00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __UT_PathFile__
00025 #define __UT_PathFile__
00026
00027 #include "FS_API.h"
00028 #include <UT/UT_Defines.h>
00029 #include <UT/UT_String.h>
00030 #include <UT/UT_PtrArray.h>
00031
00032 class UT_PathSearch;
00033 class UT_PathFileInfo;
00034 class FS_Reader;
00035
00036 #define UT_NOSAVE_HINT ".nosave"
00037 #define UT_HIDE_HINT ".hide"
00038 #define UT_APPEND_HINT ".append"
00039
00040 typedef int (*fs_path_compare_func_t)(UT_PathFileInfo *const*, UT_PathFileInfo *const*);
00041
00042 class FS_API UT_PathFile
00043 {
00044 public:
00045 UT_PathFile();
00046 virtual ~UT_PathFile();
00047
00048
00049
00050 void setSearchPath(int path_id, const char *pattern);
00051
00052
00053 void applyStandardFilter();
00054
00055
00056 const char *getSearchPattern() { return mySearchPattern; }
00057
00058 const char *getDefaultDir() { return myDefaultDir; }
00059 int getDefaultDirIndex() { return myDefaultDirIndex; }
00060 int getHomeDirIndex() { return myHomeIndex; }
00061
00062
00063
00064
00065 bool getLine(UT_WorkBuffer &wbuf);
00066
00067
00068 int getCurrentLineNumber() { return myCurrentLineNumber; }
00069 const char *getCurrentFileName();
00070
00071
00072
00073
00074 int getDirCount() const;
00075 const char *getDir(int i) const;
00076
00077
00078
00079 int getFileInfoCount(int filtered=1) const;
00080 UT_PathFileInfo *getFileInfo(int i, int filtered=1) const;
00081 void appendFileInfo(UT_PathFileInfo *info)
00082 { myFileInfos.append(info); }
00083
00084
00085 void clearFileInfoList() { myFileInfos.entries(0); }
00086
00087
00088 void sortFileInfos(int (*compare)(UT_PathFileInfo *const*t1,
00089 UT_PathFileInfo *const*t2));
00090
00091 virtual UT_PathFileInfo *createFileInfo();
00092 UT_PathFileInfo *appendFileInfo(const char *fullpath, int level);
00093 void removeFileInfo(int i);
00094 void removeFileInfo(UT_PathFileInfo *);
00095 void removeFileInfo(const char *fullpath);
00096
00097 protected:
00098
00099 void clearFileList();
00100 void computeFileList();
00101
00102 void addMatchingFiles(char *fullpattern, int level);
00103 void removeMatchingFiles(char *fullpattern, int level);
00104
00105 unsigned int myBusyFlag:1,
00106 myFilesFoundFlag:1;
00107 private:
00108 void computeDefaultDir();
00109 const UT_PathSearch *myPathSearch;
00110 UT_String mySearchPattern;
00111 UT_String myDefaultDir;
00112 int myDefaultDirIndex;
00113 int myHomeIndex;
00114 int myCurrentFileIndex;
00115 int myCurrentLineNumber;
00116
00117 UT_PtrArray<UT_PathFileInfo *> myFileInfos;
00118
00119 FS_Reader *myFile;
00120 friend int utAddMatchingFiles(const char *file, void *data);
00121 friend int utRemoveMatchingFiles(const char *file, void *data);
00122 };
00123
00124 FS_API extern bool UTfindPreferenceFile( int path_id,
00125 const char *filename,
00126 UT_String &result,
00127 bool &no_save);
00128
00129
00130 #endif