Show a warning when a file is currently locked (on A button)

This commit is contained in:
d0k3 2016-12-08 22:19:42 +01:00
parent 648f314a0a
commit 67923556da
4 changed files with 16 additions and 2 deletions

View File

@ -38,7 +38,7 @@
(((v) % (a)) ? ((v) + (a) - ((v) % (a))) : (v)) (((v) % (a)) ? ((v) + (a) - ((v) % (a))) : (v))
// GodMode9 version // GodMode9 version
#define VERSION "0.8.3" #define VERSION "0.8.4"
// input / output paths // input / output paths
#define INPUT_PATHS "0:", "0:/files9", "0:/Decrypt9" #define INPUT_PATHS "0:", "0:/files9", "0:/Decrypt9"

View File

@ -402,6 +402,15 @@ u32 GetWritePermissions() {
return write_permissions; return write_permissions;
} }
bool FileCheck(const char* path) {
FIL file;
if (PathToNumFSA(path) < 0) return true;
if (f_open(&file, path, FA_READ | FA_OPEN_EXISTING) == FR_OK) {
f_close(&file);
return true;
} else return false;
}
bool FileSetData(const char* path, const u8* data, size_t size, size_t foffset, bool create) { bool FileSetData(const char* path, const u8* data, size_t size, size_t foffset, bool create) {
int drvtype = DriveType(path); int drvtype = DriveType(path);
if (!CheckWritePermissions(path)) return false; if (!CheckWritePermissions(path)) return false;

View File

@ -64,6 +64,9 @@ bool SetWritePermissions(u32 perm, bool add_perm);
/** Get write permissions */ /** Get write permissions */
u32 GetWritePermissions(); u32 GetWritePermissions();
/** True if file exists and is not locked, false otherwise **/
bool FileCheck(const char* path);
/** Create / open file and write the provided data to it **/ /** Create / open file and write the provided data to it **/
bool FileSetData(const char* path, const u8* data, size_t size, size_t foffset, bool create); bool FileSetData(const char* path, const u8* data, size_t size, size_t foffset, bool create);

View File

@ -700,7 +700,9 @@ u32 GodMode() {
(filetype == GAME_NCCH) ? "Mount as NCCH image" : "???"; (filetype == GAME_NCCH) ? "Mount as NCCH image" : "???";
if (searchdrv > 0) optionstr[searchdrv-1] = "Open containing folder"; if (searchdrv > 0) optionstr[searchdrv-1] = "Open containing folder";
int user_select = ShowSelectPrompt(n_opt, optionstr, pathstr); int user_select = 0;
if (!FileCheck(curr_entry->path)) ShowPrompt(false, "%s\nFile is currently locked", pathstr);
else user_select = ShowSelectPrompt(n_opt, optionstr, pathstr);
if (user_select == hexviewer) { // -> show in hex viewer if (user_select == hexviewer) { // -> show in hex viewer
HexViewer(curr_entry->path); HexViewer(curr_entry->path);
} else if (user_select == calcsha) { // -> calculate SHA-256 } else if (user_select == calcsha) { // -> calculate SHA-256