mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Re-added love.filesystem.exists.
If PhysFS 2.1-alpha is used and a directory is symlinked, isDirectory will return false (whereas it will return true when PhysFS 2.0 is used.) exists will return true in all cases.
This commit is contained in:
@@ -579,6 +579,11 @@ std::string Filesystem::getRealDirectory(const char *filename) const
|
||||
return std::string(dir);
|
||||
}
|
||||
|
||||
bool Filesystem::exists(const char *path) const
|
||||
{
|
||||
return PHYSFS_exists(path) != 0;
|
||||
}
|
||||
|
||||
bool Filesystem::isDirectory(const char *dir) const
|
||||
{
|
||||
#ifdef LOVE_USE_PHYSFS_2_1
|
||||
@@ -597,6 +602,19 @@ bool Filesystem::isFile(const char *file) const
|
||||
return PHYSFS_exists(file) && !isDirectory(file);
|
||||
}
|
||||
|
||||
bool Filesystem::isSymlink(const char *filename) const
|
||||
{
|
||||
#ifdef LOVE_USE_PHYSFS_2_1
|
||||
PHYSFS_Stat stat = {};
|
||||
if (PHYSFS_stat(filename, &stat))
|
||||
return stat.filetype == PHYSFS_FILETYPE_SYMLINK;
|
||||
else
|
||||
return false;
|
||||
#else
|
||||
return PHYSFS_isSymbolicLink(filename) != 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Filesystem::createDirectory(const char *dir)
|
||||
{
|
||||
if (PHYSFS_getWriteDir() == 0 && !setupWriteDirectory())
|
||||
@@ -705,19 +723,6 @@ bool Filesystem::areSymlinksEnabled() const
|
||||
return PHYSFS_symbolicLinksPermitted() != 0;
|
||||
}
|
||||
|
||||
bool Filesystem::isSymlink(const char *filename) const
|
||||
{
|
||||
#ifdef LOVE_USE_PHYSFS_2_1
|
||||
PHYSFS_Stat stat = {};
|
||||
if (PHYSFS_stat(filename, &stat))
|
||||
return stat.filetype == PHYSFS_FILETYPE_SYMLINK;
|
||||
else
|
||||
return false;
|
||||
#else
|
||||
return PHYSFS_isSymbolicLink(filename) != 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::vector<std::string> &Filesystem::getRequirePath()
|
||||
{
|
||||
return requirePath;
|
||||
|
||||
@@ -75,8 +75,10 @@ public:
|
||||
|
||||
std::string getRealDirectory(const char *filename) const;
|
||||
|
||||
bool exists(const char *path) const;
|
||||
bool isDirectory(const char *dir) const;
|
||||
bool isFile(const char *file) const;
|
||||
bool isSymlink(const char *filename) const;
|
||||
|
||||
bool createDirectory(const char *dir);
|
||||
|
||||
@@ -93,7 +95,6 @@ public:
|
||||
|
||||
void setSymlinksEnabled(bool enable);
|
||||
bool areSymlinksEnabled() const;
|
||||
bool isSymlink(const char *filename) const;
|
||||
|
||||
std::vector<std::string> &getRequirePath();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user