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_String.h>
21 #include <UT/UT_ValArray.h>
22 
23 class UT_WorkBuffer;
24 class UT_PathSearch;
25 class UT_PathFileInfo;
26 class FS_Reader;
27 
28 #define UT_NOSAVE_HINT ".nosave"
29 #define UT_HIDE_HINT ".hide"
30 #define UT_APPEND_HINT ".append"
31 
33 
35 {
36 public:
37  UT_PathFile();
38  virtual ~UT_PathFile();
39 
40 
41  // You should call these three at least once before using this class
42  void setSearchPath(int path_id, const char *pattern);
43 
44  // Then you should call this method (or some subclass' equivalent)
45  void applyStandardFilter();
46 
47 
48  const char *getSearchPattern() { return mySearchPattern; }
49 
50  const char *getDefaultDir() { return myDefaultDir; }
51  int getDefaultDirIndex() { return myDefaultDirIndex; }
52  int getHomeDirIndex() { return myHomeIndex; }
53 
54 
55  // This is the simplest method of using this class, it just streams you
56  // all the lines in all the files that match your search.
57  bool getLine(UT_WorkBuffer &wbuf);
58 
59  // Some query methods for getting info about the current line of input
60  int getCurrentLineNumber() { return myCurrentLineNumber; }
61  const char *getCurrentFileName();
62 
63 
64  // Query methods for getting at the directory list.
65  // NOTE: getDir() indexes from the end of the list!
66  int getDirCount() const;
67  const char *getDir(int i) const;
68 
69  // if you set the filtered flag to zero, then you'll get all the matching
70  // files in the search path. ie hidden ones, overridden ones, etc
71  int getFileInfoCount(int filtered=1) const;
72  UT_PathFileInfo *getFileInfo(int i, int filtered=1) const;
73  UT_PathFileInfo *getFileInfo(char const* file_path) const;
75  { myFileInfos.append(info); }
76 
77  // note: no deleting done
78  void clearFileInfoList() { myFileInfos.entries(0); }
79 
80 
81  void sortFileInfos(int (*compare)(UT_PathFileInfo *const*t1,
82  UT_PathFileInfo *const*t2));
83 
84  virtual UT_PathFileInfo *createFileInfo();
85  UT_PathFileInfo *appendFileInfo(const char *fullpath, int level);
86  void removeFileInfo(int i); // NOT filtered
87  void removeFileInfo(UT_PathFileInfo *);
88  void removeFileInfo(const char *fullpath);
89 
90 protected:
91  // note: this is quite different from clearFileInfoList above
92  void clearFileList();
93  void computeFileList();
94 
95  void addMatchingFiles(char *fullpattern, int level);
96  void removeMatchingFiles(char *fullpattern, int level);
97 
98 
99  unsigned int myBusyFlag:1,
100  myFilesFoundFlag:1;
101 private:
102  void computeDefaultDir();
103  const UT_PathSearch *myPathSearch;
104  UT_String mySearchPattern;
105  UT_String myDefaultDir;
106  int myDefaultDirIndex;
107  int myHomeIndex;
108  int myCurrentFileIndex;
109  int myCurrentLineNumber;
110 
111  UT_ValArray<UT_PathFileInfo *> myFileInfos;
112 
113  FS_Reader *myFile;
114  friend int utAddMatchingFiles(const char *file, void *data);
115  friend int utRemoveMatchingFiles(const char *file, void *data);
116 };
117 
118 FS_API extern bool UTfindPreferenceFile( int path_id,
119  const char *filename,
120  UT_String &result,
121  bool &no_save);
122 
123 
124 #endif
Class for reading files.
Definition: FS_Reader.h:33
GT_API const UT_StringHolder filename
int(* fs_path_compare_func_t)(UT_PathFileInfo *const *, UT_PathFileInfo *const *)
Definition: UT_PathFile.h:32
int getDefaultDirIndex()
Definition: UT_PathFile.h:51
int getHomeDirIndex()
Definition: UT_PathFile.h:52
GLint level
Definition: glcorearb.h:108
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
Definition: glew.h:12900
const char * getSearchPattern()
Definition: UT_PathFile.h:48
void clearFileInfoList()
Definition: UT_PathFile.h:78
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)
GLuint64EXT * result
Definition: glew.h:14311
void appendFileInfo(UT_PathFileInfo *info)
Definition: UT_PathFile.h:74
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
const char * getDefaultDir()
Definition: UT_PathFile.h:50
GLubyte * pattern
Definition: glew.h:5741
int getCurrentLineNumber()
Definition: UT_PathFile.h:60
Definition: format.h:895
#define FS_API
Definition: FS_API.h:10