00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _FL_FILENAME_H_
00023 #define _FL_FILENAME_H_
00024
00025 #include "Enumerations.h"
00026 #include "Fl_Util.h"
00027
00028 #define FL_PATH_MAX 1024 // all buffers are assummed to be at least this long
00029
00030 #if defined(_WIN32) && !defined(__CYGWIN__)
00031
00032 # define DT_REG 0 //Regular
00033 # define DT_DIR 1 //Directory
00034 struct dirent { uchar d_type; char d_name[1]; };
00035
00036 #elif defined(__linux__)
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #include <features.h>
00047 #include <sys/types.h>
00048
00049 #include <dirent.h>
00050
00051
00052
00053 #else
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 #include <sys/types.h>
00064 #include <dirent.h>
00065
00066 #endif
00067
00068
00069 typedef int (Fl_File_Sort_F)(struct dirent **, struct dirent **);
00070
00071 extern FL_API int fl_alphasort(struct dirent **, struct dirent **);
00072 extern FL_API int fl_casealphasort(struct dirent **, struct dirent **);
00073
00074
00075 extern FL_API int fl_filename_list(const char *dir, struct dirent ***list, Fl_File_Sort_F *sort = fl_alphasort);
00076
00077
00078
00079 extern FL_API const char *fl_file_getext(const char *filename);
00080
00081 extern FL_API Fl_String fl_file_getext(const Fl_String &filename);
00082
00083
00084 extern FL_API char *fl_file_setext(char *filename, const char *ext);
00085
00086 extern FL_API Fl_String fl_file_setext(const Fl_String &, const char *ext);
00087
00088
00089 extern FL_API const char *fl_file_filename(const char *filename);
00090
00091 extern FL_API Fl_String fl_file_filename(const Fl_String &);
00092
00093
00094 extern FL_API bool fl_file_expand(char *buf, int buf_len, const char *from);
00095
00096 extern FL_API Fl_String fl_file_expand(const Fl_String &from);
00097
00098
00099 extern FL_API bool fl_file_absolute(char *buf, int buf_len, const char *from);
00100
00101 extern FL_API Fl_String fl_file_absolute(const Fl_String &from);
00102
00103
00104 extern FL_API bool fl_file_match(const char *, const char *pattern);
00105
00106
00107 extern FL_API char *fl_get_homedir();
00108 extern FL_API const Fl_String &fl_homedir();
00109
00110
00111 extern FL_API bool fl_file_exists(const char *name);
00112
00113
00114 extern FL_API bool fl_is_dir(const char *path);
00115
00116 class FL_API Fl_File_Attr
00117 {
00118 public:
00119 Fl_File_Attr() { size=0; flags=0; }
00120
00121 enum {
00122 DIR = 1,
00123 FILE = 2,
00124 LINK = 4,
00125 DEVICE = 8
00126 };
00127 bool parse(const char *filename);
00128
00129 ulong size;
00130 ulong modified;
00131 char time[128];
00132 Fl_Flags flags;
00133
00134 #ifdef _WIN32
00135 uint64 free;
00136 uint64 capacity;
00137 #endif
00138 };
00139
00140
00141 typedef Fl_File_Attr Fl_FileAttr;
00142
00143 extern FL_API Fl_File_Attr *fl_file_attr(const char *name);
00144
00145
00146 inline bool fl_file_absolute(char *buf, const char *from) { return fl_file_absolute(buf, FL_PATH_MAX, from); }
00147
00148 #define FL_DIR Fl_File_Attr::DIR
00149 #define FL_FILE Fl_File_Attr::FILE
00150 #define FL_LINK Fl_File_Attr::LINK
00151 #define FL_DEVICE Fl_File_Attr::DEVICE
00152
00153 #endif