summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-11-23 20:26:00 +0100
committermadmaxoft <github@xoft.cz>2013-11-23 20:26:00 +0100
commit94e14e1ace16a265b8e58a186c308609c504d288 (patch)
treece265c131f19bfcf43382a0bd0a80da5e84812c4 /source
parentAPIDump: Added more constant groups. (diff)
downloadcuberite-94e14e1ace16a265b8e58a186c308609c504d288.tar
cuberite-94e14e1ace16a265b8e58a186c308609c504d288.tar.gz
cuberite-94e14e1ace16a265b8e58a186c308609c504d288.tar.bz2
cuberite-94e14e1ace16a265b8e58a186c308609c504d288.tar.lz
cuberite-94e14e1ace16a265b8e58a186c308609c504d288.tar.xz
cuberite-94e14e1ace16a265b8e58a186c308609c504d288.tar.zst
cuberite-94e14e1ace16a265b8e58a186c308609c504d288.zip
Diffstat (limited to '')
-rw-r--r--source/Bindings.cpp34
-rw-r--r--source/Bindings.h2
-rw-r--r--source/OSSupport/File.cpp16
-rw-r--r--source/OSSupport/File.h3
4 files changed, 53 insertions, 2 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index 65c154b78..ad3ad8423 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -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);
diff --git a/source/Bindings.h b/source/Bindings.h
index 7d4999505..bc8589293 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -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 */
diff --git a/source/OSSupport/File.cpp b/source/OSSupport/File.cpp
index 86276bd79..274aa52da 100644
--- a/source/OSSupport/File.cpp
+++ b/source/OSSupport/File.cpp
@@ -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;
diff --git a/source/OSSupport/File.h b/source/OSSupport/File.h
index 70f81c8d2..01663a229 100644
--- a/source/OSSupport/File.h
+++ b/source/OSSupport/File.h
@@ -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).