7#ifndef PXR_BASE_TF_FILE_UTILS_H
8#define PXR_BASE_TF_FILE_UTILS_H
15#include "pxr/base/tf/api.h"
21PXR_NAMESPACE_OPEN_SCOPE
34bool TfPathExists(std::string
const& path,
bool resolveSymlinks =
false);
47bool TfIsDir(std::string
const& path,
bool resolveSymlinks =
false);
60bool TfIsFile(std::string
const& path,
bool resolveSymlinks =
false);
88bool TfSymlink(std::string
const& src, std::string
const& dst);
111bool TfMakeDirs(std::string
const& path,
int mode=-1,
bool existOk=
false);
125typedef std::function<bool (std::string
const&,
126 std::vector<std::string> *,
134typedef std::function<void (std::string
const&,
188 bool followLinks =
false);
207std::vector<std::string>
TfListDir(std::string
const& path,
208 bool recursive =
false);
223 std::vector<std::string> *dirnames,
224 std::vector<std::string> *filenames,
225 std::vector<std::string> *symlinknames,
226 std::string *errMsg = NULL);
238PXR_NAMESPACE_CLOSE_SCOPE
TF_API bool TfIsWritable(std::string const &path)
Returns true if the file or directory at path is writable.
TF_API bool TfIsFile(std::string const &path, bool resolveSymlinks=false)
Returns true if the path exists and is a file.
TF_API std::vector< std::string > TfListDir(std::string const &path, bool recursive=false)
Return a list containing files and directories in path.
TF_API bool TfReadDir(std::string const &dirPath, std::vector< std::string > *dirnames, std::vector< std::string > *filenames, std::vector< std::string > *symlinknames, std::string *errMsg=NULL)
Read the contents of dirPath and append the names of the contained directories, files,...
TF_API bool TfPathExists(std::string const &path, bool resolveSymlinks=false)
Returns true if the path exists.
TF_API bool TfSymlink(std::string const &src, std::string const &dst)
Creates a symbolic link from src to dst.
TF_API bool TfTouchFile(std::string const &fileName, bool create=true)
Touch fileName, updating access and modification time to 'now'.
TF_API bool TfIsDirEmpty(std::string const &path)
Returns true if the path is an empty directory.
TF_API void TfRmTree(std::string const &path, TfWalkErrorHandler onError=0)
Recursively delete a directory tree rooted at path.
TF_API void TfWalkIgnoreErrorHandler(std::string const &path, std::string const &msg)
error handler to use when you want to ignore errors
TF_API bool TfMakeDirs(std::string const &path, int mode=-1, bool existOk=false)
Creates a directory hierarchy.
TF_API bool TfDeleteFile(std::string const &path)
Deletes a file at path.
TF_API bool TfIsDir(std::string const &path, bool resolveSymlinks=false)
Returns true if the path exists and is a directory.
TF_API void TfWalkDirs(std::string const &top, TfWalkFunction fn, bool topDown=true, TfWalkErrorHandler onError=0, bool followLinks=false)
Directory tree walker.
TF_API bool TfIsLink(std::string const &path)
Returns true if the path exists and is a symbolic link.
std::function< void(std::string const &, std::string const &)> TfWalkErrorHandler
TfRmTree error handler function.
std::function< bool(std::string const &, std::vector< std::string > *, std::vector< std::string > const &)> TfWalkFunction
Function type for TfWalkDirs.
TF_API bool TfMakeDir(std::string const &path, int mode=-1)
Creates a directory.