All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fileSystem.h File Reference

Architecture dependent file system access. More...

+ Include dependency graph for fileSystem.h:

Go to the source code of this file.

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   "./"
 
#define ArchChmod(path, mode)   chmod(path, mode)
 
#define ArchCloseFile(fd)   close(fd)
 
#define ArchUnlinkFile(path)   unlink(path)
 
#define ArchFileAccess(path, mode)   access(path, mode)
 
#define ArchFdOpen(fd, mode)   fdopen(fd, mode)
 
#define ArchFileNo(stream)   fileno(stream)
 
#define ArchFileIsaTTY(stream)   isatty(stream)
 
#define ArchRmDir(path)   rmdir(path)
 

Typedefs

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

Enumerations

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

Functions

ARCH_API FILE * ArchOpenFile (char const *fileName, char const *mode)
 Opens a file. More...
 
ARCH_API int64_t ArchGetFileLength (const char *fileName)
 Return the length of a file in bytes. More...
 
ARCH_API int64_t ArchGetFileLength (FILE *file)
 
ARCH_API std::string ArchGetFileName (FILE *file)
 Return a filename for this file, if one can be obtained. More...
 
ARCH_API bool ArchStatIsWritable (const ArchStatType *st)
 Returns true if the data in stat struct st indicates that the target file or directory is writable. More...
 
ARCH_API bool ArchGetModificationTime (const char *pathname, double *time)
 Returns the modification time (mtime) in seconds for a file. More...
 
ARCH_API double ArchGetModificationTime (const ArchStatType &st)
 Returns the modification time (mtime) in seconds from the stat struct. More...
 
ARCH_API std::string ArchNormPath (const std::string &path, bool stripDriveSpecifier=false)
 Normalizes the specified path, eliminating double slashes, etc. More...
 
ARCH_API std::string ArchAbsPath (const std::string &path)
 Returns the canonical absolute path of the specified filename. More...
 
ARCH_API bool ArchGetStatMode (const char *pathname, int *mode)
 Returns the permissions mode (mode_t) for the given pathname. More...
 
ARCH_API const char * ArchGetTmpDir ()
 Return the path to a temporary directory for this platform. More...
 
ARCH_API std::string ArchMakeTmpFileName (const std::string &prefix, const std::string &suffix=std::string())
 Make a temporary file name, in a system-determined temporary directory. More...
 
ARCH_API int ArchMakeTmpFile (const std::string &prefix, std::string *pathname=0)
 Create a temporary file, in a system-determined temporary directory. More...
 
ARCH_API int ArchMakeTmpFile (const std::string &tmpdir, const std::string &prefix, std::string *pathname=0)
 Create a temporary file, in a given temporary directory. More...
 
ARCH_API std::string ArchMakeTmpSubdir (const std::string &tmpdir, const std::string &prefix)
 Create a temporary sub-direcrory, in a given temporary directory. More...
 
size_t ArchGetFileMappingLength (ArchConstFileMapping const &m)
 Return the length of an ArchConstFileMapping. More...
 
size_t ArchGetFileMappingLength (ArchMutableFileMapping const &m)
 Return the length of an ArchMutableFileMapping. More...
 
ARCH_API ArchConstFileMapping 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. More...
 
ARCH_API ArchConstFileMapping ArchMapFileReadOnly (std::string const &path, std::string *errMsg=nullptr)
 
ARCH_API ArchMutableFileMapping 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. More...
 
ARCH_API ArchMutableFileMapping ArchMapFileReadWrite (std::string const &path, std::string *errMsg=nullptr)
 
ARCH_API void ArchMemAdvise (void const *addr, size_t len, ArchMemAdvice adv)
 Advise the OS regarding how the application intends to access a range of memory. More...
 
ARCH_API bool 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. More...
 
ARCH_API int64_t ArchPRead (FILE *file, void *buffer, size_t count, int64_t offset)
 Read up to count bytes from offset in file into buffer. More...
 
ARCH_API int64_t ArchPWrite (FILE *file, void const *bytes, size_t count, int64_t offset)
 Write up to count bytes from buffer to file at offset. More...
 
ARCH_API std::string ArchReadLink (const char *path)
 Returns the value of the symbolic link at path. More...
 
ARCH_API void 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. More...
 

Detailed Description

Architecture dependent file system access.

Definition in file fileSystem.h.