mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Changed the SearchOrder argument of love.filesystem.setIdentity and love.filesystem.mount to a boolean (append) instead of an enum
This commit is contained in:
@@ -96,7 +96,7 @@ bool Filesystem::isFused() const
|
||||
return fused;
|
||||
}
|
||||
|
||||
bool Filesystem::setIdentity(const char *ident, SearchOrder searchorder)
|
||||
bool Filesystem::setIdentity(const char *ident, bool appendToPath)
|
||||
{
|
||||
if (!initialized)
|
||||
return false;
|
||||
@@ -126,11 +126,9 @@ bool Filesystem::setIdentity(const char *ident, SearchOrder searchorder)
|
||||
if (!old_save_path.empty())
|
||||
PHYSFS_removeFromSearchPath(old_save_path.c_str());
|
||||
|
||||
bool append = (searchorder == SEARCH_ORDER_LAST);
|
||||
|
||||
// Try to add the save directory to the search path.
|
||||
// (No error on fail, it means that the path doesn't exist).
|
||||
PHYSFS_addToSearchPath(save_path_full.c_str(), append);
|
||||
PHYSFS_addToSearchPath(save_path_full.c_str(), appendToPath);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -200,7 +198,7 @@ bool Filesystem::setupWriteDirectory()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Filesystem::mount(const char *archive, const char *mountpoint, SearchOrder searchorder)
|
||||
bool Filesystem::mount(const char *archive, const char *mountpoint, bool appendToPath)
|
||||
{
|
||||
if (!initialized || !archive)
|
||||
return false;
|
||||
@@ -238,9 +236,7 @@ bool Filesystem::mount(const char *archive, const char *mountpoint, SearchOrder
|
||||
if (realPath.length() == 0)
|
||||
return false;
|
||||
|
||||
bool append = (searchorder == SEARCH_ORDER_LAST);
|
||||
|
||||
return PHYSFS_mount(realPath.c_str(), mountpoint, append);
|
||||
return PHYSFS_mount(realPath.c_str(), mountpoint, appendToPath);
|
||||
}
|
||||
|
||||
bool Filesystem::unmount(const char *archive)
|
||||
@@ -608,24 +604,6 @@ int64 Filesystem::getSize(const char *filename) const
|
||||
return size;
|
||||
}
|
||||
|
||||
bool Filesystem::getConstant(const char *in, Filesystem::SearchOrder &out)
|
||||
{
|
||||
return orders.find(in, out);
|
||||
}
|
||||
|
||||
bool Filesystem::getConstant(Filesystem::SearchOrder in, const char *&out)
|
||||
{
|
||||
return orders.find(in, out);
|
||||
}
|
||||
|
||||
StringMap<Filesystem::SearchOrder, Filesystem::SEARCH_ORDER_MAX_ENUM>::Entry Filesystem::orderEntries[] =
|
||||
{
|
||||
{"first", Filesystem::SEARCH_ORDER_FIRST},
|
||||
{"last", Filesystem::SEARCH_ORDER_LAST},
|
||||
};
|
||||
|
||||
StringMap<Filesystem::SearchOrder, Filesystem::SEARCH_ORDER_MAX_ENUM> Filesystem::orders(Filesystem::orderEntries, sizeof(Filesystem::orderEntries));
|
||||
|
||||
} // physfs
|
||||
} // filesystem
|
||||
} // love
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "common/Module.h"
|
||||
#include "common/config.h"
|
||||
#include "common/int.h"
|
||||
#include "common/StringMap.h"
|
||||
#include "filesystem/FileData.h"
|
||||
#include "File.h"
|
||||
|
||||
@@ -77,17 +76,8 @@ class Filesystem : public Module
|
||||
{
|
||||
public:
|
||||
|
||||
// love.filesystem.setIdentity("foo", "last")
|
||||
enum SearchOrder
|
||||
{
|
||||
SEARCH_ORDER_FIRST,
|
||||
SEARCH_ORDER_LAST,
|
||||
SEARCH_ORDER_MAX_ENUM
|
||||
};
|
||||
|
||||
Filesystem();
|
||||
|
||||
~Filesystem();
|
||||
virtual ~Filesystem();
|
||||
|
||||
const char *getName() const;
|
||||
|
||||
@@ -108,7 +98,7 @@ public:
|
||||
* @param ident The name of the game. Will be used to
|
||||
* to create the folder in the LOVE data folder.
|
||||
**/
|
||||
bool setIdentity(const char *ident, SearchOrder searchorder = SEARCH_ORDER_FIRST);
|
||||
bool setIdentity(const char *ident, bool appendToPath = false);
|
||||
const char *getIdentity() const;
|
||||
|
||||
/**
|
||||
@@ -124,7 +114,7 @@ public:
|
||||
**/
|
||||
const char *getSource() const;
|
||||
|
||||
bool mount(const char *archive, const char *mountpoint, SearchOrder searchorder = SEARCH_ORDER_FIRST);
|
||||
bool mount(const char *archive, const char *mountpoint, bool appendToPath = false);
|
||||
bool unmount(const char *archive);
|
||||
|
||||
/**
|
||||
@@ -288,9 +278,6 @@ public:
|
||||
**/
|
||||
static int lines_i(lua_State *L);
|
||||
|
||||
static bool getConstant(const char *in, SearchOrder &out);
|
||||
static bool getConstant(SearchOrder in, const char *&out);
|
||||
|
||||
private:
|
||||
|
||||
// Contains the current working directory (UTF8).
|
||||
@@ -319,9 +306,6 @@ private:
|
||||
bool fused;
|
||||
bool fusedSet;
|
||||
|
||||
static StringMap<SearchOrder, SEARCH_ORDER_MAX_ENUM>::Entry orderEntries[];
|
||||
static StringMap<SearchOrder, SEARCH_ORDER_MAX_ENUM> orders;
|
||||
|
||||
}; // Filesystem
|
||||
|
||||
} // physfs
|
||||
|
||||
@@ -64,14 +64,9 @@ int w_isFused(lua_State *L)
|
||||
int w_setIdentity(lua_State *L)
|
||||
{
|
||||
const char *arg = luaL_checkstring(L, 1);
|
||||
bool append = luax_optboolean(L, 2, false);
|
||||
|
||||
Filesystem::SearchOrder order = Filesystem::SEARCH_ORDER_FIRST;
|
||||
const char *ostr = lua_isnoneornil(L, 2) ? 0 : lua_tostring(L, 2);
|
||||
|
||||
if (ostr && !Filesystem::getConstant(ostr, order))
|
||||
return luaL_error(L, "Invalid filesystem search order: %s", ostr);
|
||||
|
||||
if (!instance->setIdentity(arg, order))
|
||||
if (!instance->setIdentity(arg, append))
|
||||
return luaL_error(L, "Could not set write directory.");
|
||||
|
||||
return 0;
|
||||
@@ -103,14 +98,9 @@ int w_mount(lua_State *L)
|
||||
{
|
||||
const char *archive = luaL_checkstring(L, 1);
|
||||
const char *mountpoint = luaL_checkstring(L, 2);
|
||||
bool append = luax_optboolean(L, 3, false);
|
||||
|
||||
Filesystem::SearchOrder order = Filesystem::SEARCH_ORDER_FIRST;
|
||||
const char *ostr = lua_isnoneornil(L, 3) ? 0 : lua_tostring(L, 3);
|
||||
|
||||
if (ostr && !Filesystem::getConstant(ostr, order))
|
||||
return luaL_error(L, "Invalid filesystem search order: %s", ostr);
|
||||
|
||||
luax_pushboolean(L, instance->mount(archive, mountpoint, order));
|
||||
luax_pushboolean(L, instance->mount(archive, mountpoint, append));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -312,7 +312,7 @@ function love.init()
|
||||
},
|
||||
console = false, -- Only relevant for windows.
|
||||
identity = false,
|
||||
identityorder = "first",
|
||||
appendidentity = false,
|
||||
}
|
||||
|
||||
-- If config file exists, load it and allow it to update config table.
|
||||
@@ -395,7 +395,7 @@ function love.init()
|
||||
|
||||
if love.filesystem then
|
||||
love.filesystem.setFused(is_fused_game)
|
||||
love.filesystem.setIdentity(c.identity or love.filesystem.getIdentity(), c.identityorder)
|
||||
love.filesystem.setIdentity(c.identity or love.filesystem.getIdentity(), c.appendidentity)
|
||||
if love.filesystem.exists("main.lua") then
|
||||
require("main")
|
||||
end
|
||||
|
||||
@@ -550,8 +550,8 @@ const unsigned char boot_lua[] =
|
||||
0x66, 0x6f, 0x72, 0x20, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x2e, 0x0a,
|
||||
0x09, 0x09, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65,
|
||||
0x2c, 0x0a,
|
||||
0x09, 0x09, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x20, 0x3d, 0x20,
|
||||
0x22, 0x66, 0x69, 0x72, 0x73, 0x74, 0x22, 0x2c, 0x0a,
|
||||
0x09, 0x09, 0x61, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x20, 0x3d,
|
||||
0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x2c, 0x0a,
|
||||
0x09, 0x7d, 0x0a,
|
||||
0x09, 0x2d, 0x2d, 0x20, 0x49, 0x66, 0x20, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x20, 0x66, 0x69, 0x6c, 0x65,
|
||||
0x20, 0x65, 0x78, 0x69, 0x73, 0x74, 0x73, 0x2c, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x20, 0x69, 0x74, 0x20, 0x61,
|
||||
@@ -691,8 +691,8 @@ const unsigned char boot_lua[] =
|
||||
0x73, 0x65, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x28, 0x63, 0x2e, 0x69, 0x64, 0x65, 0x6e,
|
||||
0x74, 0x69, 0x74, 0x79, 0x20, 0x6f, 0x72, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x73,
|
||||
0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x67, 0x65, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x28,
|
||||
0x29, 0x2c, 0x20, 0x63, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x6f, 0x72, 0x64, 0x65, 0x72,
|
||||
0x29, 0x0a,
|
||||
0x29, 0x2c, 0x20, 0x63, 0x2e, 0x61, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74,
|
||||
0x79, 0x29, 0x0a,
|
||||
0x09, 0x09, 0x69, 0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x79, 0x73, 0x74,
|
||||
0x65, 0x6d, 0x2e, 0x65, 0x78, 0x69, 0x73, 0x74, 0x73, 0x28, 0x22, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x6c, 0x75,
|
||||
0x61, 0x22, 0x29, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a,
|
||||
|
||||
Reference in New Issue
Block a user