Skip to content

Commit

Permalink
Don't try to change attributes on read-only drives (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
Epicpkmn11 authored Aug 24, 2022
1 parent 5a8f3df commit 8f1eaf9
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions arm9/source/fileOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ void changeFileAttribs(const DirEntry *entry) {
font->printf(firstCol, cursorScreenPos + 5, false, alignStart, Palette::white, "[%c]%-13s[%c]%s", (newAttribs & ATTR_READONLY) ? 'X' : ' ', STR_UP_READONLY.c_str(), (newAttribs & ATTR_HIDDEN) ? 'X' : ' ', STR_LEFT_HIDDEN.c_str());
font->printf(firstCol, cursorScreenPos + 6, false, alignStart, Palette::white, "[%c]%-13s[%c]%s", (newAttribs & ATTR_SYSTEM) ? 'X' : ' ', STR_DOWN_SYSTEM.c_str(), (newAttribs & ATTR_ARCHIVE) ? 'X' : ' ', STR_RIGHT_ARCHIVE.c_str());
font->printf(firstCol, cursorScreenPos + 7, false, alignStart, Palette::white, "[%c] %s", (newAttribs & ATTR_VOLUME) ? 'X' : ' ', STR_VIRTUAL.c_str());
font->printf(firstCol, cursorScreenPos + 8, false, alignStart, Palette::white, STR_UDLR_CHANGE_ATTRIBUTES.c_str());
if(driveWritable(currentDrive))
font->printf(firstCol, cursorScreenPos + 8, false, alignStart, Palette::white, STR_UDLR_CHANGE_ATTRIBUTES.c_str());
font->print(firstCol, cursorScreenPos + 10, false, (currentAttribs == newAttribs) ? STR_A_CONTINUE : STR_A_APPLY_B_CANCEL, alignStart);
font->update(false);

Expand All @@ -358,18 +359,22 @@ void changeFileAttribs(const DirEntry *entry) {
} while (!(pressed & KEY_UP) && !(pressed & KEY_DOWN) && !(pressed & KEY_RIGHT) && !(pressed & KEY_LEFT)
&& !(pressed & KEY_A) && !(pressed & KEY_B));

if (pressed & KEY_UP) {
newAttribs ^= ATTR_READONLY;
} else if (pressed & KEY_DOWN) {
newAttribs ^= ATTR_SYSTEM;
} else if (pressed & KEY_RIGHT) {
newAttribs ^= ATTR_ARCHIVE;
} else if (pressed & KEY_LEFT) {
newAttribs ^= ATTR_HIDDEN;
} else if ((pressed & KEY_A) && (currentAttribs != newAttribs)) {
FAT_setAttr(entry->name.c_str(), newAttribs);
break;
} else if (pressed & (KEY_A | KEY_B)) {
if(driveWritable(currentDrive)) {
if (pressed & KEY_UP) {
newAttribs ^= ATTR_READONLY;
} else if (pressed & KEY_DOWN) {
newAttribs ^= ATTR_SYSTEM;
} else if (pressed & KEY_RIGHT) {
newAttribs ^= ATTR_ARCHIVE;
} else if (pressed & KEY_LEFT) {
newAttribs ^= ATTR_HIDDEN;
} else if ((pressed & KEY_A) && (currentAttribs != newAttribs)) {
FAT_setAttr(entry->name.c_str(), newAttribs);
break;
}
}

if (pressed & (KEY_A | KEY_B)) {
break;
} else if (held & KEY_R && pressed & KEY_L) {
screenshot();
Expand Down

0 comments on commit 8f1eaf9

Please sign in to comment.