"File Systems" menu item of Fl_File_Chooser: make sure "/" is listed as one of the mounted filesystems.

One FreeBSD user reported a case where "/" does not appear in /etc/fstab, and thus
did not appear when the "File Systems" menu item of Fl_File_Chooser is run.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@12047 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2016-10-19 05:55:03 +00:00
parent 1bcb9c83bc
commit 0f0597eb58

View File

@ -634,6 +634,9 @@ Fl_File_Browser::load(const char *directory,// I - Directory to load
if (mtab != NULL)
{
// We always have the root filesystem
add("/", icon);
num_files ++;
while (fgets(line, sizeof(line), mtab) != NULL)
{
if (line[0] == '#' || line[0] == '\n')
@ -641,10 +644,9 @@ Fl_File_Browser::load(const char *directory,// I - Directory to load
if (sscanf(line, "%*s%4095s", filename) != 1)
continue;
if (strcmp("/", filename) == 0) continue; // root was added before
// 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);
add(filename, icon);