Begin to rewrite files using #include <sys/stat.h> under the driver model.
struct stat is considered a platform-specific type. The Unix, Mac OS, and WIN32 platforms define it with #include <sys/stat.h> Other platforms may do that their own way. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11542 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
d905769e69
commit
ae0d15f1a3
@ -34,6 +34,7 @@ typedef struct CGContext* Fl_Offscreen;
|
||||
typedef struct CGImage* Fl_Bitmask;
|
||||
typedef struct flCocoaRegion* Fl_Region;
|
||||
typedef int FL_SOCKET;
|
||||
#include <sys/stat.h>
|
||||
|
||||
#elif defined(WIN32)
|
||||
typedef struct HBITMAP__ *HBITMAP;
|
||||
@ -45,6 +46,7 @@ typedef unsigned __int64 FL_SOCKET;
|
||||
# else
|
||||
typedef int FL_SOCKET;
|
||||
# endif
|
||||
#include <sys/stat.h>
|
||||
|
||||
#elif defined(FL_PORTING)
|
||||
# pragma message "FL_PORTING: define OS-dependent types"
|
||||
@ -52,12 +54,25 @@ typedef void* Fl_Offscreen;
|
||||
typedef void* Fl_Bitmask;
|
||||
typedef void *Fl_Region;
|
||||
typedef int FL_SOCKET;
|
||||
# pragma message "FL_PORTING: define struct stat and implement stat() for the platform"
|
||||
struct stat { // the FLTK source code uses part of the stat() API
|
||||
unsigned st_mode;
|
||||
off_t st_size;
|
||||
};
|
||||
#define S_IFMT 0170000 /* type of file */
|
||||
#define S_IFIFO 0010000 /* named pipe (fifo) */
|
||||
#define S_IFCHR 0020000 /* character special */
|
||||
#define S_IFDIR 0040000 /* directory */
|
||||
#define S_IFBLK 0060000 /* block special */
|
||||
#define S_IFREG 0100000 /* regular */
|
||||
#define S_IFLNK 0120000 /* symbolic link */
|
||||
|
||||
#else
|
||||
typedef unsigned long Fl_Offscreen;
|
||||
typedef unsigned long Fl_Bitmask;
|
||||
typedef struct _XRegion *Fl_Region;
|
||||
typedef int FL_SOCKET;
|
||||
#include <sys/stat.h>
|
||||
|
||||
#endif // __APPLE__
|
||||
|
||||
|
@ -344,6 +344,7 @@
|
||||
//
|
||||
|
||||
#include <FL/Fl_File_Chooser.H>
|
||||
#include <FL/Fl_System_Driver.H> // for struct stat
|
||||
#include <FL/filename.H>
|
||||
#include <FL/fl_ask.H>
|
||||
#include <FL/x.H>
|
||||
@ -355,7 +356,6 @@
|
||||
#include "flstring.h"
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if defined(WIN32) || defined(__APPLE__) // PORTME: Fl_Screen_Driver - platform file browser
|
||||
#elif defined(FL_PORTING)
|
||||
|
@ -38,25 +38,12 @@
|
||||
#include "flstring.h"
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#if (defined(WIN32) && ! defined(__CYGWIN__)) || defined(__EMX__)
|
||||
# include <io.h>
|
||||
# define F_OK 0
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif /* WIN32 || __EMX__ */
|
||||
|
||||
#include <FL/Fl_System_Driver.H> // for struct stat
|
||||
#include <FL/Fl_File_Icon.H>
|
||||
#include <FL/Fl_Widget.H>
|
||||
#include <FL/fl_draw.H>
|
||||
#include <FL/filename.H>
|
||||
|
||||
#if defined(WIN32) || defined(__APPLE__) // PORTME: Fl_Screen_Driver - platform file browser
|
||||
#elif defined(FL_PORTING)
|
||||
# pragma message "FL_PORTING: implement file type interpretation here"
|
||||
#else
|
||||
#endif
|
||||
|
||||
//
|
||||
// Define missing POSIX/XPG4 macros as needed...
|
||||
//
|
||||
@ -187,23 +174,13 @@ Fl_File_Icon::find(const char *filename,// I - Name of file */
|
||||
int filetype) // I - Enumerated file type
|
||||
{
|
||||
Fl_File_Icon *current; // Current file in list
|
||||
#ifndef WIN32
|
||||
struct stat fileinfo; // Information on file
|
||||
#endif // !WIN32
|
||||
const char *name; // Base name of filename
|
||||
|
||||
|
||||
// Get file information if needed...
|
||||
if (filetype == ANY)
|
||||
{
|
||||
#ifdef WIN32
|
||||
if (filename[strlen(filename) - 1] == '/')
|
||||
filetype = DIRECTORY;
|
||||
else if (fl_filename_isdir(filename))
|
||||
filetype = DIRECTORY;
|
||||
else
|
||||
filetype = PLAIN;
|
||||
#else
|
||||
if (!fl_stat(filename, &fileinfo))
|
||||
{
|
||||
if (S_ISDIR(fileinfo.st_mode))
|
||||
@ -225,7 +202,6 @@ Fl_File_Icon::find(const char *filename,// I - Name of file */
|
||||
}
|
||||
else
|
||||
filetype = PLAIN;
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
// Look at the base name in the filename
|
||||
|
@ -196,6 +196,7 @@ int Fl_WinAPI_System_Driver::access(const char* f, int mode) {
|
||||
|
||||
int Fl_WinAPI_System_Driver::stat(const char* f, struct stat *b) {
|
||||
size_t l = strlen(f);
|
||||
if (f[l-1] == '/') l--; // must remove trailing /
|
||||
unsigned wn = fl_utf8toUtf16(f, (unsigned) l, NULL, 0) + 1; // Query length
|
||||
wbuf = (wchar_t*)realloc(wbuf, sizeof(wchar_t)*wn);
|
||||
wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string
|
||||
|
@ -20,18 +20,11 @@
|
||||
|
||||
#include "flstring.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <FL/Fl_System_Driver.H> // for struct stat
|
||||
#include <ctype.h>
|
||||
#include <FL/filename.H>
|
||||
#include <FL/fl_utf8.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#elif defined(__APPLE__) // PORTME: Fl_System_Driver - directory stuff
|
||||
#elif defined(FL_PORTING)
|
||||
# pragma message "FL_PORTING: implement directory and filename handling for your platform if needed"
|
||||
#else // X11
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) || defined(__EMX__) && !defined(__CYGWIN__)
|
||||
static inline int isdirsep(char c) {return c=='/' || c=='\\';}
|
||||
#else
|
||||
@ -92,7 +85,7 @@ int fl_filename_isdir(const char* n) {
|
||||
}
|
||||
#endif
|
||||
|
||||
return !fl_stat(n, &s) && (s.st_mode&0170000)==0040000;
|
||||
return !fl_stat(n, &s) && (s.st_mode & S_IFMT) == S_IFDIR;
|
||||
}
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user