ARC SDK
|
Defines interface for accessing filesystems. More...
#include <arc/FileAccess.h>
Data Structures | |
struct | header_t |
Internal struct used for communication between processes. More... | |
Public Member Functions | |
FileAccess (void) | |
New FileAccess object. | |
~FileAccess (void) | |
Shuts down any spawned executable. | |
bool | ping (void) |
Check if communication with proxy works. | |
bool | fa_setuid (int uid, int gid) |
Modify user uid and gid. More... | |
bool | fa_mkdir (const std::string &path, mode_t mode) |
Make a directory and assign it specified mode. | |
bool | fa_mkdirp (const std::string &path, mode_t mode) |
Make a directory and assign it specified mode. More... | |
bool | fa_link (const std::string &oldpath, const std::string &newpath) |
Create hard link. | |
bool | fa_softlink (const std::string &oldpath, const std::string &newpath) |
Create symbolic (aka soft) link. | |
bool | fa_copy (const std::string &oldpath, const std::string &newpath, mode_t mode) |
Copy file to new location. More... | |
bool | fa_rename (const std::string &oldpath, const std::string &newpath) |
Rename file. | |
bool | fa_chmod (const std::string &path, mode_t mode) |
Change mode of filesystem object. | |
bool | fa_stat (const std::string &path, struct stat &st) |
stat file. | |
bool | fa_lstat (const std::string &path, struct stat &st) |
stat symbolic link or file. | |
bool | fa_fstat (struct stat &st) |
stat open file. | |
bool | fa_ftruncate (off_t length) |
Truncate open file. | |
off_t | fa_fallocate (off_t length) |
Allocate disk space for open file. | |
bool | fa_readlink (const std::string &path, std::string &linkpath) |
Read content of symbolic link. | |
bool | fa_remove (const std::string &path) |
Remove file system object. | |
bool | fa_unlink (const std::string &path) |
Remove file. | |
bool | fa_rmdir (const std::string &path) |
Remove directory (if empty). | |
bool | fa_rmdirr (const std::string &path) |
Remove directory recursively. | |
bool | fa_opendir (const std::string &path) |
Open directory. Only one directory may be open at a time. | |
bool | fa_closedir (void) |
Close open directory. | |
bool | fa_readdir (std::string &name) |
Read relative name of object in open directory. | |
bool | fa_open (const std::string &path, int flags, mode_t mode) |
Open file. Only one file may be open at a time. | |
bool | fa_close (void) |
Close open file. | |
bool | fa_mkstemp (std::string &path, mode_t mode) |
Open new temporary file for writing. More... | |
off_t | fa_lseek (off_t offset, int whence) |
Change current position in open file. | |
ssize_t | fa_read (void *buf, size_t size) |
Read from open file. | |
ssize_t | fa_write (const void *buf, size_t size) |
Write to open file. | |
ssize_t | fa_pread (void *buf, size_t size, off_t offset) |
Read from open file at specified offset. | |
ssize_t | fa_pwrite (const void *buf, size_t size, off_t offset) |
Write to open file at specified offset. | |
int | geterrno () |
Get errno of last operation. Every operation resets errno. | |
operator bool (void) | |
Returns true if this instance is in useful condition. | |
bool | operator! (void) |
Returns true if this instance is not in useful condition. | |
Static Public Member Functions | |
static FileAccess * | Acquire (void) |
Constructor which takes already existing object from global cache. | |
static void | Release (FileAccess *fa) |
Destructor which returns object into global cache. | |
static void | testtune (void) |
Special method for using in unit tests. | |
Defines interface for accessing filesystems.
This class accesses the local filesystem through a proxy executable which allows switching user id in multithreaded systems without introducing conflict with other threads. Its methods are mostly replicas of corresponding POSIX functions with some convenience tweaking.
bool Arc::FileAccess::fa_copy | ( | const std::string & | oldpath, |
const std::string & | newpath, | ||
mode_t | mode | ||
) |
Copy file to new location.
If new file is created it is assigned specified mode.
bool Arc::FileAccess::fa_mkdirp | ( | const std::string & | path, |
mode_t | mode | ||
) |
Make a directory and assign it specified mode.
If missing all intermediate directories are created too.
bool Arc::FileAccess::fa_mkstemp | ( | std::string & | path, |
mode_t | mode | ||
) |
Open new temporary file for writing.
On input path contains template of file name ending with XXXXXX. On output path is path to created file.
bool Arc::FileAccess::fa_setuid | ( | int | uid, |
int | gid | ||
) |
Modify user uid and gid.
If any is set to 0 then executable is switched to original uid/gid.