FLTK 1.3.0
|
00001 /* 00002 * "$Id: filename.H 8073 2010-12-20 13:35:43Z ianmacarthur $" 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; you can redistribute it and/or 00009 * modify it under the terms of the GNU Library General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2 of the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Library General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Library General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00021 * USA. 00022 * 00023 * Please report all bugs and problems on the following page: 00024 * 00025 * http://www.fltk.org/str.php 00026 */ 00027 00028 /* Xcode on OS X includes files by recursing down into directories. 00029 * This code catches the cycle and directly includes the required file. 00030 */ 00031 #ifdef fl_dirent_h_cyclic_include 00032 # include "/usr/include/dirent.h" 00033 #endif 00034 00035 #ifndef FL_FILENAME_H 00036 # define FL_FILENAME_H 00037 00038 # include "Fl_Export.H" 00039 00044 # define FL_PATH_MAX 2048 00060 FL_EXPORT const char *fl_filename_name(const char * filename); 00061 FL_EXPORT const char *fl_filename_ext(const char *buf); 00062 FL_EXPORT char *fl_filename_setext(char *to, int tolen, const char *ext); 00063 FL_EXPORT int fl_filename_expand(char *to, int tolen, const char *from); 00064 FL_EXPORT int fl_filename_absolute(char *to, int tolen, const char *from); 00065 FL_EXPORT int fl_filename_relative(char *to, int tolen, const char *from); 00066 FL_EXPORT int fl_filename_match(const char *name, const char *pattern); 00067 FL_EXPORT int fl_filename_isdir(const char *name); 00068 00069 # if defined(__cplusplus) && !defined(FL_DOXYGEN) 00070 /* 00071 * Under WIN32, we include filename.H from numericsort.c; this should probably change... 00072 */ 00073 00074 inline char *fl_filename_setext(char *to, const char *ext) { return fl_filename_setext(to, FL_PATH_MAX, ext); } 00075 inline int fl_filename_expand(char *to, const char *from) { return fl_filename_expand(to, FL_PATH_MAX, from); } 00076 inline int fl_filename_absolute(char *to, const char *from) { return fl_filename_absolute(to, FL_PATH_MAX, from); } 00077 FL_EXPORT int fl_filename_relative(char *to, int tolen, const char *from, const char *cwd); 00078 inline int fl_filename_relative(char *to, const char *from) { return fl_filename_relative(to, FL_PATH_MAX, from); } 00079 # endif /* __cplusplus */ 00080 00081 00082 # if defined(WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__) 00083 00084 struct dirent {char d_name[1];}; 00085 00086 # elif defined(__WATCOMC__) 00087 # include <sys/types.h> 00088 # include <direct.h> 00089 00090 # else 00091 /* 00092 * WARNING: on some systems (very few nowadays?) <dirent.h> may not exist. 00093 * The correct information is in one of these files: 00094 * 00095 * #include <sys/ndir.h> 00096 * #include <sys/dir.h> 00097 * #include <ndir.h> 00098 * 00099 * plus you must do the following #define: 00100 * 00101 * #define dirent direct 00102 * 00103 * It would be best to create a <dirent.h> file that does this... 00104 */ 00105 # include <sys/types.h> 00106 # define fl_dirent_h_cyclic_include 00107 # include <dirent.h> 00108 # undef fl_dirent_h_cyclic_include 00109 # endif 00110 00111 # if defined (__cplusplus) 00112 extern "C" { 00113 # endif /* __cplusplus */ 00114 00115 # if !defined(FL_DOXYGEN) 00116 FL_EXPORT int fl_alphasort(struct dirent **, struct dirent **); 00117 FL_EXPORT int fl_casealphasort(struct dirent **, struct dirent **); 00118 FL_EXPORT int fl_casenumericsort(struct dirent **, struct dirent **); 00119 FL_EXPORT int fl_numericsort(struct dirent **, struct dirent **); 00120 # endif 00121 00122 typedef int (Fl_File_Sort_F)(struct dirent **, struct dirent **); 00124 # if defined(__cplusplus) 00125 } 00126 00127 /* 00128 * Portable "scandir" function. Ugly but necessary... 00129 */ 00130 00131 FL_EXPORT int fl_filename_list(const char *d, struct dirent ***l, 00132 Fl_File_Sort_F *s = fl_numericsort); 00133 FL_EXPORT void fl_filename_free_list(struct dirent ***l, int n); 00134 00135 /* 00136 * Generic function to open a Uniform Resource Identifier (URI) using a 00137 * system-defined program (added in FLTK 1.1.8) 00138 */ 00139 00140 FL_EXPORT int fl_open_uri(const char *uri, char *msg = (char *)0, 00141 int msglen = 0); 00142 00143 # ifndef FL_DOXYGEN 00144 /* 00145 * _fl_filename_isdir_quick() is a private function that checks for a 00146 * trailing slash and assumes that the passed name is a directory if 00147 * it finds one. This function is used by Fl_File_Browser and 00148 * Fl_File_Chooser to avoid extra stat() calls, but is not supported 00149 * outside of FLTK... 00150 */ 00151 int _fl_filename_isdir_quick(const char *name); 00152 # endif 00153 00154 # endif /* __cplusplus */ 00155 00156 /* 00157 * FLTK 1.0.x compatibility definitions... 00158 */ 00159 00160 # ifdef FLTK_1_0_COMPAT 00161 # define filename_absolute fl_filename_absolute 00162 # define filename_expand fl_filename_expand 00163 # define filename_ext fl_filename_ext 00164 # define filename_isdir fl_filename_isdir 00165 # define filename_list fl_filename_list 00166 # define filename_match fl_filename_match 00167 # define filename_name fl_filename_name 00168 # define filename_relative fl_filename_relative 00169 # define filename_setext fl_filename_setext 00170 # define numericsort fl_numericsort 00171 # endif /* FLTK_1_0_COMPAT */ 00172 00173 00174 #endif /* FL_FILENAME_H */ 00175 00178 /* 00179 * End of "$Id: filename.H 8073 2010-12-20 13:35:43Z ianmacarthur $". 00180 */