6 #ifndef MATERIALX_FILE_H
7 #define MATERIALX_FILE_H
41 FormatNative = FormatWindows
43 FormatNative = FormatPosix
56 return _vec == rhs._vec &&
61 return !(*
this == rhs);
86 void assign(
const string& str);
100 return _type != TypeRelative;
111 return _vec[_vec.size() - 1];
121 parent._vec.pop_back();
129 const string& baseName = getBaseName();
130 size_t i = baseName.rfind(
'.');
131 return i != string::npos ? baseName.substr(i + 1) :
EMPTY_STRING;
137 assign(asString() +
"." + ext);
145 string& baseName = _vec[_vec.size() - 1];
146 size_t i = baseName.rfind(
'.');
147 if (i != string::npos)
149 baseName = baseName.substr(0, i);
188 bool isDirectory()
const;
197 void createDirectory()
const;
200 bool setCurrentPath();
247 for (
size_t i = 0; i < _paths.size(); i++)
250 if (i + 1 < _paths.size())
261 _paths.push_back(path);
269 _paths.push_back(
path);
276 _paths.insert(_paths.begin(),
path);
288 return _paths.size();
294 return _paths.empty();
300 return _paths[
index];
306 return _paths[
index];
315 if (_paths.empty() || filename.
isEmpty())
ConstIterator begin() const
string asString(const string &sep=PATH_LIST_SEPARATOR) const
Convert this sequence to a string using the given separator.
bool isEmpty() const
Return true if the search path is empty.
GT_API const UT_StringHolder filename
FilePath & operator[](size_t index)
Return the path at the given index.
#define MATERIALX_NAMESPACE_BEGIN
vector< string > StringVec
A vector of strings.
GLsizei const GLchar *const * string
GLsizei const GLchar *const * path
bool isAbsolute() const
Return true if the given path is absolute.
MATERIALX_NAMESPACE_BEGIN MX_CORE_API const string EMPTY_STRING
FilePathVec::iterator Iterator
void addExtension(const string &ext)
Add a file extension to the given path.
const string & getBaseName() const
FilePath(const string &str)
Construct a path from a standard string.
string operator[](size_t index)
Return the string at the given index.
bool isEmpty() const
Return true if the given path is empty.
size_t size() const
Return the number of paths in the sequence.
void removeExtension()
Remove the file extension, if any, from the given path.
FilePath(const char *str)
Construct a path from a C-style string.
bool operator!=(const FilePath &rhs) const
GLint GLint GLsizei GLint GLenum format
ConstIterator end() const
string getExtension() const
Return the file extension of the given path.
OIIO_UTIL_API bool exists(string_view path) noexcept
const string & operator[](size_t index) const
Return the const string at the given index.
size_t size() const
Return the number of strings in the path.
void prepend(const FilePath &path)
Prepend the given path to the sequence.
void append(const FilePath &path)
Append the given path to the sequence.
void clear()
Clear all paths from the sequence.
bool operator==(const FilePath &rhs) const
FileSearchPath(const string &searchPath, const string &sep=PATH_LIST_SEPARATOR)
FilePath find(const FilePath &filename) const
FilePathVec::const_iterator ConstIterator
#define MATERIALX_NAMESPACE_END
const FilePath & operator[](size_t index) const
Return the const path at the given index.
FilePath getParentPath() const
IMATH_HOSTDEVICE constexpr Quat< T > operator/(const Quat< T > &q1, const Quat< T > &q2) IMATH_NOEXCEPT
Quaterion division.
OIIO_UTIL_API std::string extension(string_view filepath, bool include_dot=true) noexcept
void append(const FileSearchPath &searchPath)
Append the given search path to the sequence.
MX_CORE_API StringVec splitString(const string &str, const string &sep)
bool exists() const
Return true if the given path exists on the file system.