mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-26 07:39:56 -06:00
Check for write permissions for some key files (#1972)
* check if an nds save file can be opened for writing also add the ability to open a file in append mode * fix multi-instance saves also move the check for file writability into a separate function (probably uneeded?) * implement check for gba roms * move rom load error messages into the functions also finish gba slot (oops) * improve error string * check write perms before saving path settings * fix memory leak * check for writability of firmware/nand/sds * add secondary checks for nand/firmware * add check for config file being writable * Return the file write error as a QString to avoid the invalid char* causing a garbled error message. Qt wants it as QString either way.
This commit is contained in:
@ -136,6 +136,11 @@ enum FileMode : unsigned {
|
||||
*/
|
||||
Text = 0b01'00'00,
|
||||
|
||||
/**
|
||||
* Opens a file in append mode.
|
||||
*/
|
||||
Append = 0b10'00'00,
|
||||
|
||||
/**
|
||||
* Opens a file for reading and writing.
|
||||
* Equivalent to <tt>Read | Write</tt>.
|
||||
@ -201,6 +206,13 @@ FileHandle* OpenLocalFile(const std::string& path, FileMode mode);
|
||||
bool FileExists(const std::string& name);
|
||||
bool LocalFileExists(const std::string& name);
|
||||
|
||||
// Returns true if we have permission to write to the file.
|
||||
// Warning: Also creates the file if not present!
|
||||
bool CheckFileWritable(const std::string& filepath);
|
||||
|
||||
// Same as above (CheckFileWritable()) but for local files.
|
||||
bool CheckLocalFileWritable(const std::string& filepath);
|
||||
|
||||
/** Close a file opened with \c OpenFile.
|
||||
* @returns \c true if the file was closed successfully, false otherwise.
|
||||
* @post \c file is no longer valid and should not be used.
|
||||
|
Reference in New Issue
Block a user