Skip to content

Commit

Permalink
added check for root to exit surf (#2542)
Browse files Browse the repository at this point in the history
  • Loading branch information
LettucePie committed Apr 28, 2024
1 parent 8c769f8 commit 8667bad
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/studio/fs.c
Expand Up @@ -112,11 +112,17 @@ static bool isRoot(tic_fs* fs)
return fs->work[0] == '\0';
}

bool tic_fs_isroot(tic_fs* fs)
{
return isRoot(fs);
}

static bool isPublicRoot(tic_fs* fs)
{
return strcmp(fs->work, PublicDir) == 0;
}


static bool isPublic(tic_fs* fs)
{
return memcmp(fs->work, PublicDir, STRLEN(PublicDir)) == 0;
Expand Down
1 change: 1 addition & 0 deletions src/studio/fs.h
Expand Up @@ -50,6 +50,7 @@ bool tic_fs_makedir (tic_fs* fs, const char* name);
bool tic_fs_exists (tic_fs* fs, const char* name);
void tic_fs_openfolder (tic_fs* fs);
bool tic_fs_isdir (tic_fs* fs, const char* dir);
bool tic_fs_isroot (tic_fs* fs);
bool tic_fs_ispubdir (tic_fs* fs);
void tic_fs_changedir (tic_fs* fs, const char* dir);
void tic_fs_dir (tic_fs* fs, char* out);
Expand Down
3 changes: 2 additions & 1 deletion src/studio/screens/surf.c
Expand Up @@ -693,7 +693,8 @@ static void processGamepad(Surf* surf)
if(tic_api_btnp(tic, B, -1, -1)
|| tic_api_keyp(tic, tic_key_backspace, -1, -1))
{
goBackDir(surf);
if(tic_fs_isroot(surf->fs)) setStudioMode(surf->studio, TIC_CONSOLE_MODE);
else goBackDir(surf);
}

#ifdef CAN_OPEN_URL
Expand Down

0 comments on commit 8667bad

Please sign in to comment.