FLTK 1.3.2
|
00001 /* 00002 * "$Id$" 00003 * 00004 * Filename header file for the Fast Light Tool Kit (FLTK). 00005 * 00006 * Copyright 1998-2010 by Bill Spitzak and others. 00007 * 00008 * This library is free software. Distribution and use rights are outlined in 00009 * the file "COPYING" which should have been included with this file. If this 00010 * file is missing or damaged, see the license at: 00011 * 00012 * http://www.fltk.org/COPYING.php 00013 * 00014 * Please report all bugs and problems on the following page: 00015 * 00016 * http://www.fltk.org/str.php 00017 */ 00022 /* Xcode on OS X includes files by recursing down into directories. 00023 * This code catches the cycle and directly includes the required file. 00024 */ 00025 #ifdef fl_dirent_h_cyclic_include 00026 # include "/usr/include/dirent.h" 00027 #endif 00028 00029 #ifndef FL_FILENAME_H 00030 # define FL_FILENAME_H 00031 00032 # include "Fl_Export.H" 00033 00038 # define FL_PATH_MAX 2048 00054 FL_EXPORT const char *fl_filename_name(const char * filename); 00055 FL_EXPORT const char *fl_filename_ext(const char *buf); 00056 FL_EXPORT char *fl_filename_setext(char *to, int tolen, const char *ext); 00057 FL_EXPORT int fl_filename_expand(char *to, int tolen, const char *from); 00058 FL_EXPORT int fl_filename_absolute(char *to, int tolen, const char *from); 00059 FL_EXPORT int fl_filename_relative(char *to, int tolen, const char *from); 00060 FL_EXPORT int fl_filename_match(const char *name, const char *pattern); 00061 FL_EXPORT int fl_filename_isdir(const char *name); 00062 00063 # if defined(__cplusplus) && !defined(FL_DOXYGEN) 00064 /* 00065 * Under WIN32, we include filename.H from numericsort.c; this should probably change... 00066 */ 00067 00068 inline char *fl_filename_setext(char *to, const char *ext) { return fl_filename_setext(to, FL_PATH_MAX, ext); } 00069 inline int fl_filename_expand(char *to, const char *from) { return fl_filename_expand(to, FL_PATH_MAX, from); } 00070 inline int fl_filename_absolute(char *to, const char *from) { return fl_filename_absolute(to, FL_PATH_MAX, from); } 00071 FL_EXPORT int fl_filename_relative(char *to, int tolen, const char *from, const char *cwd); 00072 inline int fl_filename_relative(char *to, const char *from) { return fl_filename_relative(to, FL_PATH_MAX, from); } 00073 # endif /* __cplusplus */ 00074 00075 00076 # if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(__WATCOMC__) 00077 00078 struct dirent {char d_name[1];}; 00079 00080 # elif defined(__WATCOMC__) 00081 # include <sys/types.h> 00082 # include <direct.h> 00083 00084 # else 00085 /* 00086 * WARNING: on some systems (very few nowadays?) <dirent.h> may not exist. 00087 * The correct information is in one of these files: 00088 * 00089 * #include <sys/ndir.h> 00090 * #include <sys/dir.h> 00091 * #include <ndir.h> 00092 * 00093 * plus you must do the following #define: 00094 * 00095 * #define dirent direct 00096 * 00097 * It would be best to create a <dirent.h> file that does this... 00098 */ 00099 # include <sys/types.h> 00100 # define fl_dirent_h_cyclic_include 00101 # include <dirent.h> 00102 # undef fl_dirent_h_cyclic_include 00103 # endif 00104 00105 # if defined (__cplusplus) 00106 extern "C" { 00107 # endif /* __cplusplus */ 00108 00109 # if !defined(FL_DOXYGEN) 00110 FL_EXPORT int fl_alphasort(struct dirent **, struct dirent **); 00111 FL_EXPORT int fl_casealphasort(struct dirent **, struct dirent **); 00112 FL_EXPORT int fl_casenumericsort(struct dirent **, struct dirent **); 00113 FL_EXPORT int fl_numericsort(struct dirent **, struct dirent **); 00114 # endif 00115 00116 typedef int (Fl_File_Sort_F)(struct dirent **, struct dirent **); 00118 # if defined(__cplusplus) 00119 } 00120 00121 /* 00122 * Portable "scandir" function. Ugly but necessary... 00123 */ 00124 00125 FL_EXPORT int fl_filename_list(const char *d, struct dirent ***l, 00126 Fl_File_Sort_F *s = fl_numericsort); 00127 FL_EXPORT void fl_filename_free_list(struct dirent ***l, int n); 00128 00129 /* 00130 * Generic function to open a Uniform Resource Identifier (URI) using a 00131 * system-defined program (added in FLTK 1.1.8) 00132 */ 00133 00134 FL_EXPORT int fl_open_uri(const char *uri, char *msg = (char *)0, 00135 int msglen = 0); 00136 00137 FL_EXPORT void fl_decode_uri(char *uri); 00138 00139 # ifndef FL_DOXYGEN 00140 /* 00141 * _fl_filename_isdir_quick() is a private function that checks for a 00142 * trailing slash and assumes that the passed name is a directory if 00143 * it finds one. This function is used by Fl_File_Browser and 00144 * Fl_File_Chooser to avoid extra stat() calls, but is not supported 00145 * outside of FLTK... 00146 */ 00147 int _fl_filename_isdir_quick(const char *name); 00148 # endif 00149 00150 # endif /* __cplusplus */ 00151 00152 /* 00153 * FLTK 1.0.x compatibility definitions... 00154 */ 00155 00156 # ifdef FLTK_1_0_COMPAT 00157 # define filename_absolute fl_filename_absolute 00158 # define filename_expand fl_filename_expand 00159 # define filename_ext fl_filename_ext 00160 # define filename_isdir fl_filename_isdir 00161 # define filename_list fl_filename_list 00162 # define filename_match fl_filename_match 00163 # define filename_name fl_filename_name 00164 # define filename_relative fl_filename_relative 00165 # define filename_setext fl_filename_setext 00166 # define numericsort fl_numericsort 00167 # endif /* FLTK_1_0_COMPAT */ 00168 00169 00170 #endif /* FL_FILENAME_H */ 00171 00174 /* 00175 * End of "$Id$". 00176 */