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;
74  { myFileInfos.append(info); }
75 
76  // note: no deleting done
77  void clearFileInfoList() { myFileInfos.entries(0); }
78 
79 
80  void sortFileInfos(int (*compare)(UT_PathFileInfo *const*t1,
81  UT_PathFileInfo *const*t2));
82 
83  virtual UT_PathFileInfo *createFileInfo();
84  UT_PathFileInfo *appendFileInfo(const char *fullpath, int level);
85  void removeFileInfo(int i); // NOT filtered
86  void removeFileInfo(UT_PathFileInfo *);
87  void removeFileInfo(const char *fullpath);
88 
89 protected:
90  // note: this is quite different from clearFileInfoList above
91  void clearFileList();
92  void computeFileList();
93 
94  void addMatchingFiles(char *fullpattern, int level);
95  void removeMatchingFiles(char *fullpattern, int level);
96 
97  unsigned int myBusyFlag:1,
98  myFilesFoundFlag:1;
99 private:
100  void computeDefaultDir();
101  const UT_PathSearch *myPathSearch;
102  UT_String mySearchPattern;
103  UT_String myDefaultDir;
104  int myDefaultDirIndex;
105  int myHomeIndex;
106  int myCurrentFileIndex;
107  int myCurrentLineNumber;
108 
109  UT_ValArray<UT_PathFileInfo *> myFileInfos;
110 
111  FS_Reader *myFile;
112  friend int utAddMatchingFiles(const char *file, void *data);
113  friend int utRemoveMatchingFiles(const char *file, void *data);
114 };
115 
116 FS_API extern bool UTfindPreferenceFile( int path_id,
117  const char *filename,
118  UT_String &result,
119  bool &no_save);
120 
121 
122 #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
const char * getSearchPattern()
Definition: UT_PathFile.h:48
void clearFileInfoList()
Definition: UT_PathFile.h:77
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)
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
void appendFileInfo(UT_PathFileInfo *info)
Definition: UT_PathFile.h:73
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
const char * getDefaultDir()
Definition: UT_PathFile.h:50
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
Definition: glew.h:12681
int getCurrentLineNumber()
Definition: UT_PathFile.h:60
GLuint64EXT * result
Definition: glew.h:14007
GLubyte * pattern
Definition: glew.h:5711
GLint level
Definition: glew.h:1252
#define FS_API
Definition: FS_API.h:10