Get drive size from destination drive, not current (#211)

- Fixes #210
This commit is contained in:
Pk11 2023-01-12 18:31:28 -06:00 committed by GitHub
parent 24d3a0ae66
commit 2212ee5d93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 2 deletions

View File

@ -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] != ' ') {

View File

@ -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);

View File

@ -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);