1 /* AbiSource Program Utilities
2  * Copyright (C) 1998-2000 AbiSource, Inc.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301 USA.
18  */
19 
20 #ifndef UT_PATH_H
21 #define UT_PATH_H
22 
23 #include <glib.h>
24 #include <time.h>
25 
26 #if defined(MAXPATHLEN) && !defined(PATH_MAX)
27 #define PATH_MAX MAXPATHLEN
28 #else
29 #include <limits.h>
30 #endif
31 
32 #ifdef HAVE_CONFIG_H
33 #include "config.h"
34 #endif
35 
36 /* GTK build supports platforms without PATH_MAX; we leave the warning in for
37  * other platforms to avoid headaches
38  */
39 #if !defined(PATH_MAX) && !defined(TOOLKIT_GTK_ALL)
40 #error Huh, neither MAXPATHLEN nor PATH_MAX available, fix for this platform needed.
41 #endif
42 
43 /* pre-emptive dismissal; ut_types.h is needed by just about everything,
44  * so even if it's commented out in-file that's still a lot of work for
45  * the preprocessor to do...
46  */
47 #ifndef UT_TYPES_H
48 #include "ut_types.h"
49 #endif
50 
51 #include "ut_string_class.h"
52 #include "ut_go_file.h"
53 #include "ut_rand.h"
54 
55 class UT_UTF8String;
56 
57 // todo: deprecate me
58 ABI_EXPORT const char* UT_basename(const char* path);
59 
60 ABI_EXPORT UT_UTF8String UT_go_basename(const char* uri);
61 
62 // useful for win32, since we can't use the glib functions that return
63 // a file descriptor in msvc (not unless someone adds a g_close() function
64 // to glib
65 ABI_EXPORT std::string UT_createTmpFile(const std::string& prefix, const std::string& extension);
66 
67 ABI_EXPORT bool UT_directoryExists(const char* dir);
68 
69 ABI_EXPORT bool UT_isRegularFile(const char* filename);
70 
71 ABI_EXPORT size_t UT_fileSize(const char * filename);
72 
73 ABI_EXPORT time_t UT_mTime(const char* path);
74 
75 ABI_EXPORT bool UT_legalizeFileName(std::string &filename);
76 #endif /* UT_PATH_H */
77