diff options
| author | Michael R Sweet <michael.r.sweet@gmail.com> | 2005-08-18 14:08:17 +0000 |
|---|---|---|
| committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2005-08-18 14:08:17 +0000 |
| commit | c1ba87140e22e9e7b46fe90c0f98e38b7c8a94ca (patch) | |
| tree | 19081ab89fb59d334623c584c872e99ddb4be57c /src/filename_list.cxx | |
| parent | eca40efb6e42b352ca77d1d290b4149037b70efd (diff) | |
Fix new trailing slash usage, and restore correct OSX filesystem listing
(added filter to hide /dev and /.vol)
src/Fl_File_Browser.cxx:
- Fl_File_Browser::load(): use getfsstat() API on OSX, and don't
bother adding a trailing slash to directories since we already
have them!
src/filename_list.cxx:
- fl_filename_list(): Add 3 bytes (two possible slashes + nul byte)
to temporary buffer, and document why we are using memcpy() instead
of strcpy().
src/filename_isdir.cxx:
- fl_filename_isdir(): Add check for trailing directory separator
before wasting time doing a stat() call.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4526 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/filename_list.cxx')
| -rw-r--r-- | src/filename_list.cxx | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/filename_list.cxx b/src/filename_list.cxx index 71335757b..b2b3858c7 100644 --- a/src/filename_list.cxx +++ b/src/filename_list.cxx @@ -79,7 +79,8 @@ int fl_filename_list(const char *d, dirent ***list, #else // append a '/' to all filenames that are directories int i, dirlen = strlen(d); - char *fullname = (char*)malloc(dirlen+FL_PATH_MAX+2); + char *fullname = (char*)malloc(dirlen+FL_PATH_MAX+3); // Add enough extra for two /'s and a nul + // Use memcpy for speed since we already know the length of the string... memcpy(fullname, d, dirlen+1); char *name = fullname + dirlen; if (name!=fullname && name[-1]!='/') *name++ = '/'; @@ -87,6 +88,7 @@ int fl_filename_list(const char *d, dirent ***list, dirent *de = (*list)[i]; int len = strlen(de->d_name); if (de->d_name[len-1]=='/' || len>FL_PATH_MAX) continue; + // Use memcpy for speed since we already know the length of the string... memcpy(name, de->d_name, len+1); if (fl_filename_isdir(fullname)) { if (len<FL_PATH_MAX) { |
