Make sure "/" is always in the list of file systems reported by Fl_File_Chooser (Unix/Linux platform)

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@12049 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2016-10-19 08:31:48 +00:00
parent 43c98c7c90
commit ec41e1a59b

View File

@ -301,9 +301,17 @@ int Fl_X11_System_Driver::file_browser_load_filesystem(Fl_File_Browser *browser,
FILE *mtab; // /etc/mtab or /etc/mnttab file FILE *mtab; // /etc/mtab or /etc/mnttab file
char line[FL_PATH_MAX]; // Input line char line[FL_PATH_MAX]; // Input line
// Every Unix has a root filesystem '/'.
// This ensures that the user don't get an empty
// window after requesting filesystem list.
browser->add("/", icon);
num_files ++;
// //
// Open the file that contains a list of mounted filesystems... // Open the file that contains a list of mounted filesystems...
// //
// Note: this misses automounted filesystems on FreeBSD if absent from /etc/fstab
//
mtab = fopen("/etc/mnttab", "r"); // Fairly standard mtab = fopen("/etc/mnttab", "r"); // Fairly standard
if (mtab == NULL) if (mtab == NULL)
@ -321,11 +329,11 @@ int Fl_X11_System_Driver::file_browser_load_filesystem(Fl_File_Browser *browser,
continue; continue;
if (sscanf(line, "%*s%4095s", filename) != 1) if (sscanf(line, "%*s%4095s", filename) != 1)
continue; continue;
if (strcmp("/", filename) == 0)
continue; // "/" was added before
// Add a trailing slash (except for the root filesystem) // Add a trailing slash (except for the root filesystem)
if (strcmp("/", filename) != 0) {
strlcat(filename, "/", sizeof(filename)); strlcat(filename, "/", sizeof(filename));
}
// printf("Fl_File_Browser::load() - adding \"%s\" to list...\n", filename); // printf("Fl_File_Browser::load() - adding \"%s\" to list...\n", filename);
browser->add(filename, icon); browser->add(filename, icon);
@ -333,11 +341,6 @@ int Fl_X11_System_Driver::file_browser_load_filesystem(Fl_File_Browser *browser,
} }
fclose(mtab); fclose(mtab);
} else {
// Every Unix has a root filesystem '/'.
// This last stage fallback ensures that the user don't get an empty
// window after requesting filesystem list.
browser->add("/", icon);
} }
#endif // _AIX || ... #endif // _AIX || ...
return num_files; return num_files;