7 #ifndef PXR_BASE_ARCH_FILE_SYSTEM_H
8 #define PXR_BASE_ARCH_FILE_SYSTEM_H
25 #include <sys/types.h>
28 #if defined(ARCH_OS_LINUX) || defined(ARCH_OS_WASM_VM)
30 #include <sys/statfs.h>
32 #elif defined(ARCH_OS_DARWIN)
34 #include <sys/mount.h>
36 #elif defined(ARCH_OS_WINDOWS)
44 #if !defined(ARCH_OS_WINDOWS)
48 #include <sys/param.h>
52 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
56 #define F_OK 0 // Test for existence.
57 #define X_OK 1 // Test for execute permission.
58 #define W_OK 2 // Test for write permission.
59 #define R_OK 4 // Test for read permission.
62 #if defined(ARCH_OS_WINDOWS)
63 #define ARCH_GLOB_NOCHECK 1
64 #define ARCH_GLOB_MARK 2
65 #define ARCH_GLOB_NOSORT 4
67 #define ARCH_GLOB_NOCHECK GLOB_NOCHECK
68 #define ARCH_GLOB_MARK GLOB_MARK
69 #define ARCH_GLOB_NOSORT GLOB_NOSORT
71 #define ARCH_GLOB_DEFAULT (ARCH_GLOB_NOCHECK | ARCH_GLOB_MARK)
75 #define ARCH_PATH_MAX PATH_MAX
78 #define ARCH_PATH_MAX MAXPATHLEN
81 #define ARCH_PATH_MAX _MAX_PATH
83 #define ARCH_PATH_MAX 1024
89 #if defined(ARCH_OS_WINDOWS)
90 #define ARCH_PATH_SEP "\\"
91 #define ARCH_PATH_LIST_SEP ";"
92 #define ARCH_REL_PATH_IDENT ".\\"
94 #define ARCH_PATH_SEP "/"
95 #define ARCH_PATH_LIST_SEP ":"
96 #define ARCH_REL_PATH_IDENT "./"
99 #if defined(ARCH_OS_WINDOWS)
118 #if defined(ARCH_OS_WINDOWS)
119 # define ArchChmod(path, mode) _chmod(path, mode)
121 # define ArchChmod(path, mode) chmod(path, mode)
124 #if defined(ARCH_OS_WINDOWS)
125 # define ArchCloseFile(fd) _close(fd)
127 # define ArchCloseFile(fd) close(fd)
130 #if defined(ARCH_OS_WINDOWS)
131 # define ArchUnlinkFile(path) _unlink(path)
133 # define ArchUnlinkFile(path) unlink(path)
136 #if defined(ARCH_OS_WINDOWS)
137 ARCH_API int ArchWindowsFileAccess(
const char*
path, uint32_t dwAccessMask);
140 # define ArchFileAccess(path, mode) access(path, mode)
143 #if defined(ARCH_OS_WINDOWS)
144 # define ArchFdOpen(fd, mode) _fdopen(fd, mode)
146 # define ArchFdOpen(fd, mode) fdopen(fd, mode)
149 #if defined(ARCH_OS_WINDOWS)
150 # define ArchFileNo(stream) _fileno(stream)
152 # define ArchFileNo(stream) fileno(stream)
155 #if defined(ARCH_OS_WINDOWS)
156 # define ArchFileIsaTTY(stream) _isatty(stream)
158 # define ArchFileIsaTTY(stream) isatty(stream)
161 #if defined(ARCH_OS_WINDOWS)
164 # define ArchRmDir(path) rmdir(path)
210 bool stripDriveSpecifier =
false);
251 const std::string& suffix = std::string());
263 int ArchMakeTmpFile(
const std::string& prefix, std::string* pathname = 0);
275 const std::string& prefix, std::string* pathname = 0);
287 const std::string& prefix);
310 return m.get_deleter().GetLength();
316 return m.get_deleter().GetLength();
376 void const *addr,
size_t len,
unsigned char *pageMap);
412 #if defined(ARCH_OS_WINDOWS)
415 ARCH_API std::string ArchWindowsUtf16ToUtf8(
const std::wstring &wstr);
418 ARCH_API std::wstring ArchWindowsUtf8ToUtf16(
const std::string &str);
426 #endif // PXR_BASE_ARCH_FILE_SYSTEM_H
ARCH_API FILE * ArchOpenFile(char const *fileName, char const *mode)
ARCH_API void ArchMemAdvise(void const *addr, size_t len, ArchMemAdvice adv)
GT_API const UT_StringHolder time
#define PXR_NAMESPACE_OPEN_SCOPE
GLsizei const GLchar *const * path
ARCH_API std::string ArchAbsPath(const std::string &path)
ARCH_API void ArchFileAdvise(FILE *file, int64_t offset, size_t count, ArchFileAdvice adv)
ARCH_API std::string ArchNormPath(const std::string &path, bool stripDriveSpecifier=false)
GLuint GLsizei GLsizei * length
ARCH_API ArchConstFileMapping ArchMapFileReadOnly(FILE *file, std::string *errMsg=nullptr)
std::unique_ptr< char const, Arch_Unmapper > ArchConstFileMapping
Arch_Unmapper(size_t length)
ARCH_API ArchMutableFileMapping ArchMapFileReadWrite(FILE *file, std::string *errMsg=nullptr)
ARCH_API const char * ArchGetTmpDir()
ARCH_API int ArchMakeTmpFile(const std::string &prefix, std::string *pathname=0)
std::unique_ptr< char, Arch_Unmapper > ArchMutableFileMapping
ARCH_API std::string ArchReadLink(const char *path)
ARCH_API int64_t ArchGetFileLength(const char *fileName)
size_t ArchGetFileMappingLength(ArchConstFileMapping const &m)
Return the length of an ArchConstFileMapping.
ARCH_API bool ArchGetStatMode(const char *pathname, int *mode)
ARCH_API bool ArchStatIsWritable(const ArchStatType *st)
ARCH_API bool ArchQueryMappedMemoryResidency(void const *addr, size_t len, unsigned char *pageMap)
GT_API const UT_StringHolder st
#define PXR_NAMESPACE_CLOSE_SCOPE
ARCH_API std::string ArchGetFileName(FILE *file)
#define ArchFileAccess(path, mode)
ARCH_API int64_t ArchPRead(FILE *file, void *buffer, size_t count, int64_t offset)
ARCH_API void operator()(char *mapStart) const
ARCH_API std::string ArchMakeTmpSubdir(const std::string &tmpdir, const std::string &prefix)
ARCH_API int64_t ArchPWrite(FILE *file, void const *bytes, size_t count, int64_t offset)
ARCH_API bool ArchGetModificationTime(const char *pathname, double *time)
ARCH_API std::string ArchMakeTmpFileName(const std::string &prefix, const std::string &suffix=std::string())