HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_PathFile.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_PathFile.h (Utility Library, C++)
7  *
8  * COMMENTS:
9  * This class is used to look for files using searchpaths.
10  * It has mechanisms for patternmatching, finding only the
11  * file that's highest in the searchpath, or combining them
12  * all, and so on. The way it searches for files is also
13  * special. Check out the .C file for more docs on that.
14  */
15 
16 #ifndef __UT_PathFile__
17 #define __UT_PathFile__
18 
19 #include "FS_API.h"
20 #include <UT/UT_NonCopyable.h>
21 #include <UT/UT_String.h>
22 #include <UT/UT_ValArray.h>
23 
24 class UT_WorkBuffer;
25 class UT_PathSearch;
26 class UT_PathFileInfo;
27 class FS_Reader;
28 
29 #define UT_NOSAVE_HINT ".nosave"
30 #define UT_HIDE_HINT ".hide"
31 #define UT_APPEND_HINT ".append"
32 
34 
36 {
37 public:
38  UT_PathFile();
39  virtual ~UT_PathFile();
40 
42 
43  // You should call these three at least once before using this class
44  void setSearchPath(int path_id, const char *pattern);
45 
46  // Then you should call this method (or some subclass' equivalent)
47  void applyStandardFilter();
48 
49 
50  const char *getSearchPattern() { return mySearchPattern; }
51 
52  const char *getDefaultDir() { return myDefaultDir; }
53  int getDefaultDirIndex() { return myDefaultDirIndex; }
54  int getHomeDirIndex() { return myHomeIndex; }
55 
56 
57  // This is the simplest method of using this class, it just streams you
58  // all the lines in all the files that match your search.
59  bool getLine(UT_WorkBuffer &wbuf);
60 
61  // Some query methods for getting info about the current line of input
62  int getCurrentLineNumber() { return myCurrentLineNumber; }
63  const char *getCurrentFileName();
64 
65 
66  // Query methods for getting at the directory list.
67  // NOTE: getDir() indexes from the end of the list!
68  int getDirCount() const;
69  const char *getDir(int i) const;
70 
71  // if you set the filtered flag to zero, then you'll get all the matching
72  // files in the search path. ie hidden ones, overridden ones, etc
73  int getFileInfoCount(int filtered=1) const;
74  UT_PathFileInfo *getFileInfo(int i, int filtered=1) const;
75  UT_PathFileInfo *getFileInfo(char const* file_path) const;
77  { myFileInfos.append(info); }
78 
79  // note: no deleting done
80  void clearFileInfoList() { myFileInfos.entries(0); }
81 
82 
83  void sortFileInfos(int (*compare)(UT_PathFileInfo *const*t1,
84  UT_PathFileInfo *const*t2));
85 
86  virtual UT_PathFileInfo *createFileInfo();
87  UT_PathFileInfo *appendFileInfo(const char *fullpath, int level);
88  void removeFileInfo(int i); // NOT filtered
89  void removeFileInfo(UT_PathFileInfo *);
90  void removeFileInfo(const char *fullpath);
91 
92 protected:
93  // note: this is quite different from clearFileInfoList above
94  void clearFileList();
95  void computeFileList();
96 
97  void addMatchingFiles(char *fullpattern, int level);
98  void removeMatchingFiles(char *fullpattern, int level);
99 
100 
101  unsigned int myBusyFlag:1,
102  myFilesFoundFlag:1;
103 private:
104  void computeDefaultDir();
105  const UT_PathSearch *myPathSearch;
106  UT_String mySearchPattern;
107  UT_String myDefaultDir;
108  int myDefaultDirIndex;
109  int myHomeIndex;
110  int myCurrentFileIndex;
111  int myCurrentLineNumber;
112 
113  UT_ValArray<UT_PathFileInfo *> myFileInfos;
114 
115  FS_Reader *myFile;
116  friend int utAddMatchingFiles(const char *file, void *data);
117  friend int utRemoveMatchingFiles(const char *file, void *data);
118 };
119 
120 FS_API extern bool UTfindPreferenceFile( int path_id,
121  const char *filename,
122  UT_String &result,
123  bool &no_save);
124 
125 
126 #endif
Class for reading files.
Definition: FS_Reader.h:33
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
GT_API const UT_StringHolder filename
int(* fs_path_compare_func_t)(UT_PathFileInfo *const *, UT_PathFileInfo *const *)
Definition: UT_PathFile.h:33
int getDefaultDirIndex()
Definition: UT_PathFile.h:53
int getHomeDirIndex()
Definition: UT_PathFile.h:54
GLint level
Definition: glcorearb.h:108
**But if you need a result
Definition: thread.h:613
const char * getSearchPattern()
Definition: UT_PathFile.h:50
void clearFileInfoList()
Definition: UT_PathFile.h:80
CompareResults OIIO_API compare(const ImageBuf &A, const ImageBuf &B, float failthresh, float warnthresh, ROI roi={}, int nthreads=0)
FS_API bool UTfindPreferenceFile(int path_id, const char *filename, UT_String &result, bool &no_save)
void appendFileInfo(UT_PathFileInfo *info)
Definition: UT_PathFile.h:76
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
GLushort pattern
Definition: glad.h:2583
const char * getDefaultDir()
Definition: UT_PathFile.h:52
int getCurrentLineNumber()
Definition: UT_PathFile.h:62
Definition: format.h:895
#define FS_API
Definition: FS_API.h:10