Skip to content

Commit

Permalink
Root (#39)
Browse files Browse the repository at this point in the history
* Handle move to root directory

* Explicit root

* Handle root to root

---------

Co-authored-by: ikjordan <[email protected]>
  • Loading branch information
ikjordan and ikjordan authored Jan 16, 2025
1 parent c452bd7 commit 2d374c2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
36 changes: 24 additions & 12 deletions src/emuapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,26 +475,38 @@ static bool setDirectory(const char* dir)
{
bool retVal = false;

if (dir!=NULL && dir[0])
if (dir!=NULL)
{
if (dir[strlen(dir) - 1] != '/')
if (dir[0])
{
if (strncasecmp(dirPath, dir, strlen(dir) - 1) ||
(strlen(dir) != (strlen(dirPath) - 1)))
if (dir[strlen(dir) - 1] != '/')
{
strncpy(dirPath, dir, MAX_DIRECTORY_LEN-2);
dirPath[MAX_DIRECTORY_LEN-2] = 0;
strcat(dirPath, "/");
retVal = true;
if (strncasecmp(dirPath, dir, strlen(dir) - 1) ||
(strlen(dir) != (strlen(dirPath) - 1)))
{
strncpy(dirPath, dir, MAX_DIRECTORY_LEN-2);
dirPath[MAX_DIRECTORY_LEN-2] = 0;
strcat(dirPath, "/");
retVal = true;
}
}
else
{
if (strncasecmp(dirPath, dir, strlen(dir)) ||
(strlen(dir) != strlen(dirPath)))
{
strncpy(dirPath, dir, MAX_DIRECTORY_LEN-1);
dirPath[MAX_DIRECTORY_LEN-1] = 0;
retVal = true;
}
}
}
else
{
if (strncasecmp(dirPath, dir, strlen(dir)) ||
(strlen(dir) != strlen(dirPath)))
if (dirPath[0])
{
strncpy(dirPath, dir, MAX_DIRECTORY_LEN-1);
dirPath[MAX_DIRECTORY_LEN-1] = 0;
// Moving to root directory
dirPath[0] = 0;
retVal = true;
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,14 @@ bool statusMenu(void)
}

writeString("Directory:", lhs, ++lcount);
writeString(emu_GetDirectory(), rhs, lcount++);
if (!emu_GetDirectory()[0])
{
writeString("<ROOT>", rhs, lcount++);
}
else
{
writeString(emu_GetDirectory(), rhs, lcount++);
}

#ifdef NINEPIN_JOYSTICK
writeString("Nine Pin JS:", lhs, lcount);
Expand Down

0 comments on commit 2d374c2

Please sign in to comment.