mirror of
https://github.com/rvtr/GodMode9i.git
synced 2025-11-02 00:11:07 -04:00
Add copying/pasting to a specific folder
This commit is contained in:
parent
933d3b6e28
commit
f6bc3a24ef
@ -72,9 +72,9 @@ void gbaCartDump(void) {
|
|||||||
printf("Creating directory...");
|
printf("Creating directory...");
|
||||||
mkdir("fat:/gm9i/out", 0777);
|
mkdir("fat:/gm9i/out", 0777);
|
||||||
}
|
}
|
||||||
char gbaHeaderGameTitle[13] = "/0";
|
char gbaHeaderGameTitle[13] = "\0";
|
||||||
char gbaHeaderGameCode[5] = "/0";
|
char gbaHeaderGameCode[5] = "\0";
|
||||||
char gbaHeaderMakerCode[3] = "/0";
|
char gbaHeaderMakerCode[3] = "\0";
|
||||||
for (int i = 0; i < 12; i++) {
|
for (int i = 0; i < 12; i++) {
|
||||||
gbaHeaderGameTitle[i] = *(char*)(0x080000A0+i);
|
gbaHeaderGameTitle[i] = *(char*)(0x080000A0+i);
|
||||||
if (*(u8*)(0x080000A0+i) == 0) {
|
if (*(u8*)(0x080000A0+i) == 0) {
|
||||||
@ -247,6 +247,7 @@ void driveMenu (void) {
|
|||||||
if (isDSiMode()) {
|
if (isDSiMode()) {
|
||||||
if (sdMounted) {
|
if (sdMounted) {
|
||||||
dmTextPrinted = false;
|
dmTextPrinted = false;
|
||||||
|
secondaryDrive = false;
|
||||||
chdir("sd:/");
|
chdir("sd:/");
|
||||||
screenMode = 1;
|
screenMode = 1;
|
||||||
break;
|
break;
|
||||||
@ -254,6 +255,7 @@ void driveMenu (void) {
|
|||||||
} else {
|
} else {
|
||||||
if (flashcardMounted) {
|
if (flashcardMounted) {
|
||||||
dmTextPrinted = false;
|
dmTextPrinted = false;
|
||||||
|
secondaryDrive = true;
|
||||||
chdir("fat:/");
|
chdir("fat:/");
|
||||||
screenMode = 1;
|
screenMode = 1;
|
||||||
break;
|
break;
|
||||||
@ -263,6 +265,7 @@ void driveMenu (void) {
|
|||||||
if (isDSiMode()) {
|
if (isDSiMode()) {
|
||||||
if (flashcardMounted) {
|
if (flashcardMounted) {
|
||||||
dmTextPrinted = false;
|
dmTextPrinted = false;
|
||||||
|
secondaryDrive = true;
|
||||||
chdir("fat:/");
|
chdir("fat:/");
|
||||||
screenMode = 1;
|
screenMode = 1;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -13,6 +13,8 @@ u8 stored_SCFG_MC = 0;
|
|||||||
bool sdMounted = false;
|
bool sdMounted = false;
|
||||||
bool flashcardMounted = false;
|
bool flashcardMounted = false;
|
||||||
|
|
||||||
|
bool secondaryDrive = false; // false == SD card, true == Flashcard
|
||||||
|
|
||||||
bool sdFound(void) {
|
bool sdFound(void) {
|
||||||
if (access("sd:/", F_OK) == 0) {
|
if (access("sd:/", F_OK) == 0) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -6,6 +6,8 @@ extern u8 stored_SCFG_MC;
|
|||||||
extern bool sdMounted;
|
extern bool sdMounted;
|
||||||
extern bool flashcardMounted;
|
extern bool flashcardMounted;
|
||||||
|
|
||||||
|
extern bool secondaryDrive; // false == SD card, true == Flashcard
|
||||||
|
|
||||||
extern bool sdFound(void);
|
extern bool sdFound(void);
|
||||||
extern bool flashcardFound(void);
|
extern bool flashcardFound(void);
|
||||||
extern bool bothSDandFlashcard(void);
|
extern bool bothSDandFlashcard(void);
|
||||||
|
|||||||
@ -5,6 +5,12 @@
|
|||||||
|
|
||||||
u32 copyBuf[copyBufSize];
|
u32 copyBuf[copyBufSize];
|
||||||
|
|
||||||
|
char clipboard[256];
|
||||||
|
char clipboardFilename[256];
|
||||||
|
bool clipboardOn = false;
|
||||||
|
bool clipboardUsed = false;
|
||||||
|
bool clipboardDrive = false; // false == SD card, true == Flashcard
|
||||||
|
|
||||||
off_t getFileSize(const char *fileName)
|
off_t getFileSize(const char *fileName)
|
||||||
{
|
{
|
||||||
FILE* fp = fopen(fileName, "rb");
|
FILE* fp = fopen(fileName, "rb");
|
||||||
|
|||||||
@ -1,7 +1,13 @@
|
|||||||
#ifndef FILE_COPY
|
#ifndef FILE_COPY
|
||||||
#define FILE_COPY
|
#define FILE_COPY
|
||||||
|
|
||||||
off_t getFileSize(const char *fileName);
|
extern char clipboard[256];
|
||||||
int fcopy(const char *sourcePath, const char *destinationPath);
|
extern char clipboardFilename[256];
|
||||||
|
extern bool clipboardOn;
|
||||||
|
extern bool clipboardUsed;
|
||||||
|
extern bool clipboardDrive; // false == SD card, true == Flashcard
|
||||||
|
|
||||||
|
extern off_t getFileSize(const char *fileName);
|
||||||
|
extern int fcopy(const char *sourcePath, const char *destinationPath);
|
||||||
|
|
||||||
#endif // FILE_COPY
|
#endif // FILE_COPY
|
||||||
@ -262,6 +262,69 @@ int fileBrowse_A(DirEntry* entry) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool fileBrowse_paste(void) {
|
||||||
|
int pressed = 0;
|
||||||
|
int optionOffset = 0;
|
||||||
|
int maxCursors = -1;
|
||||||
|
|
||||||
|
char path[PATH_MAX];
|
||||||
|
getcwd(path, PATH_MAX);
|
||||||
|
printf ("\x1b[0;27H");
|
||||||
|
printf (" "); // Clear time
|
||||||
|
consoleInit(NULL, 1, BgType_Text4bpp, BgSize_T_256x256, 15, 0, false, true);
|
||||||
|
printf("Paste file here?\n\n");
|
||||||
|
iprintf ("\x1b[%d;0H", ENTRIES_START_ROW);
|
||||||
|
maxCursors++;
|
||||||
|
printf(" Copy path\n");
|
||||||
|
if (secondaryDrive == clipboardDrive) {
|
||||||
|
maxCursors++;
|
||||||
|
printf(" Move path\n");
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
printf("(<A> select, <B> cancel)");
|
||||||
|
while (true) {
|
||||||
|
// Clear old cursors
|
||||||
|
for (int i = ENTRIES_START_ROW; i < (maxCursors+1) + ENTRIES_START_ROW; i++) {
|
||||||
|
iprintf ("\x1b[%d;0H ", i);
|
||||||
|
}
|
||||||
|
// Show cursor
|
||||||
|
iprintf ("\x1b[%d;0H->", optionOffset + ENTRIES_START_ROW);
|
||||||
|
|
||||||
|
// Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do
|
||||||
|
do {
|
||||||
|
scanKeys();
|
||||||
|
pressed = keysDownRepeat();
|
||||||
|
swiWaitForVBlank();
|
||||||
|
} while (!(pressed & KEY_UP) && !(pressed & KEY_DOWN)
|
||||||
|
&& !(pressed & KEY_A) && !(pressed & KEY_B));
|
||||||
|
|
||||||
|
if (pressed & KEY_UP) optionOffset -= 1;
|
||||||
|
if (pressed & KEY_DOWN) optionOffset += 1;
|
||||||
|
|
||||||
|
if (optionOffset < 0) optionOffset = maxCursors; // Wrap around to bottom of list
|
||||||
|
if (optionOffset > maxCursors) optionOffset = 0; // Wrap around to top of list
|
||||||
|
|
||||||
|
if (pressed & KEY_A) {
|
||||||
|
char path[PATH_MAX];
|
||||||
|
getcwd(path, PATH_MAX);
|
||||||
|
char destPath[256];
|
||||||
|
snprintf(destPath, sizeof(destPath), "%s%s", path, clipboardFilename);
|
||||||
|
iprintf ("\x1b[%d;3H", optionOffset + ENTRIES_START_ROW);
|
||||||
|
if (optionOffset == 0) {
|
||||||
|
printf("Copying...");
|
||||||
|
fcopy(clipboard, destPath);
|
||||||
|
} else {
|
||||||
|
printf("Moving...");
|
||||||
|
rename(clipboard, destPath);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (pressed & KEY_B) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
string browseForFile (void) {
|
string browseForFile (void) {
|
||||||
int pressed = 0;
|
int pressed = 0;
|
||||||
int screenOffset = 0;
|
int screenOffset = 0;
|
||||||
@ -282,10 +345,19 @@ string browseForFile (void) {
|
|||||||
fileSize = getFileSize(entry->name.c_str());
|
fileSize = getFileSize(entry->name.c_str());
|
||||||
printf ("%i Bytes", (int)fileSize);
|
printf ("%i Bytes", (int)fileSize);
|
||||||
}
|
}
|
||||||
printf ("\x1b[21;0H");
|
if (clipboardOn) {
|
||||||
|
printf ("\x1b[10;0H");
|
||||||
|
printf ("[CLIPBOARD]\n");
|
||||||
|
printf (clipboardFilename);
|
||||||
|
}
|
||||||
|
printf ("\x1b[19;0H");
|
||||||
printf (titleName);
|
printf (titleName);
|
||||||
|
printf ("\x1b[20;0H");
|
||||||
|
printf ("X - DELETE file");
|
||||||
|
printf ("\x1b[21;0H");
|
||||||
|
printf (clipboardOn ? "Y - PASTE file" : "Y - COPY file");
|
||||||
printf ("\x1b[22;0H");
|
printf ("\x1b[22;0H");
|
||||||
printf ("X - DELETE");
|
printf (clipboardOn ? "SELECT - Clear Clipboard" : "SELECT - Restore Clipboard");
|
||||||
printf ("\x1b[23;0H");
|
printf ("\x1b[23;0H");
|
||||||
printf ((!isDSiMode() && isRegularDS) ? POWERTEXT_DS : POWERTEXT);
|
printf ((!isDSiMode() && isRegularDS) ? POWERTEXT_DS : POWERTEXT);
|
||||||
|
|
||||||
@ -316,7 +388,8 @@ string browseForFile (void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (!(pressed & KEY_UP) && !(pressed & KEY_DOWN) && !(pressed & KEY_LEFT) && !(pressed & KEY_RIGHT)
|
} while (!(pressed & KEY_UP) && !(pressed & KEY_DOWN) && !(pressed & KEY_LEFT) && !(pressed & KEY_RIGHT)
|
||||||
&& !(pressed & KEY_A) && !(pressed & KEY_B) && !(pressed & KEY_X));
|
&& !(pressed & KEY_A) && !(pressed & KEY_B) && !(pressed & KEY_X) && !(pressed & KEY_Y)
|
||||||
|
&& !(pressed & KEY_SELECT));
|
||||||
|
|
||||||
iprintf ("\x1b[%d;0H*", fileOffset - screenOffset + ENTRIES_START_ROW);
|
iprintf ("\x1b[%d;0H*", fileOffset - screenOffset + ENTRIES_START_ROW);
|
||||||
|
|
||||||
@ -408,5 +481,25 @@ string browseForFile (void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pressed & KEY_Y) {
|
||||||
|
if (clipboardOn) {
|
||||||
|
if (fileBrowse_paste()) {
|
||||||
|
getDirectoryContents (dirContents);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
char path[PATH_MAX];
|
||||||
|
getcwd(path, PATH_MAX);
|
||||||
|
snprintf(clipboard, sizeof(clipboard), "%s%s", path, entry->name.c_str());
|
||||||
|
snprintf(clipboardFilename, sizeof(clipboardFilename), "%s", entry->name.c_str());
|
||||||
|
clipboardOn = true;
|
||||||
|
clipboardDrive = secondaryDrive;
|
||||||
|
}
|
||||||
|
clipboardUsed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((pressed & KEY_SELECT) && clipboardUsed) {
|
||||||
|
clipboardOn = !clipboardOn;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,7 +71,7 @@ int main(int argc, char **argv) {
|
|||||||
int pathLen;
|
int pathLen;
|
||||||
std::string filename;
|
std::string filename;
|
||||||
|
|
||||||
snprintf(titleName, sizeof(titleName), "GodMode9i v%i.%i.%i", 1, 0, 0);
|
snprintf(titleName, sizeof(titleName), "GodMode9i v%i.%i.%i", 1, 1, 0);
|
||||||
|
|
||||||
// initialize video mode
|
// initialize video mode
|
||||||
videoSetMode(MODE_4_2D);
|
videoSetMode(MODE_4_2D);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user