diff options
| author | Michael R Sweet <michael.r.sweet@gmail.com> | 2001-12-03 18:29:49 +0000 |
|---|---|---|
| committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2001-12-03 18:29:49 +0000 |
| commit | 3a0fe7916436b5ce5f4ba252f4078dd649b67c6b (patch) | |
| tree | 564537edff2138ff6ce14864333d275ed6cbf1b1 /src/filename_isdir.cxx | |
| parent | d7f311e25cff723badae260b42a8c7575fa5661d (diff) | |
Bug fixes and doco updates care of Sebastian.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1799 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/filename_isdir.cxx')
| -rw-r--r-- | src/filename_isdir.cxx | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/src/filename_isdir.cxx b/src/filename_isdir.cxx index 1d4d4cb05..4620e29e6 100644 --- a/src/filename_isdir.cxx +++ b/src/filename_isdir.cxx @@ -1,5 +1,5 @@ // -// "$Id: filename_isdir.cxx,v 1.4.2.5 2001/01/22 15:13:40 easysw Exp $" +// "$Id: filename_isdir.cxx,v 1.4.2.5.2.1 2001/12/03 18:29:49 easysw Exp $" // // Directory detection routines for the Fast Light Tool Kit (FLTK). // @@ -25,28 +25,39 @@ // Used by fl_file_chooser -#include <config.h> -#include <FL/filename.H> +#include "flstring.h" #include <sys/stat.h> -#include <string.h> +#include <ctype.h> +#include <FL/filename.H> + int filename_isdir(const char* n) { struct stat s; + #ifdef WIN32 char fn[1024]; int length; // This workaround brought to you by the fine folks at Microsoft! // (read lots of sarcasm in that...) - strncpy(fn, n, sizeof(fn) - 1); - fn[sizeof(fn) - 1] = '\0'; - length = strlen(fn); - if (length > 0 && (fn[length - 1] == '/' || fn[length - 1] == '\\')) - fn[length - 1] = '\0'; // Strip trailing slash... - n = fn; + length = strlen(n); + if (length < (int)(sizeof(fn) - 1)) { + if (length < 4 && isletter(n[0]) && n[1] == ':') { + // Always use D:/ for drive letters + fn[0] = n[0]; + strcpy(fn + 1, ":/"); + n = fn; + } else if (length > 0 && (n[length - 1] == '/' || n[length - 1] == '\\')) { + // Strip trailing slash from name... + strncpy(fn, n, sizeof(fn) - 1); + fn[length - 1] = '\0'; + n = fn; + } + } #endif + return !stat(n, &s) && (s.st_mode&0170000)==0040000; } // -// End of "$Id: filename_isdir.cxx,v 1.4.2.5 2001/01/22 15:13:40 easysw Exp $". +// End of "$Id: filename_isdir.cxx,v 1.4.2.5.2.1 2001/12/03 18:29:49 easysw Exp $". // |
