mirror of
https://github.com/love2d/love.git
synced 2026-08-20 04:30:09 +02:00
Removed restriction on mounting a filepath to root
--HG-- branch : love.filesystem.mount2
This commit is contained in:
@@ -184,17 +184,13 @@ bool Filesystem::setupWriteDirectory()
|
|||||||
|
|
||||||
bool Filesystem::mount(const char *archive, const char *mountpoint)
|
bool Filesystem::mount(const char *archive, const char *mountpoint)
|
||||||
{
|
{
|
||||||
if (!isInited || !archive || !mountpoint)
|
if (!isInited || !archive)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Not allowed for safety reasons.
|
// Not allowed for safety reasons.
|
||||||
if (strlen(archive) == 0 || strstr(archive, "..") || strcmp(archive, "/") == 0)
|
if (strlen(archive) == 0 || strstr(archive, "..") || strcmp(archive, "/") == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// An empty string or "/" is equivalent to doing PHYSFS_addToSearchPath.
|
|
||||||
if (strlen(mountpoint) == 0 || strcmp(mountpoint, "/") == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
const char *realDir = PHYSFS_getRealDir(archive);
|
const char *realDir = PHYSFS_getRealDir(archive);
|
||||||
if (!realDir)
|
if (!realDir)
|
||||||
return false;
|
return false;
|
||||||
@@ -223,9 +219,8 @@ bool Filesystem::unmount(const char *archive)
|
|||||||
realPath += LOVE_PATH_SEPARATOR;
|
realPath += LOVE_PATH_SEPARATOR;
|
||||||
realPath += archive;
|
realPath += archive;
|
||||||
|
|
||||||
// Make sure the archive path was previously added with PHYSFS_mount.
|
|
||||||
const char *mountPoint = PHYSFS_getMountPoint(realPath.c_str());
|
const char *mountPoint = PHYSFS_getMountPoint(realPath.c_str());
|
||||||
if (!mountPoint || strcmp(mountPoint, "/") == 0)
|
if (!mountPoint)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return PHYSFS_removeFromSearchPath(realPath.c_str());
|
return PHYSFS_removeFromSearchPath(realPath.c_str());
|
||||||
|
|||||||
Reference in New Issue
Block a user