Skip to content
Permalink
Browse files

Reset last visited dir if failed to open during startup

  • Loading branch information...
joel16 committed Apr 1, 2019
1 parent 0824948 commit 9a7a30863567e44f38985bc7acd6b2f7c9d75d7e
Showing with 12 additions and 7 deletions.
  1. +8 −3 source/main.c
  2. +4 −4 source/menus/menu_displayfiles.c
@@ -5,6 +5,7 @@
#include <string.h>

#include "common.h"
#include "dirbrowse.h"
#include "fs.h"
#include "menu_displayfiles.h"
#include "textures.h"
@@ -25,7 +26,7 @@ static int GetLastDirectory(void) {
return ret;
}

strcpy(cwd, ROOT_PATH); // Set Start Path to "sdmc:/" if lastDir.txt hasn't been created.
strcpy(cwd, ROOT_PATH);
}
else {
SceOff size = 0;
@@ -42,8 +43,12 @@ static int GetLastDirectory(void) {
char path[513];
sscanf(buf, "%[^\n]s", path);

if (FS_DirExists(path)) // Incase a directory previously visited had been deleted, set start path to sdmc:/ to avoid errors.
strcpy(cwd, path);
if (FS_DirExists(path)) {
if (R_SUCCEEDED(Dirbrowse_PopulateFiles(SCE_FALSE)))
strcpy(cwd, path);
else
strcpy(cwd, ROOT_PATH);
}
else
strcpy(cwd, ROOT_PATH);

@@ -23,11 +23,11 @@ static void Menu_HandleControls(void) {

if (pressed & SCE_CTRL_ENTER)
Dirbrowse_OpenFile();
}

if ((strcmp(cwd, ROOT_PATH) != 0) && (pressed & SCE_CTRL_CANCEL)) {
Dirbrowse_Navigate(SCE_TRUE);
Dirbrowse_PopulateFiles(SCE_TRUE);
}
if ((strcmp(cwd, ROOT_PATH) != 0) && (pressed & SCE_CTRL_CANCEL)) {
Dirbrowse_Navigate(SCE_TRUE);
Dirbrowse_PopulateFiles(SCE_TRUE);
}
}

0 comments on commit 9a7a308

Please sign in to comment.
You can’t perform that action at this time.