FLTK
filename.H
Go to the documentation of this file.
1 /*
2  * Filename header file for the Fast Light Tool Kit (FLTK).
3  *
4  * Copyright 1998-2018 by Bill Spitzak and others.
5  *
6  * This library is free software. Distribution and use rights are outlined in
7  * the file "COPYING" which should have been included with this file. If this
8  * file is missing or damaged, see the license at:
9  *
10  * https://www.fltk.org/COPYING.php
11  *
12  * Please see the following page on how to report bugs and issues:
13  *
14  * https://www.fltk.org/bugs.php
15  */
16 
21 #ifndef FL_FILENAME_H
22 # define FL_FILENAME_H
23 
24 #include "Fl_Export.H"
25 #include <FL/platform_types.h>
26 
31 # define FL_PATH_MAX 2048
47 FL_EXPORT const char *fl_filename_name(const char * filename);
48 FL_EXPORT const char *fl_filename_ext(const char *buf);
49 FL_EXPORT char *fl_filename_setext(char *to, int tolen, const char *ext);
50 FL_EXPORT int fl_filename_expand(char *to, int tolen, const char *from);
51 FL_EXPORT int fl_filename_absolute(char *to, int tolen, const char *from);
52 FL_EXPORT int fl_filename_relative(char *to, int tolen, const char *from);
53 FL_EXPORT int fl_filename_match(const char *name, const char *pattern);
54 FL_EXPORT int fl_filename_isdir(const char *name);
55 
56 # if defined(__cplusplus) && !defined(FL_DOXYGEN)
57 /*
58  * Under Windows, we include filename.H from numericsort.c; this should probably change...
59  */
60 
61 inline char *fl_filename_setext(char *to, const char *ext) { return fl_filename_setext(to, FL_PATH_MAX, ext); }
62 inline int fl_filename_expand(char *to, const char *from) { return fl_filename_expand(to, FL_PATH_MAX, from); }
63 inline int fl_filename_absolute(char *to, const char *from) { return fl_filename_absolute(to, FL_PATH_MAX, from); }
64 FL_EXPORT int fl_filename_relative(char *to, int tolen, const char *from, const char *cwd);
65 inline int fl_filename_relative(char *to, const char *from) { return fl_filename_relative(to, FL_PATH_MAX, from); }
66 # endif /* __cplusplus */
67 
68 # if defined (__cplusplus)
69 extern "C" {
70 # endif /* __cplusplus */
71 
72 # if !defined(FL_DOXYGEN)
73 FL_EXPORT int fl_alphasort(struct dirent **, struct dirent **);
74 FL_EXPORT int fl_casealphasort(struct dirent **, struct dirent **);
75 FL_EXPORT int fl_casenumericsort(struct dirent **, struct dirent **);
76 FL_EXPORT int fl_numericsort(struct dirent **, struct dirent **);
77 # endif
78 
79 typedef int (Fl_File_Sort_F)(struct dirent **, struct dirent **);
81 # if defined(__cplusplus)
82 }
83 
84 /*
85  * Portable "scandir" function. Ugly but necessary...
86  */
87 
88 FL_EXPORT int fl_filename_list(const char *d, struct dirent ***l,
90 FL_EXPORT void fl_filename_free_list(struct dirent ***l, int n);
91 
92 /*
93  * Generic function to open a Uniform Resource Identifier (URI) using a
94  * system-defined program (added in FLTK 1.1.8)
95  */
96 
97 FL_EXPORT int fl_open_uri(const char *uri, char *msg = (char *)0,
98  int msglen = 0);
99 
100 FL_EXPORT void fl_decode_uri(char *uri);
101 
102 # endif /* __cplusplus */
103 
104 /*
105  * FLTK 1.0.x compatibility definitions (FLTK_1_0_COMPAT) dropped in 1.4.0
106  */
107 
108 #endif /* FL_FILENAME_H */
109 
FL_EXPORT void fl_filename_free_list(struct dirent ***l, int n)
Free the list of filenames that is generated by fl_filename_list().
Definition: filename_list.cxx:81
FL_EXPORT char * fl_filename_setext(char *to, int tolen, const char *ext)
Replaces the extension in buf of max.
Definition: filename_setext.cxx:38
int fl_casenumericsort(struct dirent **A, struct dirent **B)
Compares directory entries alphanumerically (case-insensitive).
Definition: numericsort.c:77
FL_EXPORT int fl_filename_match(const char *name, const char *pattern)
Checks if a string s matches a pattern p.
Definition: filename_match.cxx:42
Definitions of platform-dependent types.
FL_EXPORT int fl_open_uri(const char *uri, char *msg=(char *) 0, int msglen=0)
Opens the specified Uniform Resource Identifier (URI).
Definition: fl_open_uri.cxx:74
FL_EXPORT int fl_filename_absolute(char *to, int tolen, const char *from)
Makes a filename absolute from a relative filename.
Definition: filename_absolute.cxx:46
FL_EXPORT int fl_filename_relative(char *to, int tolen, const char *from)
Makes a filename relative to the current working directory.
Definition: filename_absolute.cxx:121
FL_EXPORT int fl_filename_expand(char *to, int tolen, const char *from)
Expands a filename containing shell variables and tilde (~).
Definition: filename_expand.cxx:42
#define FL_PATH_MAX
all path buffers should use this length
Definition: filename.H:31
FL_EXPORT int fl_filename_isdir(const char *name)
Determines if a file exists and is a directory from its filename.
Definition: filename_isdir.cxx:35
FL_EXPORT int fl_filename_list(const char *d, struct dirent ***l, Fl_File_Sort_F *s=fl_numericsort)
Portable and const-correct wrapper for the scandir() function.
Definition: filename_list.cxx:68
FL_EXPORT void fl_decode_uri(char *uri)
Decodes a URL-encoded string.
Definition: fl_open_uri.cxx:113
FL_EXPORT const char * fl_filename_ext(const char *buf)
Gets the extension of a filename.
Definition: filename_ext.cxx:31
int fl_numericsort(struct dirent **A, struct dirent **B)
Compares directory entries alphanumerically (case-sensitive).
Definition: numericsort.c:120
int() Fl_File_Sort_F(struct dirent **, struct dirent **)
File sorting function.
Definition: filename.H:79