00001 #ifndef _UT_DIRUTIL_H_
00002 #define _UT_DIRUTIL_H_
00003
00004 #include "UT_API.h"
00005 #include <time.h>
00006
00007 #include "UT_String.h"
00008 #include "UT_StringArray.h"
00009
00010 UT_API int UTunixFullPathSpecified(const char *name);
00011 UT_API int UTfullPathSpecified(const char *name);
00012 UT_API int UTisValidDirectory(const char *path);
00013
00014 UT_API bool UTisAbsolutePath(const char *filename);
00015 UT_API bool UTisRootPath(const char *filename);
00016 UT_API void UTmakeAbsoluteFilePath(UT_String &path, const char *basepath=NULL);
00017 UT_API const UT_StringArray &UTgetAbsolutePathPrefixes();
00018 UT_API void UTaddAbsolutePathPrefix(const char *prefix);
00019
00020
00021 UT_API bool UTisHiddenFile(const char *filename);
00022
00023 class UT_API UT_FileStat
00024 {
00025 public:
00026 enum FileType
00027 {
00028 REGULAR,
00029 EXECUTABLE,
00030 DIRECTORY,
00031 SHORTCUT,
00032 SOCKET,
00033 CHAR_DEVICE,
00034 BLOCK_DEVICE,
00035 SPECIAL
00036 };
00037
00038 UT_FileStat(FileType ftype = REGULAR, int64 fsize = 0,
00039 time_t f_atime = 0, time_t f_ctime = 0, time_t f_mtime = 0)
00040 : myFileType(ftype),
00041 mySize(fsize),
00042 myAccessTime(f_atime),
00043 myCreateTime(f_ctime),
00044 myModTime(f_mtime)
00045 {
00046 }
00047
00048 FileType myFileType;
00049 int64 mySize;
00050 time_t myAccessTime;
00051 time_t myCreateTime;
00052 time_t myModTime;
00053 };
00054
00055 #ifdef WIN32
00056 #include <sys/types.h>
00057 #include <direct.h>
00058
00059
00060
00061 #define EOVERFLOW 100
00062
00063 typedef intptr_t DIR;
00064 struct dirent {
00065 char *d_name;
00066 };
00067 UT_API DIR *opendir( const char *name );
00068 UT_API struct dirent *readdir( DIR *dirp );
00069 UT_API void closedir( DIR *dirp );
00070
00071
00072 UT_API int statLastRead(const char *path, UT_FileStat &file_stat);
00073
00074 UT_API char *getUnixCwd( char *buffer, int maxlen );
00075 #else
00076 #if defined(GAMEOS)
00077 #include "UT_GameOsUtil.h"
00078 #endif
00079 #include <sys/types.h>
00080 #include <sys/stat.h>
00081 #include <string.h>
00082 #include <dirent.h>
00083 #include <unistd.h>
00084 #include <stdlib.h>
00085
00086 inline char *getUnixCwd( char *buffer, int maxlen )
00087 { return getcwd( buffer, maxlen ); }
00088
00089 UT_API int statLastRead(const char *path, UT_FileStat &file_stat);
00090 #endif
00091
00092 #endif
00093