1
0

Added cFile:ReadWholeFile() to Lua API.

This commit is contained in:
madmaxoft 2013-11-23 20:26:00 +01:00
parent 520088fc7c
commit 94e14e1ace
4 changed files with 53 additions and 2 deletions

View File

@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 11/22/13 16:24:50.
** Generated automatically by tolua++-1.0.92 on 11/23/13 19:57:30.
*/
#ifndef __cplusplus
@ -2303,6 +2303,37 @@ static int tolua_AllToLua_cFile_CreateFolder00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
/* method: ReadWholeFile of class cFile */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cFile_ReadWholeFile00
static int tolua_AllToLua_cFile_ReadWholeFile00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertable(tolua_S,1,"cFile",0,&tolua_err) ||
!tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
const AString a_FileName = ((const AString) tolua_tocppstring(tolua_S,2,0));
{
AString tolua_ret = (AString) cFile::ReadWholeFile(a_FileName);
tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
tolua_pushcppstring(tolua_S,(const char*)a_FileName);
}
}
return 2;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'ReadWholeFile'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* function: BlockStringToType */
#ifndef TOLUA_DISABLE_tolua_AllToLua_BlockStringToType00
static int tolua_AllToLua_BlockStringToType00(lua_State* tolua_S)
@ -29538,6 +29569,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"IsFile",tolua_AllToLua_cFile_IsFile00);
tolua_function(tolua_S,"GetSize",tolua_AllToLua_cFile_GetSize00);
tolua_function(tolua_S,"CreateFolder",tolua_AllToLua_cFile_CreateFolder00);
tolua_function(tolua_S,"ReadWholeFile",tolua_AllToLua_cFile_ReadWholeFile00);
tolua_endmodule(tolua_S);
tolua_constant(tolua_S,"E_BLOCK_AIR",E_BLOCK_AIR);
tolua_constant(tolua_S,"E_BLOCK_STONE",E_BLOCK_STONE);

View File

@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 11/22/13 16:24:51.
** Generated automatically by tolua++-1.0.92 on 11/23/13 19:57:31.
*/
/* Exported function */

View File

@ -420,6 +420,22 @@ AStringVector cFile::GetFolderContents(const AString & a_Folder)
AString cFile::ReadWholeFile(const AString & a_FileName)
{
cFile f;
if (!f.Open(a_FileName, fmRead))
{
return "";
}
AString Contents;
f.ReadRestOfFile(Contents);
return Contents;
}
int cFile::Printf(const char * a_Fmt, ...)
{
AString buf;

View File

@ -121,6 +121,9 @@ public:
/// Creates a new folder with the specified name. Returns true if successful. Path may be relative or absolute
static bool CreateFolder(const AString & a_FolderPath);
/// Returns the entire contents of the specified file as a string. Returns empty string on error.
static AString ReadWholeFile(const AString & a_FileName);
// tolua_end
/// Returns the list of all items in the specified folder (files, folders, nix pipes, whatever's there).