mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
macOS/iOS: Use more modern APIs for determining the save directory.
--HG-- branch : minor
This commit is contained in:
@@ -231,7 +231,7 @@ public:
|
||||
* This "native" method returns a table of all
|
||||
* files in a given directory.
|
||||
**/
|
||||
virtual void getDirectoryItems(const char *dir, std::vector<std::string> &items) = 0;
|
||||
virtual bool getDirectoryItems(const char *dir, std::vector<std::string> &items) = 0;
|
||||
|
||||
/**
|
||||
* Enable or disable symbolic link support in love.filesystem.
|
||||
|
||||
@@ -46,6 +46,10 @@
|
||||
# include "common/ios.h"
|
||||
#endif
|
||||
|
||||
#ifdef LOVE_MACOSX
|
||||
# include "common/macosx.h"
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef LOVE_ANDROID
|
||||
@@ -497,9 +501,7 @@ std::string Filesystem::getAppdataDirectory()
|
||||
appdata = to_utf8(w_appdata);
|
||||
replace_char(appdata, '\\', '/');
|
||||
#elif defined(LOVE_MACOSX)
|
||||
std::string udir = getUserDirectory();
|
||||
udir.append("/Library/Application Support");
|
||||
appdata = normalize(udir);
|
||||
appdata = normalize(love::macosx::getAppdataDirectory());
|
||||
#elif defined(LOVE_IOS)
|
||||
appdata = normalize(love::ios::getAppdataDirectory());
|
||||
#elif defined(LOVE_LINUX)
|
||||
@@ -644,20 +646,21 @@ void Filesystem::append(const char *filename, const void *data, int64 size) cons
|
||||
throw love::Exception("Data could not be written.");
|
||||
}
|
||||
|
||||
void Filesystem::getDirectoryItems(const char *dir, std::vector<std::string> &items)
|
||||
bool Filesystem::getDirectoryItems(const char *dir, std::vector<std::string> &items)
|
||||
{
|
||||
if (!PHYSFS_isInit())
|
||||
return;
|
||||
return false;
|
||||
|
||||
char **rc = PHYSFS_enumerateFiles(dir);
|
||||
|
||||
if (rc == nullptr)
|
||||
return;
|
||||
return false;
|
||||
|
||||
for (char **i = rc; *i != 0; i++)
|
||||
items.push_back(*i);
|
||||
|
||||
PHYSFS_freeList(rc);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Filesystem::setSymlinksEnabled(bool enable)
|
||||
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
void write(const char *filename, const void *data, int64 size) const override;
|
||||
void append(const char *filename, const void *data, int64 size) const override;
|
||||
|
||||
void getDirectoryItems(const char *dir, std::vector<std::string> &items) override;
|
||||
bool getDirectoryItems(const char *dir, std::vector<std::string> &items) override;
|
||||
|
||||
void setSymlinksEnabled(bool enable) override;
|
||||
bool areSymlinksEnabled() const override;
|
||||
|
||||
Reference in New Issue
Block a user