Do not copy and paste file in same location as copied file

This commit is contained in:
RocketRobz 2018-10-21 21:26:06 -06:00
parent 427290cec1
commit 554c2a3efa

View File

@ -302,7 +302,7 @@ int fileBrowse_A(DirEntry* entry, char path[PATH_MAX]) {
} }
} }
bool fileBrowse_paste(char path[PATH_MAX]) { bool fileBrowse_paste(char destPath[256]) {
int pressed = 0; int pressed = 0;
int optionOffset = 0; int optionOffset = 0;
int maxCursors = -1; int maxCursors = -1;
@ -346,8 +346,6 @@ bool fileBrowse_paste(char path[PATH_MAX]) {
if (optionOffset > maxCursors) optionOffset = 0; // Wrap around to top of list if (optionOffset > maxCursors) optionOffset = 0; // Wrap around to top of list
if (pressed & KEY_A) { if (pressed & KEY_A) {
char destPath[256];
snprintf(destPath, sizeof(destPath), "%s%s", path, clipboardFilename);
iprintf ("\x1b[%d;3H", optionOffset + OPTIONS_ENTRIES_START_ROW); iprintf ("\x1b[%d;3H", optionOffset + OPTIONS_ENTRIES_START_ROW);
if (optionOffset == 0) { if (optionOffset == 0) {
printf("Copying..."); printf("Copying...");
@ -591,8 +589,10 @@ string browseForFile (void) {
if (pressed & KEY_Y) { if (pressed & KEY_Y) {
if (clipboardOn) { if (clipboardOn) {
if (strncmp (path, "nitro:/", 7) != 0) { char destPath[256];
if (fileBrowse_paste(path)) { snprintf(destPath, sizeof(destPath), "%s%s", path, clipboardFilename);
if (strncmp (path, "nitro:/", 7) != 0 && string(clipboard) != string(destPath)) {
if (fileBrowse_paste(destPath)) {
getDirectoryContents (dirContents); getDirectoryContents (dirContents);
} }
} }