HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FS Namespace Reference

Functions

template<bool DIR, typename T >
bool process (T &func, UT_WorkBuffer &fullpath, exint fullpath_len, const UT_StringArray &paths, const UT_Array< FS_Stat > &stats)
 Utility function to process the contents of the traverse() function. More...
 
template<typename T >
void traverse (T &func, const char *path, bool sort_contents=false, bool directories_first=true)
 

Function Documentation

template<bool DIR, typename T >
bool FS::process ( T &  func,
UT_WorkBuffer fullpath,
exint  fullpath_len,
const UT_StringArray paths,
const UT_Array< FS_Stat > &  stats 
)

Utility function to process the contents of the traverse() function.

Definition at line 24 of file FS_Traverse.h.

template<typename T >
void FS::traverse ( T &  func,
const char *  path,
bool  sort_contents = false,
bool  directories_first = true 
)

FS function to process all files in a directory. The template functor should have two methods:

  • bool dir(const char *path, const FS_Stat &stat);
  • bool file(const char *path, const FS_Stat &stat); If either of these functions returns false, traversal will be terminated

For example, to list all files in a directory:

struct FileList {
bool file(const char *dir, const FS_Stat &stat) const {
if (myRecursive) {
printf("%s/\n", dir);
FS::traverse(dir, this);
}
}
bool file(const char *path, const FS_Stat &stat) const {
printf("%s\n", path);
}
bool myRecursive = true;
};

Definition at line 70 of file FS_Traverse.h.