aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/qt_sdl/Platform.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/qt_sdl/Platform.cpp')
-rw-r--r--src/frontend/qt_sdl/Platform.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/frontend/qt_sdl/Platform.cpp b/src/frontend/qt_sdl/Platform.cpp
index 222e512..9bb19d1 100644
--- a/src/frontend/qt_sdl/Platform.cpp
+++ b/src/frontend/qt_sdl/Platform.cpp
@@ -217,6 +217,10 @@ std::string InstanceFileSuffix()
constexpr char AccessMode(FileMode mode, bool file_exists)
{
+
+ if (mode & FileMode::Append)
+ return 'a';
+
if (!(mode & FileMode::Write))
// If we're only opening the file for reading...
return 'r';
@@ -255,7 +259,7 @@ static std::string GetModeString(FileMode mode, bool file_exists)
FileHandle* OpenFile(const std::string& path, FileMode mode)
{
- if ((mode & FileMode::ReadWrite) == FileMode::None)
+ if ((mode & (FileMode::ReadWrite | FileMode::Append)) == FileMode::None)
{ // If we aren't reading or writing, then we can't open the file
Log(LogLevel::Error, "Attempted to open \"%s\" in neither read nor write mode (FileMode 0x%x)\n", path.c_str(), mode);
return nullptr;
@@ -327,6 +331,28 @@ bool LocalFileExists(const std::string& name)
return true;
}
+bool CheckFileWritable(const std::string& filepath)
+{
+ FileHandle* file = Platform::OpenFile(filepath.c_str(), FileMode::Append);
+ if (file)
+ {
+ Platform::CloseFile(file);
+ return true;
+ }
+ else return false;
+}
+
+bool CheckLocalFileWritable(const std::string& name)
+{
+ FileHandle* file = Platform::OpenLocalFile(name.c_str(), FileMode::Append);
+ if (file)
+ {
+ Platform::CloseFile(file);
+ return true;
+ }
+ else return false;
+}
+
bool FileSeek(FileHandle* file, s64 offset, FileSeekOrigin origin)
{
int stdorigin;