Fix issue 477: Crash when browsing drives that have no 'parent directory' entry

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1957 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2012-05-13 14:55:33 +00:00
parent 5864569bd6
commit 7443239566
2 changed files with 10 additions and 2 deletions

View File

@ -422,6 +422,13 @@ void Read_list_of_files(T_Fileselector *list, byte selected_format)
}
}
}
if (list->Nb_files==0 && list->Nb_directories==0)
{
// This can happen on some empty network drives.
// Add a dummy entry because the fileselector doesn't
// seem to support empty list.
Add_element_to_list(list, ".",Format_filename(".",19,1),1,ICON_NONE);
}
#if defined(__MORPHOS__) || defined(__AROS__) || defined (__amigaos4__) || defined(__amigaos__)
Add_element_to_list(list, "/", Format_filename("/",19,1), 1, ICON_NONE); // on amiga systems, / means parent. And there is no ..
@ -436,7 +443,7 @@ void Read_list_of_files(T_Fileselector *list, byte selected_format)
for (item = list->First; (((item != NULL) && (bFound==false))); item = item->Next){
if (item->Type == 1){
if(strncmp(item->Full_name,"..",(sizeof(char)*2))==0) bFound=true;
if(strncmp(item->Full_name,"..",(sizeof(char)*2))==0) bFound=true;
}
}
@ -1833,7 +1840,7 @@ byte Button_Load_or_Save(byte load, T_IO_Context *context)
case SDLK_BACKSPACE : // Backspace
Reset_quicksearch();
// Si le choix ".." est bien en tête des propositions...
if (!strcmp(Filelist.First->Full_name,PARENT_DIR))
if (Filelist.Nb_elements && !strcmp(Filelist.First->Full_name,PARENT_DIR))
{
// On va dans le répertoire parent.
strcpy(Selector_filename,PARENT_DIR);

View File

@ -367,6 +367,7 @@ int Analyze_command_line(int argc, char * argv[], char *main_filename, char *mai
}
break;
default:
printf("[%s]\n", argv[index]);
// Si ce n'est pas un paramètre, c'est le nom du fichier à ouvrir
if (file_in_command_line > 1)
{