Remove compilation errors in Fl_File_Icon.cxx with MSVC compiler with new method Fl_System_Driver::file_type().
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11581 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
aafd8b6031
commit
5b44fe3bff
@ -157,6 +157,8 @@ public:
|
||||
virtual int lock() {return 1;}
|
||||
virtual void unlock() {}
|
||||
virtual void* thread_message() {return NULL;}
|
||||
// implement to support Fl_File_Icon
|
||||
virtual int file_type(const char *filename);
|
||||
};
|
||||
|
||||
#endif // FL_SYSTEM_DRIVER_H
|
||||
|
@ -58,12 +58,8 @@ struct stat { /* the FLTK source code uses part of the stat() API */
|
||||
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;
|
||||
|
@ -36,27 +36,13 @@
|
||||
#include <stdlib.h>
|
||||
#include <FL/fl_utf8.h>
|
||||
#include "flstring.h"
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <FL/Fl_System_Driver.H> // for struct stat
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_System_Driver.H>
|
||||
#include <FL/Fl_File_Icon.H>
|
||||
#include <FL/Fl_Widget.H>
|
||||
#include <FL/fl_draw.H>
|
||||
#include <FL/filename.H>
|
||||
|
||||
//
|
||||
// Define missing POSIX/XPG4 macros as needed...
|
||||
//
|
||||
|
||||
#ifndef S_ISDIR
|
||||
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
||||
# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
|
||||
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
|
||||
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
|
||||
#endif /* !S_ISDIR */
|
||||
|
||||
|
||||
//
|
||||
// Icon cache...
|
||||
//
|
||||
@ -178,39 +164,8 @@ Fl_File_Icon::find(const char *filename,// I - Name of file */
|
||||
|
||||
|
||||
// Get file information if needed...
|
||||
if (filetype == ANY)
|
||||
{
|
||||
#ifdef _MSC_VER // was: WIN32
|
||||
if (filename[strlen(filename) - 1] == '/')
|
||||
filetype = DIRECTORY;
|
||||
else if (fl_filename_isdir(filename))
|
||||
filetype = DIRECTORY;
|
||||
else
|
||||
filetype = PLAIN;
|
||||
#else
|
||||
struct stat fileinfo; // Information on file
|
||||
if (!fl_stat(filename, &fileinfo))
|
||||
{
|
||||
if (S_ISDIR(fileinfo.st_mode))
|
||||
filetype = DIRECTORY;
|
||||
# ifdef S_ISFIFO
|
||||
else if (S_ISFIFO(fileinfo.st_mode))
|
||||
filetype = FIFO;
|
||||
# endif // S_ISFIFO
|
||||
# if defined(S_ISCHR) && defined(S_ISBLK)
|
||||
else if (S_ISCHR(fileinfo.st_mode) || S_ISBLK(fileinfo.st_mode))
|
||||
filetype = DEVICE;
|
||||
# endif // S_ISCHR && S_ISBLK
|
||||
# ifdef S_ISLNK
|
||||
else if (S_ISLNK(fileinfo.st_mode))
|
||||
filetype = LINK;
|
||||
# endif // S_ISLNK
|
||||
else
|
||||
filetype = PLAIN;
|
||||
}
|
||||
else
|
||||
filetype = PLAIN;
|
||||
#endif // _MSC_VER // was: WIN32
|
||||
if (filetype == ANY) {
|
||||
filetype = Fl::system_driver()->file_type(filename);
|
||||
}
|
||||
|
||||
// Look at the base name in the filename
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include <FL/Fl_System_Driver.H>
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_File_Icon.H>
|
||||
#include <FL/fl_utf8.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@ -423,6 +424,11 @@ int Fl_System_Driver::file_browser_load_directory(const char *directory, char *f
|
||||
return filename_list(directory, pfiles, sort);
|
||||
}
|
||||
|
||||
int Fl_System_Driver::file_type(const char *filename)
|
||||
{
|
||||
return Fl_File_Icon::ANY;
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
@ -85,6 +85,7 @@ public:
|
||||
virtual int lock();
|
||||
virtual void unlock();
|
||||
virtual void* thread_message();
|
||||
virtual int file_type(const char *filename);
|
||||
};
|
||||
|
||||
#endif // FL_DARWIN_SYSTEM_DRIVER_H
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <sys/param.h>
|
||||
#include <sys/ucred.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/stat.h>
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
|
||||
|
||||
@ -229,6 +230,34 @@ void *Fl_Darwin_System_Driver::dlopen(const char *filename) {
|
||||
return ::dlopen(filename, RTLD_LAZY);
|
||||
}
|
||||
|
||||
int Fl_Darwin_System_Driver::file_type(const char *filename)
|
||||
{
|
||||
int filetype;
|
||||
struct stat fileinfo; // Information on file
|
||||
if (!stat(filename, &fileinfo))
|
||||
{
|
||||
if (S_ISDIR(fileinfo.st_mode))
|
||||
filetype = Fl_File_Icon::DIRECTORY;
|
||||
# ifdef S_ISFIFO
|
||||
else if (S_ISFIFO(fileinfo.st_mode))
|
||||
filetype = Fl_File_Icon::FIFO;
|
||||
# endif // S_ISFIFO
|
||||
# if defined(S_ISCHR) && defined(S_ISBLK)
|
||||
else if (S_ISCHR(fileinfo.st_mode) || S_ISBLK(fileinfo.st_mode))
|
||||
filetype = Fl_File_Icon::DEVICE;
|
||||
# endif // S_ISCHR && S_ISBLK
|
||||
# ifdef S_ISLNK
|
||||
else if (S_ISLNK(fileinfo.st_mode))
|
||||
filetype = Fl_File_Icon::LINK;
|
||||
# endif // S_ISLNK
|
||||
else
|
||||
filetype = Fl_File_Icon::PLAIN;
|
||||
}
|
||||
else
|
||||
filetype = Fl_File_Icon::PLAIN;
|
||||
return filetype;
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
@ -86,6 +86,7 @@ public:
|
||||
virtual int lock();
|
||||
virtual void unlock();
|
||||
virtual void* thread_message();
|
||||
virtual int file_type(const char *filename);
|
||||
};
|
||||
|
||||
#endif // FL_POSIX_SYSTEM_DRIVER_H
|
||||
|
@ -30,6 +30,7 @@
|
||||
# include <dlfcn.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <pwd.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
@ -60,6 +61,17 @@ extern "C" {
|
||||
}
|
||||
#endif // __NetBSD__
|
||||
|
||||
//
|
||||
// Define missing POSIX/XPG4 macros as needed...
|
||||
//
|
||||
#ifndef S_ISDIR
|
||||
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
||||
# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
|
||||
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
|
||||
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
|
||||
#endif /* !S_ISDIR */
|
||||
|
||||
// Pointers you can use to change FLTK to another language.
|
||||
// Note: Similar pointers are defined in FL/fl_ask.H and src/fl_ask.cxx
|
||||
const char* fl_local_alt = "Alt";
|
||||
@ -521,6 +533,34 @@ void *Fl_Posix_System_Driver::dlopen(const char *filename)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int Fl_Posix_System_Driver::file_type(const char *filename)
|
||||
{
|
||||
int filetype;
|
||||
struct stat fileinfo; // Information on file
|
||||
if (!stat(filename, &fileinfo))
|
||||
{
|
||||
if (S_ISDIR(fileinfo.st_mode))
|
||||
filetype = Fl_File_Icon::DIRECTORY;
|
||||
# ifdef S_ISFIFO
|
||||
else if (S_ISFIFO(fileinfo.st_mode))
|
||||
filetype = Fl_File_Icon::FIFO;
|
||||
# endif // S_ISFIFO
|
||||
# if defined(S_ISCHR) && defined(S_ISBLK)
|
||||
else if (S_ISCHR(fileinfo.st_mode) || S_ISBLK(fileinfo.st_mode))
|
||||
filetype = Fl_File_Icon::DEVICE;
|
||||
# endif // S_ISCHR && S_ISBLK
|
||||
# ifdef S_ISLNK
|
||||
else if (S_ISLNK(fileinfo.st_mode))
|
||||
filetype = Fl_File_Icon::LINK;
|
||||
# endif // S_ISLNK
|
||||
else
|
||||
filetype = Fl_File_Icon::PLAIN;
|
||||
}
|
||||
else
|
||||
filetype = Fl_File_Icon::PLAIN;
|
||||
return filetype;
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
@ -92,6 +92,7 @@ public:
|
||||
virtual void unlock();
|
||||
// this one is implemented in Fl_win32.cxx
|
||||
virtual void* thread_message();
|
||||
virtual int file_type(const char *filename);
|
||||
};
|
||||
|
||||
#endif // FL_WINAPI_SYSTEM_DRIVER_H
|
||||
|
@ -884,6 +884,18 @@ const char *Fl_WinAPI_System_Driver::next_dir_sep(const char *start)
|
||||
return p;
|
||||
}
|
||||
|
||||
int Fl_WinAPI_System_Driver::file_type(const char *filename)
|
||||
{
|
||||
int filetype;
|
||||
if (filename[strlen(filename) - 1] == '/')
|
||||
filetype = Fl_File_Icon::DIRECTORY;
|
||||
else if (filename_isdir(filename))
|
||||
filetype = Fl_File_Icon::DIRECTORY;
|
||||
else
|
||||
filetype = Fl_File_Icon::PLAIN;
|
||||
return filetype;
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user