FLTK 1.3.0
filename.H
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  */
00018 
00019 /* Xcode on OS X includes files by recursing down into directories.
00020  * This code catches the cycle and directly includes the required file.
00021  */
00022 #ifdef fl_dirent_h_cyclic_include
00023 #  include "/usr/include/dirent.h"
00024 #endif
00025 
00026 #ifndef FL_FILENAME_H
00027 #  define FL_FILENAME_H
00028 
00029 #  include "Fl_Export.H"
00030 
00035 #  define FL_PATH_MAX 2048 
00051 FL_EXPORT const char *fl_filename_name(const char * filename);
00052 FL_EXPORT const char *fl_filename_ext(const char *buf);
00053 FL_EXPORT char *fl_filename_setext(char *to, int tolen, const char *ext);
00054 FL_EXPORT int fl_filename_expand(char *to, int tolen, const char *from);
00055 FL_EXPORT int fl_filename_absolute(char *to, int tolen, const char *from);
00056 FL_EXPORT int fl_filename_relative(char *to, int tolen, const char *from);
00057 FL_EXPORT int fl_filename_match(const char *name, const char *pattern);
00058 FL_EXPORT int fl_filename_isdir(const char *name);
00059 
00060 #  if defined(__cplusplus) && !defined(FL_DOXYGEN)
00061 /*
00062  * Under WIN32, we include filename.H from numericsort.c; this should probably change...
00063  */
00064 
00065 inline char *fl_filename_setext(char *to, const char *ext) { return fl_filename_setext(to, FL_PATH_MAX, ext); }
00066 inline int fl_filename_expand(char *to, const char *from) { return fl_filename_expand(to, FL_PATH_MAX, from); }
00067 inline int fl_filename_absolute(char *to, const char *from) { return fl_filename_absolute(to, FL_PATH_MAX, from); }
00068 FL_EXPORT int fl_filename_relative(char *to, int tolen, const char *from, const char *cwd);
00069 inline int fl_filename_relative(char *to, const char *from) { return fl_filename_relative(to, FL_PATH_MAX, from); }
00070 #  endif /* __cplusplus */
00071 
00072 
00073 #  if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
00074 
00075 struct dirent {char d_name[1];};
00076 
00077 #  elif defined(__WATCOMC__)
00078 #    include <sys/types.h>
00079 #    include <direct.h>
00080 
00081 #  else
00082 /*
00083  * WARNING: on some systems (very few nowadays?) <dirent.h> may not exist.
00084  * The correct information is in one of these files:
00085  *
00086  *     #include <sys/ndir.h>
00087  *     #include <sys/dir.h>
00088  *     #include <ndir.h>
00089  *
00090  * plus you must do the following #define:
00091  *
00092  *     #define dirent direct
00093  *
00094  * It would be best to create a <dirent.h> file that does this...
00095  */
00096 #    include <sys/types.h>
00097 #    define fl_dirent_h_cyclic_include
00098 #    include <dirent.h>
00099 #    undef fl_dirent_h_cyclic_include
00100 #  endif
00101 
00102 #  if defined (__cplusplus)
00103 extern "C" {
00104 #  endif /* __cplusplus */
00105 
00106 #  if !defined(FL_DOXYGEN)
00107 FL_EXPORT int fl_alphasort(struct dirent **, struct dirent **);
00108 FL_EXPORT int fl_casealphasort(struct dirent **, struct dirent **);
00109 FL_EXPORT int fl_casenumericsort(struct dirent **, struct dirent **);
00110 FL_EXPORT int fl_numericsort(struct dirent **, struct dirent **);
00111 #  endif
00112 
00113   typedef int (Fl_File_Sort_F)(struct dirent **, struct dirent **); 
00115 #  if defined(__cplusplus)
00116 }
00117 
00118 /*
00119  * Portable "scandir" function.  Ugly but necessary...
00120  */
00121 
00122 FL_EXPORT int fl_filename_list(const char *d, struct dirent ***l,
00123                                Fl_File_Sort_F *s = fl_numericsort);
00124 FL_EXPORT void fl_filename_free_list(struct dirent ***l, int n);
00125 
00126 /*
00127  * Generic function to open a Uniform Resource Identifier (URI) using a
00128  * system-defined program (added in FLTK 1.1.8)
00129  */
00130 
00131 FL_EXPORT int   fl_open_uri(const char *uri, char *msg = (char *)0,
00132                             int msglen = 0);
00133 
00134 FL_EXPORT void fl_decode_uri(char *uri);
00135 
00136 #    ifndef FL_DOXYGEN
00137 /*
00138  * _fl_filename_isdir_quick() is a private function that checks for a
00139  * trailing slash and assumes that the passed name is a directory if
00140  * it finds one.  This function is used by Fl_File_Browser and
00141  * Fl_File_Chooser to avoid extra stat() calls, but is not supported
00142  * outside of FLTK...
00143  */
00144 int _fl_filename_isdir_quick(const char *name);
00145 #    endif
00146 
00147 #  endif /* __cplusplus */
00148 
00149 /*
00150  * FLTK 1.0.x compatibility definitions...
00151  */
00152 
00153 #  ifdef FLTK_1_0_COMPAT
00154 #    define filename_absolute   fl_filename_absolute
00155 #    define filename_expand     fl_filename_expand
00156 #    define filename_ext        fl_filename_ext
00157 #    define filename_isdir      fl_filename_isdir
00158 #    define filename_list       fl_filename_list
00159 #    define filename_match      fl_filename_match
00160 #    define filename_name       fl_filename_name
00161 #    define filename_relative   fl_filename_relative
00162 #    define filename_setext     fl_filename_setext
00163 #    define numericsort         fl_numericsort
00164 #  endif /* FLTK_1_0_COMPAT */
00165 
00166 
00167 #endif /* FL_FILENAME_H */
00168 
00171 /*
00172  * End of "$Id$".
00173  */