00001 /* AbiSource Program Utilities 00002 * Copyright (C) 1998-2000 AbiSource, Inc. 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00017 * 02110-1301 USA. 00018 */ 00019 00020 #ifndef UT_PATH_H 00021 #define UT_PATH_H 00022 00023 #include <glib.h> 00024 #include <time.h> 00025 00026 #if defined(MAXPATHLEN) && !defined(PATH_MAX) 00027 #define PATH_MAX MAXPATHLEN 00028 #else 00029 #include <limits.h> 00030 #endif 00031 00032 #ifdef HAVE_CONFIG_H 00033 #include "config.h" 00034 #endif 00035 00036 /* GTK build supports platforms without PATH_MAX; we leave the warning in for 00037 * other platforms to avoid headaches 00038 */ 00039 #if !defined(PATH_MAX) && !defined(TOOLKIT_GTK_ALL) 00040 #error Huh, neither MAXPATHLEN nor PATH_MAX available, fix for this platform needed. 00041 #endif 00042 00043 /* pre-emptive dismissal; ut_types.h is needed by just about everything, 00044 * so even if it's commented out in-file that's still a lot of work for 00045 * the preprocessor to do... 00046 */ 00047 #ifndef UT_TYPES_H 00048 #include "ut_types.h" 00049 #endif 00050 00051 #include "ut_string_class.h" 00052 #include "ut_go_file.h" 00053 #include "ut_rand.h" 00054 00055 class UT_UTF8String; 00056 00057 // todo: deprecate me 00058 ABI_EXPORT const char* UT_basename(const char* path); 00059 00060 ABI_EXPORT UT_UTF8String UT_go_basename(const char* uri); 00061 00062 // useful for win32, since we can't use the glib functions that return 00063 // a file descriptor in msvc (not unless someone adds a g_close() function 00064 // to glib 00065 ABI_EXPORT std::string UT_createTmpFile(const std::string& prefix, const std::string& extension); 00066 00067 ABI_EXPORT bool UT_directoryExists(const char* dir); 00068 00069 ABI_EXPORT bool UT_isRegularFile(const char* filename); 00070 00071 ABI_EXPORT size_t UT_fileSize(const char * filename); 00072 00073 ABI_EXPORT time_t UT_mTime(const char* path); 00074 00075 ABI_EXPORT bool UT_legalizeFileName(std::string &filename); 00076 #endif /* UT_PATH_H */