ARC SDK
Data Structures | Public Member Functions | Static Public Member Functions
Arc::FileAccess Class Reference

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 FileAccessAcquire (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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ FileAccess()

Arc::FileAccess::FileAccess ( void  )

New FileAccess object.

◆ ~FileAccess()

Arc::FileAccess::~FileAccess ( void  )

Shuts down any spawned executable.

Member Function Documentation

◆ Acquire()

static FileAccess* Arc::FileAccess::Acquire ( void  )
static

Constructor which takes already existing object from global cache.

◆ fa_chmod()

bool Arc::FileAccess::fa_chmod ( const std::string &  path,
mode_t  mode 
)

Change mode of filesystem object.

Since
Renamed in 3.0.0 from chmod

◆ fa_close()

bool Arc::FileAccess::fa_close ( void  )

Close open file.

Since
Renamed in 3.0.0 from close

◆ fa_closedir()

bool Arc::FileAccess::fa_closedir ( void  )

Close open directory.

Since
Renamed in 3.0.0 from closedir

◆ fa_copy()

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.

Since
Renamed in 3.0.0 from copy

◆ fa_fallocate()

off_t Arc::FileAccess::fa_fallocate ( off_t  length)

Allocate disk space for open file.

Since
Renamed in 3.0.0 from fallocate

◆ fa_fstat()

bool Arc::FileAccess::fa_fstat ( struct stat &  st)

Stat open file.

Since
Renamed in 3.0.0 from fstat

◆ fa_ftruncate()

bool Arc::FileAccess::fa_ftruncate ( off_t  length)

Truncate open file.

Since
Renamed in 3.0.0 from ftruncate

◆ fa_link()

bool Arc::FileAccess::fa_link ( const std::string &  oldpath,
const std::string &  newpath 
)

Create hard link.

Since
Renamed in 3.0.0 from link

◆ fa_lseek()

off_t Arc::FileAccess::fa_lseek ( off_t  offset,
int  whence 
)

Change current position in open file.

Since
Renamed in 3.0.0 from lseek

◆ fa_lstat()

bool Arc::FileAccess::fa_lstat ( const std::string &  path,
struct stat &  st 
)

Stat symbolic link or file.

Since
Renamed in 3.0.0 from lstat

◆ fa_mkdir()

bool Arc::FileAccess::fa_mkdir ( const std::string &  path,
mode_t  mode 
)

Make a directory and assign it specified mode.

Since
Renamed in 3.0.0 from mkdir

◆ fa_mkdirp()

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.

Since
Renamed in 3.0.0 from mkdirp

◆ fa_mkstemp()

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.

Since
Renamed in 3.0.0 from mkstemp

◆ fa_open()

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.

Since
Renamed in 3.0.0 from open

◆ fa_opendir()

bool Arc::FileAccess::fa_opendir ( const std::string &  path)

Open directory.

Only one directory may be open at a time.

Since
Renamed in 3.0.0 from opendir

◆ fa_pread()

ssize_t Arc::FileAccess::fa_pread ( void *  buf,
size_t  size,
off_t  offset 
)

Read from open file at specified offset.

Since
Renamed in 3.0.0 from pread

◆ fa_pwrite()

ssize_t Arc::FileAccess::fa_pwrite ( const void *  buf,
size_t  size,
off_t  offset 
)

Write to open file at specified offset.

Since
Renamed in 3.0.0 from pwrite

◆ fa_read()

ssize_t Arc::FileAccess::fa_read ( void *  buf,
size_t  size 
)

Read from open file.

Since
Renamed in 3.0.0 from read

◆ fa_readdir()

bool Arc::FileAccess::fa_readdir ( std::string &  name)

Read relative name of object in open directory.

Since
Renamed in 3.0.0 from readdir

◆ fa_readlink()

bool Arc::FileAccess::fa_readlink ( const std::string &  path,
std::string &  linkpath 
)

Read content of symbolic link.

Since
Renamed in 3.0.0 from readlink

◆ fa_remove()

bool Arc::FileAccess::fa_remove ( const std::string &  path)

Remove file system object.

Since
Renamed in 3.0.0 from remove

◆ fa_rename()

bool Arc::FileAccess::fa_rename ( const std::string &  oldpath,
const std::string &  newpath 
)

Rename file.

Since
Renamed in 3.0.0 from rename

◆ fa_rmdir()

bool Arc::FileAccess::fa_rmdir ( const std::string &  path)

Remove directory (if empty).

Since
Renamed in 3.0.0 from rmdir

◆ fa_rmdirr()

bool Arc::FileAccess::fa_rmdirr ( const std::string &  path)

Remove directory recursively.

Since
Renamed in 3.0.0 from rmdirr

◆ fa_setuid()

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.

Since
Renamed in 3.0.0 from setuid

◆ fa_softlink()

bool Arc::FileAccess::fa_softlink ( const std::string &  oldpath,
const std::string &  newpath 
)

Create symbolic (aka soft) link.

Since
Renamed in 3.0.0 form softlink

◆ fa_stat()

bool Arc::FileAccess::fa_stat ( const std::string &  path,
struct stat &  st 
)

Stat file.

Since
Renamed in 3.0.0 from stat

◆ fa_unlink()

bool Arc::FileAccess::fa_unlink ( const std::string &  path)

Remove file.

Since
Renamed in 3.0.0 from unlink

◆ fa_write()

ssize_t Arc::FileAccess::fa_write ( const void *  buf,
size_t  size 
)

Write to open file.

Since
Renamed in 3.0.0 from write

◆ geterrno()

int Arc::FileAccess::geterrno ( )
inline

Get errno of last operation. Every operation resets errno.

◆ operator bool()

Arc::FileAccess::operator bool ( void  )
inline

Returns true if this instance is in useful condition.

◆ operator!()

bool Arc::FileAccess::operator! ( void  )
inline

Returns true if this instance is not in useful condition.

◆ ping()

bool Arc::FileAccess::ping ( void  )

Check if communication with proxy works.

◆ Release()

static void Arc::FileAccess::Release ( FileAccess fa)
static

Destructor which returns object into global cache.

◆ testtune()

static void Arc::FileAccess::testtune ( void  )
static

Special method for using in unit tests.


The documentation for this class was generated from the following file: