Author: spitzak
Date: 2007-11-08 10:13:07 -0800 (Thu, 08 Nov 2007)
New Revision: 5966
Log:
Removed any attempts to translate filenames.
Made the windows scandir use the same data structure as is declared in
the header file. Note that if there is a reason to add the other fields,
they should be put in the header as well.


Modified:
   trunk/src/filename_isdir.cxx
   trunk/src/win32/scandir.c

Modified: trunk/src/filename_isdir.cxx
===================================================================
--- trunk/src/filename_isdir.cxx        2007-11-08 18:11:42 UTC (rev 5965)
+++ trunk/src/filename_isdir.cxx        2007-11-08 18:13:07 UTC (rev 5966)
@@ -25,7 +25,6 @@
 
 #include <config.h>
 #include <fltk/filename.h>
-#include <fltk/utf.h>
 #include <fltk/string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -46,9 +45,6 @@
   if (last_statname && strcmp(last_statname, name)==0) return last_result;
   delete[] const_cast<char *>( last_statname ); // otherwize VC++ will scream
   last_statname = newstring(name);
-  char namebuf[PATH_MAX];
-  utf8tomb(name, strlen(name), namebuf, PATH_MAX);
-  name = namebuf;
 #if defined(_WIN32) || defined(__EMX__)
   // _WIN32 apparently thinks A: is not a directory, but A:/ is!
   char buffer[4];

Modified: trunk/src/win32/scandir.c
===================================================================
--- trunk/src/win32/scandir.c   2007-11-08 18:11:42 UTC (rev 5965)
+++ trunk/src/win32/scandir.c   2007-11-08 18:13:07 UTC (rev 5966)
@@ -26,27 +26,14 @@
 #include <string.h>
 #include <windows.h>
 #include <stdlib.h>
-#include <io.h>
-#include <stdio.h>
 #include <fltk/utf.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-struct dirent {
-  long           d_ino;                      /** Always zero. */
-  unsigned short d_reclen;           /** Always zero. */
-  unsigned short d_namlen;            /** Length of name in d_name. */
-  char         d_name[FILENAME_MAX]; /** File name. */
-};
+struct dirent { char d_name[1]; };
 
-/**
- * The scandir() function reads the directory dirname and builds an array of
- * pointers to directory entries. It returns the number of entries in the 
array.
- * A pointer to the array of directory entries is stored in the location
- * referenced by namelist.
- */
 int scandir(const char *dirname, struct dirent ***namelist,
     int (*select)(struct dirent *),
     int (*compar)(struct dirent **, struct dirent **)) {
@@ -56,9 +43,9 @@
   int nDir = 0, NDir = 0;
   struct dirent **dir = 0, *selectDir;
   unsigned long ret;
-  char findIn[MAX_PATH*4];
+  char findIn[MAX_PATH];
 
-  utf8tomb(dirname, strlen(dirname), findIn, _MAX_PATH);
+  strlcpy ( findIn, dirname, MAX_PATH );
   d = findIn+strlen(findIn);
   if (d==findIn) *d++ = '.';
   if (*(d-1)!='/' && *(d-1)!='\\') *d++ = '/';
@@ -74,7 +61,7 @@
     return nDir;
   }
   do {
-    selectDir=(struct dirent*)malloc(sizeof(struct dirent));
+    selectDir=(struct dirent*)malloc(sizeof(struct 
dirent)+strlen(find.cFileName));
     strcpy(selectDir->d_name, find.cFileName);
     if (!select || (*select)(selectDir)) {
       if (nDir==NDir) {
@@ -110,4 +97,4 @@
 
 //
 // End of "$Id: scandir.c 1339 2006-04-03 22:47:29Z spitzak $".
-//
+//
\ No newline at end of file

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to