|
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. More... | |
| ~FileAccess (void) | |
| Shuts down any spawned executable. More... | |
| bool | ping (void) |
| Check if communication with proxy works. More... | |
| 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. More... | |
| 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. More... | |
| bool | fa_softlink (const std::string &oldpath, const std::string &newpath) |
| Create symbolic (aka soft) link. More... | |
| 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. More... | |
| bool | fa_chmod (const std::string &path, mode_t mode) |
| Change mode of filesystem object. More... | |
| bool | fa_stat (const std::string &path, struct stat &st) |
| Stat file. More... | |
| bool | fa_lstat (const std::string &path, struct stat &st) |
| Stat symbolic link or file. More... | |
| bool | fa_fstat (struct stat &st) |
| Stat open file. More... | |
| bool | fa_ftruncate (off_t length) |
| Truncate open file. More... | |
| off_t | fa_fallocate (off_t length) |
| Allocate disk space for open file. More... | |
| bool | fa_readlink (const std::string &path, std::string &linkpath) |
| Read content of symbolic link. More... | |
| bool | fa_remove (const std::string &path) |
| Remove file system object. More... | |
| bool | fa_unlink (const std::string &path) |
| Remove file. More... | |
| bool | fa_rmdir (const std::string &path) |
| Remove directory (if empty). More... | |
| bool | fa_rmdirr (const std::string &path) |
| Remove directory recursively. More... | |
| bool | fa_opendir (const std::string &path) |
| Open directory. More... | |
| bool | fa_closedir (void) |
| Close open directory. More... | |
| bool | fa_readdir (std::string &name) |
| Read relative name of object in open directory. More... | |
| bool | fa_open (const std::string &path, int flags, mode_t mode) |
| Open file. Only one file may be open at a time. More... | |
| bool | fa_close (void) |
| Close open file. More... | |
| 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. More... | |
| ssize_t | fa_read (void *buf, size_t size) |
| Read from open file. More... | |
| ssize_t | fa_write (const void *buf, size_t size) |
| Write to open file. More... | |
| ssize_t | fa_pread (void *buf, size_t size, off_t offset) |
| Read from open file at specified offset. More... | |
| ssize_t | fa_pwrite (const void *buf, size_t size, off_t offset) |
| Write to open file at specified offset. More... | |
| int | geterrno () |
| Get errno of last operation. Every operation resets errno. More... | |
| operator bool (void) | |
| Returns true if this instance is in useful condition. More... | |
| bool | operator! (void) |
| Returns true if this instance is not in useful condition. More... | |
Static Public Member Functions | |
| static FileAccess * | Acquire (void) |
| Constructor which takes already existing object from global cache. More... | |
| static void | Release (FileAccess *fa) |
| Destructor which returns object into global cache. More... | |
| static void | testtune (void) |
| Special method for using in unit tests. More... | |
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.
| Arc::FileAccess::FileAccess | ( | void | ) |
New FileAccess object.
| Arc::FileAccess::~FileAccess | ( | void | ) |
Shuts down any spawned executable.
|
static |
Constructor which takes already existing object from global cache.
| bool Arc::FileAccess::fa_chmod | ( | const std::string & | path, |
| mode_t | mode | ||
| ) |
Change mode of filesystem object.
| bool Arc::FileAccess::fa_close | ( | void | ) |
Close open file.
| bool Arc::FileAccess::fa_closedir | ( | void | ) |
Close open directory.
| 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.
| off_t Arc::FileAccess::fa_fallocate | ( | off_t | length | ) |
Allocate disk space for open file.
| bool Arc::FileAccess::fa_fstat | ( | struct stat & | st | ) |
Stat open file.
| bool Arc::FileAccess::fa_ftruncate | ( | off_t | length | ) |
Truncate open file.
| bool Arc::FileAccess::fa_link | ( | const std::string & | oldpath, |
| const std::string & | newpath | ||
| ) |
Create hard link.
| off_t Arc::FileAccess::fa_lseek | ( | off_t | offset, |
| int | whence | ||
| ) |
Change current position in open file.
| bool Arc::FileAccess::fa_lstat | ( | const std::string & | path, |
| struct stat & | st | ||
| ) |
Stat symbolic link or file.
| bool Arc::FileAccess::fa_mkdir | ( | const std::string & | path, |
| mode_t | mode | ||
| ) |
Make a directory and assign it 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_open | ( | const std::string & | path, |
| int | flags, | ||
| mode_t | mode | ||
| ) |
Open file. Only one file may be open at a time.
| bool Arc::FileAccess::fa_opendir | ( | const std::string & | path | ) |
Open directory.
Only one directory may be open at a time.
| ssize_t Arc::FileAccess::fa_pread | ( | void * | buf, |
| size_t | size, | ||
| off_t | offset | ||
| ) |
Read from open file at specified offset.
| ssize_t Arc::FileAccess::fa_pwrite | ( | const void * | buf, |
| size_t | size, | ||
| off_t | offset | ||
| ) |
Write to open file at specified offset.
| ssize_t Arc::FileAccess::fa_read | ( | void * | buf, |
| size_t | size | ||
| ) |
Read from open file.
| bool Arc::FileAccess::fa_readdir | ( | std::string & | name | ) |
Read relative name of object in open directory.
| bool Arc::FileAccess::fa_readlink | ( | const std::string & | path, |
| std::string & | linkpath | ||
| ) |
Read content of symbolic link.
| bool Arc::FileAccess::fa_remove | ( | const std::string & | path | ) |
Remove file system object.
| bool Arc::FileAccess::fa_rename | ( | const std::string & | oldpath, |
| const std::string & | newpath | ||
| ) |
Rename file.
| bool Arc::FileAccess::fa_rmdir | ( | const std::string & | path | ) |
Remove directory (if empty).
| bool Arc::FileAccess::fa_rmdirr | ( | const std::string & | path | ) |
Remove directory recursively.
| 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.
| bool Arc::FileAccess::fa_softlink | ( | const std::string & | oldpath, |
| const std::string & | newpath | ||
| ) |
Create symbolic (aka soft) link.
| bool Arc::FileAccess::fa_stat | ( | const std::string & | path, |
| struct stat & | st | ||
| ) |
Stat file.
| bool Arc::FileAccess::fa_unlink | ( | const std::string & | path | ) |
Remove file.
| ssize_t Arc::FileAccess::fa_write | ( | const void * | buf, |
| size_t | size | ||
| ) |
Write to open file.
|
inline |
Get errno of last operation. Every operation resets errno.
|
inline |
Returns true if this instance is in useful condition.
|
inline |
Returns true if this instance is not in useful condition.
| bool Arc::FileAccess::ping | ( | void | ) |
Check if communication with proxy works.
|
static |
Destructor which returns object into global cache.
|
static |
Special method for using in unit tests.
1.8.3.1-20130209