diff --git a/arm9/source/driveOperations.cpp b/arm9/source/driveOperations.cpp index aa8881c..dcb9524 100644 --- a/arm9/source/driveOperations.cpp +++ b/arm9/source/driveOperations.cpp @@ -73,6 +73,27 @@ const char* getDrivePath(void) { return ""; } +Drive getDriveFromPath(const char *path) { + Drive destDrive = currentDrive; + if(strncmp(path, "sd:", 3) == 0) { + return Drive::sdCard; + } else if(strncmp(path, "fat:", 4) == 0) { + return Drive::flashcard; + } else if(strncmp(path, "ram:", 4)) { + return Drive::ramDrive; + } else if(strncmp(path, "nand:", 5)) { + return Drive::nand; + } else if(strncmp(path, "photo:", 6)) { + return Drive::nandPhoto; + } else if(strncmp(path, "nitro:", 6)) { + return Drive::nitroFS; + } else if(strncmp(path, "img:", 4)) { + return Drive::fatImg; + } + + return currentDrive; +} + void fixLabel(char* label) { for (int i = strlen(label) - 1; i >= 0; i--) { if(label[i] != ' ') { diff --git a/arm9/source/driveOperations.h b/arm9/source/driveOperations.h index c44e789..8299afd 100644 --- a/arm9/source/driveOperations.h +++ b/arm9/source/driveOperations.h @@ -39,6 +39,7 @@ extern u64 imgSize; extern u32 ramdSize; extern const char* getDrivePath(void); +extern Drive getDriveFromPath(const char *path); extern bool nandFound(void); extern bool photoFound(void); diff --git a/arm9/source/fileOperations.cpp b/arm9/source/fileOperations.cpp index b4949ab..190d9a5 100644 --- a/arm9/source/fileOperations.cpp +++ b/arm9/source/fileOperations.cpp @@ -220,7 +220,7 @@ bool fcopy(const char *sourcePath, const char *destinationPath) { getDirectoryContents(dirContents); // Check that everything will fit - if(dirSize(dirContents) > driveSizeFree(currentDrive)) { + if(dirSize(dirContents) > driveSizeFree(getDriveFromPath(destinationPath))) { font->clear(false); font->printf(0, 0, false, Alignment::left, Palette::white, (STR_FILE_TOO_BIG + "\n\n" + STR_A_OK).c_str(), sourcePath); font->update(false); @@ -258,7 +258,7 @@ bool fcopy(const char *sourcePath, const char *destinationPath) { } // Check that the file will fit - if((u64)fsize > driveSizeFree(currentDrive)) { + if((u64)fsize > driveSizeFree(getDriveFromPath(destinationPath))) { font->clear(false); font->printf(0, 0, false, Alignment::left, Palette::white, (STR_FILE_TOO_BIG + "\n\n" + STR_A_OK).c_str(), sourcePath); font->update(false);