mirror of https://github.com/bjornbytes/lovr.git
isDirectory and isFile;
This commit is contained in:
parent
7c5a9585fd
commit
8869539f97
|
@ -31,6 +31,14 @@ const char* lovrFilesystemGetExecutablePath() {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int lovrFilesystemIsDirectory(const char* path) {
|
||||
return PHYSFS_isDirectory(path);
|
||||
}
|
||||
|
||||
int lovrFilesystemIsFile(const char* path) {
|
||||
return lovrFilesystemExists(path) && !lovrFilesystemIsDirectory(path);
|
||||
}
|
||||
|
||||
int lovrFilesystemSetSource(const char* source) {
|
||||
return PHYSFS_mount(source, NULL, 0);
|
||||
}
|
||||
|
|
|
@ -2,4 +2,6 @@ void lovrFilesystemInit(const char* arg0);
|
|||
void lovrFilesystemDestroy();
|
||||
int lovrFilesystemExists(const char* path);
|
||||
const char* lovrFilesystemGetExecutablePath();
|
||||
int lovrFilesystemIsDirectory(const char* path);
|
||||
int lovrFilesystemIsFile(const char* path);
|
||||
int lovrFilesystemSetSource(const char* source);
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
#include "../filesystem/filesystem.h"
|
||||
|
||||
const luaL_Reg lovrFilesystem[] = {
|
||||
{ "init", l_lovrFilesystemInitialize },
|
||||
{ "exists", l_lovrFilesystemExists },
|
||||
{ "getExecutablePath", l_lovrFilesystemGetExecutablePath },
|
||||
{ "init", l_lovrFilesystemInitialize },
|
||||
{ "isDirectory", l_lovrFilesystemIsDirectory },
|
||||
{ "isFile", l_lovrFilesystemIsFile },
|
||||
{ "setSource", l_lovrFilesystemSetSource },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
@ -39,6 +41,18 @@ int l_lovrFilesystemGetExecutablePath(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int l_lovrFilesystemIsDirectory(lua_State* L) {
|
||||
const char* path = luaL_checkstring(L, 1);
|
||||
lua_pushboolean(L, lovrFilesystemIsDirectory(path));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int l_lovrFilesystemIsFile(lua_State* L) {
|
||||
const char* path = luaL_checkstring(L, 1);
|
||||
lua_pushboolean(L, lovrFilesystemIsFile(path));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int l_lovrFilesystemSetSource(lua_State* L) {
|
||||
const char* source = lua_tostring(L, 1);
|
||||
|
||||
|
|
|
@ -7,4 +7,6 @@ int l_lovrFilesystemInit(lua_State* L);
|
|||
int l_lovrFilesystemInitialize(lua_State* L);
|
||||
int l_lovrFilesystemExists(lua_State* L);
|
||||
int l_lovrFilesystemGetExecutablePath(lua_State* L);
|
||||
int l_lovrFilesystemIsDirectory(lua_State* L);
|
||||
int l_lovrFilesystemIsFile(lua_State* L);
|
||||
int l_lovrFilesystemSetSource(lua_State* L);
|
||||
|
|
Loading…
Reference in New Issue