mirror of
https://github.com/love2d/love.git
synced 2026-08-17 11:00:31 +02:00
Finally abstracted constants properly. Changed how the event module works; wasn't really abstract before. Removed libs we're not going to use: native, signal.
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
#include "File.h"
|
||||
|
||||
// STD
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
|
||||
// LOVE
|
||||
#include "Filesystem.h"
|
||||
@@ -46,6 +46,9 @@ namespace physfs
|
||||
|
||||
bool File::open(Mode mode)
|
||||
{
|
||||
if(mode == CLOSED)
|
||||
return true;
|
||||
|
||||
// File must exist if read mode.
|
||||
if((mode == READ))
|
||||
if(!PHYSFS_exists(filename.c_str()))
|
||||
@@ -73,9 +76,6 @@ namespace physfs
|
||||
case WRITE:
|
||||
file = PHYSFS_openWrite(filename.c_str());
|
||||
break;
|
||||
case CLOSED:
|
||||
// Heh. Case closed.
|
||||
return true;
|
||||
}
|
||||
|
||||
return (file != 0);
|
||||
|
||||
@@ -44,11 +44,14 @@ namespace physfs
|
||||
int w_File_open(lua_State * L)
|
||||
{
|
||||
File * file = luax_checkfile(L, 1);
|
||||
int mode = luaL_optint(L, 2, File::READ);
|
||||
File::Mode mode;
|
||||
|
||||
if(!File::getConstant(luaL_checkstring(L, 2), mode))
|
||||
return luaL_error(L, "Incorrect file open mode: %s", luaL_checkstring(L, 2));
|
||||
|
||||
try
|
||||
{
|
||||
lua_pushboolean(L, file->open((File::Mode)mode) ? 1 : 0);
|
||||
lua_pushboolean(L, file->open(mode) ? 1 : 0);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
||||
@@ -265,15 +265,6 @@ namespace physfs
|
||||
0
|
||||
};
|
||||
|
||||
// List of constants.
|
||||
static const Constant constants[] = {
|
||||
{ "file_closed", File::CLOSED },
|
||||
{ "file_read", File::READ },
|
||||
{ "file_write", File::WRITE },
|
||||
{ "file_append", File::APPEND },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int luaopen_love_filesystem(lua_State * L)
|
||||
{
|
||||
if(instance == 0)
|
||||
@@ -295,7 +286,6 @@ namespace physfs
|
||||
w.flags = MODULE_FILESYSTEM_T;
|
||||
w.functions = functions;
|
||||
w.types = types;
|
||||
w.constants = constants;
|
||||
|
||||
return luax_register_module(L, w);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user