Skip to content

Commit

Permalink
Make sure "/" is always in the list of file systems reported by Fl_Fi…
Browse files Browse the repository at this point in the history
…le_Chooser (Unix/Linux platform)

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@12049 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Manolo Gouy authored and Manolo Gouy committed Oct 19, 2016
1 parent 43c98c7 commit ec41e1a
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/drivers/X11/Fl_X11_System_Driver.cxx
Expand Up @@ -300,10 +300,18 @@ int Fl_X11_System_Driver::file_browser_load_filesystem(Fl_File_Browser *browser,
//
FILE *mtab; // /etc/mtab or /etc/mnttab file
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...
//
// Note: this misses automounted filesystems on FreeBSD if absent from /etc/fstab
//

mtab = fopen("/etc/mnttab", "r"); // Fairly standard
if (mtab == NULL)
Expand All @@ -321,23 +329,18 @@ int Fl_X11_System_Driver::file_browser_load_filesystem(Fl_File_Browser *browser,
continue;
if (sscanf(line, "%*s%4095s", filename) != 1)
continue;
if (strcmp("/", filename) == 0)
continue; // "/" 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);
browser->add(filename, icon);
num_files ++;
}

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 || ...
return num_files;
Expand Down

0 comments on commit ec41e1a

Please sign in to comment.