Disable file deletion in NitroFS

ALSO: file_browse.cpp: Make "path" a static char
This commit is contained in:
RocketRobz 2018-10-08 16:18:24 -06:00
parent 4b422c45f4
commit 25b2a4288f

View File

@ -44,6 +44,8 @@
using namespace std; using namespace std;
static char path[PATH_MAX];
struct DirEntry { struct DirEntry {
string name; string name;
bool isDirectory; bool isDirectory;
@ -431,7 +433,9 @@ string browseForFile (void) {
screenOffset = fileOffset - ENTRIES_PER_SCREEN + 1; screenOffset = fileOffset - ENTRIES_PER_SCREEN + 1;
showDirectoryContents (dirContents, screenOffset); showDirectoryContents (dirContents, screenOffset);
} }
getcwd(path, PATH_MAX);
if (pressed & KEY_A) { if (pressed & KEY_A) {
DirEntry* entry = &dirContents.at(fileOffset); DirEntry* entry = &dirContents.at(fileOffset);
if (entry->isDirectory) { if (entry->isDirectory) {
@ -441,30 +445,24 @@ string browseForFile (void) {
getDirectoryContents (dirContents); getDirectoryContents (dirContents);
screenOffset = 0; screenOffset = 0;
fileOffset = 0; fileOffset = 0;
} else { } else if (bothSDandFlashcard() || entry->isApp
char path[PATH_MAX]; || strcmp (path, (secondaryDrive ? "fat:/gm9i/out/" : "sd:/gm9i/out/")) != 0)
getcwd(path, PATH_MAX); {
if (bothSDandFlashcard() || entry->isApp int getOp = fileBrowse_A(entry, path);
|| strcmp (path, (secondaryDrive ? "fat:/gm9i/out/" : "sd:/gm9i/out/")) != 0) if (getOp == 0) {
{ // Return the chosen file
int getOp = fileBrowse_A(entry, path); return entry->name;
if (getOp == 0) { } else if (getOp == 1 || getOp == 2 || (getOp == 3 && nitroMounted)) {
// Return the chosen file getDirectoryContents (dirContents); // Refresh directory listing
return entry->name; if (getOp == 3 && nitroMounted) {
} else if (getOp == 1 || getOp == 2 || (getOp == 3 && nitroMounted)) { screenOffset = 0;
getDirectoryContents (dirContents); // Refresh directory listing fileOffset = 0;
if (getOp == 3 && nitroMounted) {
screenOffset = 0;
fileOffset = 0;
}
} }
} }
} }
} }
if (pressed & KEY_B) { if (pressed & KEY_B) {
char path[PATH_MAX];
getcwd(path, PATH_MAX);
if ((strcmp (path, "sd:/") == 0) || (strcmp (path, "fat:/") == 0) || (strcmp (path, "nitro:/") == 0)) { if ((strcmp (path, "sd:/") == 0) || (strcmp (path, "fat:/") == 0) || (strcmp (path, "nitro:/") == 0)) {
screenMode = 0; screenMode = 0;
return "null"; return "null";
@ -477,7 +475,7 @@ string browseForFile (void) {
} }
// Delete file/folder // Delete file/folder
if ((pressed & KEY_X) && (strcmp (entry->name.c_str(), "..") != 0)) { if ((pressed & KEY_X) && (strcmp (entry->name.c_str(), "..") != 0) && (strncmp (path, "nitro:/", 7) != 0)) {
printf ("\x1b[0;27H"); printf ("\x1b[0;27H");
printf (" "); // Clear time printf (" "); // Clear time
consoleInit(NULL, 1, BgType_Text4bpp, BgSize_T_256x256, 15, 0, false, true); consoleInit(NULL, 1, BgType_Text4bpp, BgSize_T_256x256, 15, 0, false, true);
@ -509,16 +507,12 @@ string browseForFile (void) {
if (pressed & KEY_Y) { if (pressed & KEY_Y) {
if (clipboardOn) { if (clipboardOn) {
char path[PATH_MAX];
getcwd(path, PATH_MAX);
if (strncmp (path, "nitro:/", 7) != 0) { if (strncmp (path, "nitro:/", 7) != 0) {
if (fileBrowse_paste(path)) { if (fileBrowse_paste(path)) {
getDirectoryContents (dirContents); getDirectoryContents (dirContents);
} }
} }
} else if (strcmp(entry->name.c_str(), "..") != 0) { } else if (strcmp(entry->name.c_str(), "..") != 0) {
char path[PATH_MAX];
getcwd(path, PATH_MAX);
snprintf(clipboard, sizeof(clipboard), "%s%s", path, entry->name.c_str()); snprintf(clipboard, sizeof(clipboard), "%s%s", path, entry->name.c_str());
snprintf(clipboardFilename, sizeof(clipboardFilename), "%s", entry->name.c_str()); snprintf(clipboardFilename, sizeof(clipboardFilename), "%s", entry->name.c_str());
clipboardOn = true; clipboardOn = true;