mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
Add love.filesystem.getLastModified (issue #163)
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user