summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2000-06-06 15:25:20 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2000-06-06 15:25:20 +0000
commitf4fff52828dd43677b2795c1b0c1d4ee52c0e527 (patch)
tree92b2ec808b3836a8d2a1e930b87182de37ce0860
parentec770b7f4a0f21199594e794366cd19b093cc79b (diff)
Fix for filename_isdir() under Winbloze. Strip trailing backslash for
stat() call (don't we need the trailing slash for filename_list()???) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1174 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--src/filename_isdir.cxx20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/filename_isdir.cxx b/src/filename_isdir.cxx
index ba671c95b..302b17678 100644
--- a/src/filename_isdir.cxx
+++ b/src/filename_isdir.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: filename_isdir.cxx,v 1.4.2.2 2000/06/05 21:21:04 mike Exp $"
+// "$Id: filename_isdir.cxx,v 1.4.2.3 2000/06/06 15:25:20 mike Exp $"
//
// Directory detection routines for the Fast Light Tool Kit (FLTK).
//
@@ -28,12 +28,24 @@
#include <config.h>
#include <FL/filename.H>
#include <sys/stat.h>
+#include <string.h>
int filename_isdir(const char* n) {
- struct stat s;
- return !stat(n, &s) && (s.st_mode&0170000)==0040000;
+ char fn[1024];
+ int length;
+ struct stat s;
+
+ // 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...
+
+ return !stat(fn, &s) && (s.st_mode&0170000)==0040000;
}
//
-// End of "$Id: filename_isdir.cxx,v 1.4.2.2 2000/06/05 21:21:04 mike Exp $".
+// End of "$Id: filename_isdir.cxx,v 1.4.2.3 2000/06/06 15:25:20 mike Exp $".
//