Add love.filesystem.getLastModified (issue #163)

This commit is contained in:
Bart van Strien
2011-01-06 22:54:51 +01:00
parent 089da5b08d
commit aa7ec54121
4 changed files with 23 additions and 0 deletions
@@ -557,6 +557,20 @@ namespace physfs
}
}
int Filesystem::getLastModified(lua_State * L)
{
const char * filename = luaL_checkstring(L, 1);
int64_t time = PHYSFS_getLastModTime(filename);
if (time == -1)
{
lua_pushnil(L);
lua_pushstring(L, "Could not determine file modification date.");
return 2;
}
lua_pushnumber(L, time);
return 1;
}
} // physfs
} // filesystem
} // love
@@ -278,6 +278,8 @@ namespace physfs
**/
int load(lua_State * L);
int getLastModified(lua_State * L);
}; // Filesystem
} // physfs
@@ -221,6 +221,11 @@ namespace physfs
return instance->load(L);
}
int w_getLastModified(lua_State * L)
{
return instance->getLastModified(L);
}
int loader(lua_State * L)
{
const char * filename = lua_tostring(L, -1);
@@ -297,6 +302,7 @@ namespace physfs
{ "enumerate", w_enumerate },
{ "lines", w_lines },
{ "load", w_load },
{ "getLastModified", w_getLastModified },
{ "newFileData", w_newFileData },
{ 0, 0 }
};
@@ -57,6 +57,7 @@ namespace physfs
int w_enumerate(lua_State * L);
int w_lines(lua_State * L);
int w_load(lua_State * L);
int w_getLastModified(lua_State * L);
int loader(lua_State * L);
extern "C" LOVE_EXPORT int luaopen_love_filesystem(lua_State * L);