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:
parent
43c98c7c90
commit
ec41e1a59b
@ -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)
|
||||
@ -321,11 +329,11 @@ 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);
|
||||
@ -333,11 +341,6 @@ int Fl_X11_System_Driver::file_browser_load_filesystem(Fl_File_Browser *browser,
|
||||
}
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user