More internal code cleanup

This commit is contained in:
Alex Szpakowski
2013-03-31 19:02:27 -03:00
parent eef4eed636
commit d5aa807747
19 changed files with 105 additions and 124 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ namespace physfs
extern bool hack_setupWriteDirectory();
File::File(std::string filename)
File::File(const std::string &filename)
: filename(filename)
, file(0)
, mode(filesystem::File::CLOSED)
+1 -1
View File
@@ -61,7 +61,7 @@ public:
* @param source The source from which to load the file. (Archive or directory)
* @param filename The relative filepath of the file to load from the source.
**/
File(std::string filename);
File(const std::string &filename);
virtual ~File();
+3 -14
View File
@@ -343,28 +343,17 @@ void Filesystem::append(const char *filename, const void *data, int64 size) cons
int Filesystem::enumerate(lua_State *L)
{
int n = lua_gettop(L);
const char *dir = luaL_checkstring(L, 1);
if (n != 1)
return luaL_error(L, "Function requires a single parameter.");
int type = lua_type(L, 1);
if (type != LUA_TSTRING)
return luaL_error(L, "Function requires parameter of type string.");
const char *dir = lua_tostring(L, 1);
char **rc = PHYSFS_enumerateFiles(dir);
char **i;
int index = 1;
lua_newtable(L);
for (i = rc; *i != 0; i++)
for (char **i = rc; *i != 0; i++)
{
lua_pushinteger(L, index);
lua_pushstring(L, *i);
lua_settable(L, -3);
lua_rawseti(L, -2, index);
index++;
}