Pixar Arch
Loading...
Searching...
No Matches
fileSystem.h File Reference

Architecture dependent file system access. More...

#include "./api.h"
#include "./defines.h"
#include "./inttypes.h"
#include <memory>
#include <cstdio>
#include <string>
#include <set>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>

Go to the source code of this file.

Classes

struct  pxr::Arch_Unmapper
 

Namespaces

namespace  pxr
 

Macros

#define ARCH_GLOB_NOCHECK   GLOB_NOCHECK
 
#define ARCH_GLOB_MARK   GLOB_MARK
 
#define ARCH_GLOB_NOSORT   GLOB_NOSORT
 
#define ARCH_GLOB_DEFAULT   (ARCH_GLOB_NOCHECK | ARCH_GLOB_MARK)
 
#define ARCH_PATH_MAX   1024
 
#define ARCH_PATH_SEP   "/"
 
#define ARCH_PATH_LIST_SEP   ":"
 
#define ARCH_REL_PATH_IDENT   "./"
 

Typedefs

typedef struct stat pxr::ArchStatType
 
using pxr::ArchConstFileMapping = std::unique_ptr<char const, Arch_Unmapper>
 ArchConstFileMapping and ArchMutableFileMapping are std::unique_ptr<char const *, ...> and std::unique_ptr<char *, ...> respectively.
 
using pxr::ArchMutableFileMapping = std::unique_ptr<char, Arch_Unmapper>
 

Enumerations

enum  pxr::ArchMemAdvice { pxr::ArchMemAdviceNormal , pxr::ArchMemAdviceWillNeed , pxr::ArchMemAdviceDontNeed , pxr::ArchMemAdviceRandomAccess }
 
enum  pxr::ArchFileAdvice { pxr::ArchFileAdviceNormal , pxr::ArchFileAdviceWillNeed , pxr::ArchFileAdviceDontNeed , pxr::ArchFileAdviceRandomAccess }
 

Functions

ARCH_API FILE * pxr::ArchOpenFile (char const *fileName, char const *mode)
 Opens a file.
 
ARCH_API int pxr::ArchChmod (const char *path, int mode)
 
ARCH_API int pxr::ArchCloseFile (int fd)
 
ARCH_API int pxr::ArchUnlinkFile (const char *path)
 
ARCH_API int pxr::ArchFileAccess (const char *path, int mode)
 
ARCH_API FILE * pxr::ArchFdOpen (int fd, const char *mode)
 
ARCH_API int pxr::ArchFileNo (FILE *file)
 
ARCH_API int pxr::ArchFileIsaTTY (int fd)
 
ARCH_API int pxr::ArchRmDir (const char *path)
 
ARCH_API int64_t pxr::ArchGetFileLength (const char *fileName)
 Return the length of a file in bytes.
 
ARCH_API int64_t pxr::ArchGetFileLength (FILE *file)
 
ARCH_API std::string pxr::ArchGetFileName (FILE *file)
 Return a filename for this file, if one can be obtained.
 
ARCH_API bool pxr::ArchStatIsWritable (const ArchStatType *st)
 Returns true if the data in stat struct st indicates that the target file or directory is writable.
 
ARCH_API bool pxr::ArchGetModificationTime (const char *pathname, double *time)
 Returns the modification time (mtime) in seconds for a file.
 
ARCH_API double pxr::ArchGetModificationTime (const ArchStatType &st)
 Returns the modification time (mtime) in seconds from the stat struct.
 
ARCH_API std::string pxr::ArchNormPath (const std::string &path, bool stripDriveSpecifier=false)
 Normalizes the specified path, eliminating double slashes, etc.
 
ARCH_API std::string pxr::ArchAbsPath (const std::string &path)
 Returns the canonical absolute path of the specified filename.
 
ARCH_API bool pxr::ArchGetStatMode (const char *pathname, int *mode)
 Returns the permissions mode (mode_t) for the given pathname.
 
ARCH_API const char * pxr::ArchGetTmpDir ()
 Return the path to a temporary directory for this platform.
 
ARCH_API std::string pxr::ArchMakeTmpFileName (const std::string &prefix, const std::string &suffix=std::string())
 Make a temporary file name, in a system-determined temporary directory.
 
ARCH_API int pxr::ArchMakeTmpFile (const std::string &prefix, std::string *pathname=0)
 Create a temporary file, in a system-determined temporary directory.
 
ARCH_API int pxr::ArchMakeTmpFile (const std::string &tmpdir, const std::string &prefix, std::string *pathname=0)
 Create a temporary file, in a given temporary directory.
 
ARCH_API std::string pxr::ArchMakeTmpSubdir (const std::string &tmpdir, const std::string &prefix)
 Create a temporary sub-direcrory, in a given temporary directory.
 
size_t pxr::ArchGetFileMappingLength (ArchConstFileMapping const &m)
 Return the length of an ArchConstFileMapping.
 
size_t pxr::ArchGetFileMappingLength (ArchMutableFileMapping const &m)
 Return the length of an ArchMutableFileMapping.
 
ARCH_API ArchConstFileMapping pxr::ArchMapFileReadOnly (FILE *file, std::string *errMsg=nullptr)
 Privately map the passed file into memory and return a unique_ptr to the read-only mapped contents.
 
ARCH_API ArchConstFileMapping pxr::ArchMapFileReadOnly (std::string const &path, std::string *errMsg=nullptr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
ARCH_API ArchMutableFileMapping pxr::ArchMapFileReadWrite (FILE *file, std::string *errMsg=nullptr)
 Privately map the passed file into memory and return a unique_ptr to the copy-on-write mapped contents.
 
ARCH_API ArchMutableFileMapping pxr::ArchMapFileReadWrite (std::string const &path, std::string *errMsg=nullptr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
ARCH_API void pxr::ArchMemAdvise (void const *addr, size_t len, ArchMemAdvice adv)
 Advise the OS regarding how the application intends to access a range of memory.
 
ARCH_API bool pxr::ArchQueryMappedMemoryResidency (void const *addr, size_t len, unsigned char *pageMap)
 Report whether or not the mapped virtual memory pages starting at addr for len bytes are resident in RAM.
 
ARCH_API int64_t pxr::ArchPRead (FILE *file, void *buffer, size_t count, int64_t offset)
 Read up to count bytes from offset in file into buffer.
 
ARCH_API int64_t pxr::ArchPWrite (FILE *file, void const *bytes, size_t count, int64_t offset)
 Write up to count bytes from buffer to file at offset.
 
ARCH_API std::string pxr::ArchReadLink (const char *path)
 Returns the value of the symbolic link at path.
 
ARCH_API void pxr::ArchFileAdvise (FILE *file, int64_t offset, size_t count, ArchFileAdvice adv)
 Advise the OS regarding how the application intends to access a range of bytes in a file.
 

Detailed Description

Architecture dependent file system access.

Macro Definition Documentation

◆ ARCH_GLOB_NOCHECK

#define ARCH_GLOB_NOCHECK   GLOB_NOCHECK

◆ ARCH_GLOB_MARK

#define ARCH_GLOB_MARK   GLOB_MARK

◆ ARCH_GLOB_NOSORT

#define ARCH_GLOB_NOSORT   GLOB_NOSORT

◆ ARCH_GLOB_DEFAULT

#define ARCH_GLOB_DEFAULT   (ARCH_GLOB_NOCHECK | ARCH_GLOB_MARK)

◆ ARCH_PATH_MAX

#define ARCH_PATH_MAX   1024

◆ ARCH_PATH_SEP

#define ARCH_PATH_SEP   "/"

◆ ARCH_PATH_LIST_SEP

#define ARCH_PATH_LIST_SEP   ":"

◆ ARCH_REL_PATH_IDENT

#define ARCH_REL_PATH_IDENT   "./"