Bug fix for file browser initial directory calculation.

This commit is contained in:
Matthew Budd 2020-07-11 21:29:23 -04:00
parent d43383d8bf
commit 76d8b829bd
1 changed files with 12 additions and 5 deletions

View File

@ -470,22 +470,29 @@ void consoleWin_t::closeApp(void)
//---------------------------------------------------------------------------
int consoleWin_t::getDirFromFile( const char *path, char *dir )
{
int i,j;
int i, lastSlash = -1, lastPeriod = -1;
i=0; j = -1;
i=0;
while ( path[i] != 0 )
{
if ( path[i] == '/' )
{
j = i;
lastSlash = i;
}
else if ( path[i] == '.' )
{
lastPeriod = i;
}
dir[i] = path[i]; i++;
}
dir[i] = 0;
if ( j >= 0 )
if ( lastPeriod >= 0 )
{
dir[j] = 0;
if ( lastPeriod > lastSlash )
{
dir[lastSlash] = 0;
}
}
return 0;