Show ".." on drive root

This commit is contained in:
RocketRobz 2018-10-15 23:56:37 -06:00
parent 5693e1e7b0
commit 325538c29b
2 changed files with 29 additions and 18 deletions

View File

@ -72,6 +72,7 @@ bool dirEntryPredicate (const DirEntry& lhs, const DirEntry& rhs) {
} }
void getDirectoryContents (vector<DirEntry>& dirContents) { void getDirectoryContents (vector<DirEntry>& dirContents) {
bool twoDotsMade = false;
struct stat st; struct stat st;
dirContents.clear(); dirContents.clear();
@ -89,6 +90,15 @@ void getDirectoryContents (vector<DirEntry>& dirContents) {
if(pent == NULL) break; if(pent == NULL) break;
stat(pent->d_name, &st); stat(pent->d_name, &st);
if (!twoDotsMade) {
if (strcmp(pent->d_name, "..") != 0) {
dirEntry.name = "..";
dirEntry.isDirectory = true;
dirEntry.isApp = false;
dirContents.push_back (dirEntry); // List ".."
}
twoDotsMade = true;
} else if (strcmp(pent->d_name, "..") != 0) {
dirEntry.name = pent->d_name; dirEntry.name = pent->d_name;
dirEntry.isDirectory = (st.st_mode & S_IFDIR) ? true : false; dirEntry.isDirectory = (st.st_mode & S_IFDIR) ? true : false;
if((dirEntry.name.substr(dirEntry.name.find_last_of(".") + 1) == "nds") if((dirEntry.name.substr(dirEntry.name.find_last_of(".") + 1) == "nds")
@ -106,6 +116,7 @@ void getDirectoryContents (vector<DirEntry>& dirContents) {
if (dirEntry.name.compare(".") != 0 && (dirEntry.isDirectory || nameEndsWith(dirEntry.name))) { if (dirEntry.name.compare(".") != 0 && (dirEntry.isDirectory || nameEndsWith(dirEntry.name))) {
dirContents.push_back (dirEntry); dirContents.push_back (dirEntry);
} }
}
} }

View File

@ -75,7 +75,7 @@ int main(int argc, char **argv) {
bool yHeld = false; bool yHeld = false;
snprintf(titleName, sizeof(titleName), "GodMode9i v%i.%i.%i", 1, 2, 1); snprintf(titleName, sizeof(titleName), "GodMode9i v%i.%i.%i", 1, 3, 0);
// initialize video mode // initialize video mode
videoSetMode(MODE_4_2D); videoSetMode(MODE_4_2D);