PUMA Library Reference Manual
Loading...
Searching...
No Matches
Puma::SysCall Class Reference

#include <Puma/SysCall.h>

Description

Encapsulates system dependent file system operations.

Static Public Member Functions

static const char * mktemp (const char *prefix, ErrorSink *err=(ErrorSink *) 0)
 Create a temporary file name, needs to be freed by the caller. More...
 
static int open_excl (const char *path, int flags, ErrorSink *err=(ErrorSink *) 0)
 Open a file in exclusive file locking mode. More...
 
static int create_excl (const char *path, int mode, ErrorSink *err=(ErrorSink *) 0)
 Create and open a file in exclusive file locking mode. More...
 
static bool close_excl (int fd, ErrorSink *err=(ErrorSink *) 0)
 Close a file opened in exclusive file locking mode. More...
 
static int open (const char *path, int flags, ErrorSink *err=(ErrorSink *) 0)
 Open a file in non-exclusive mode. More...
 
static int create (const char *path, int mode, ErrorSink *err=(ErrorSink *) 0)
 Create and open a file in non-exclusive mode. More...
 
static bool close (int fd, ErrorSink *err=(ErrorSink *) 0)
 Close a file opened in non-exclusive mode. More...
 
static long read (int fd, void *buffer, size_t n, ErrorSink *err=(ErrorSink *) 0)
 Read n bytes from a file into the given buffer. More...
 
static bool stat (const char *path, FileInfo &info, ErrorSink *err=(ErrorSink *) 0)
 Get information about a file. More...
 
static bool fstat (int fd, FileInfo &info, ErrorSink *err=(ErrorSink *) 0)
 Get information about a file. More...
 
static char * readlink (const char *path, char *buffer, size_t len, ErrorSink *err=(ErrorSink *) 0)
 Get the path to the file the given link points to. More...
 
static FileHandle fopen (const char *path, const char *mode, ErrorSink *err=(ErrorSink *) 0)
 Open a file stream. More...
 
static bool fclose (FileHandle fh, ErrorSink *err=(ErrorSink *) 0)
 Close a file stream. More...
 
static DirHandle opendir (const char *path, ErrorSink *err=(ErrorSink *) 0)
 Open a directory stream. More...
 
static bool closedir (DirHandle dh, ErrorSink *err=(ErrorSink *) 0)
 Close a directory stream. More...
 
static const char * readdir (DirHandle dh, DirEntryType *type=0, ErrorSink *err=(ErrorSink *) 0)
 
static bool chdir (const char *path, ErrorSink *err=(ErrorSink *) 0)
 Change the current working directory. More...
 
static bool mkdir (const char *path, ErrorSink *err=(ErrorSink *) 0)
 Create a directory. More...
 
static char * getcwd (char *buffer, size_t len, ErrorSink *err=(ErrorSink *) 0)
 Get the current working directory. More...
 
static time_t time (time_t *buffer, ErrorSink *err=(ErrorSink *) 0)
 Get the current time. More...
 
static void MakeUnixPath (char *path)
 Transform the given path into a Unix path by replacing all backslashes with slashes. More...
 
static void MakeDosPath (char *path)
 Transform the given path into a MS-DOS path by replacing all slashes with backslashes. More...
 
static bool canonical (Filename filename, Filename &result, ErrorSink *err=0)
 Get the canonical path name for an existing file. More...
 
static char * absolute (const char *filename, ErrorSink *err=(ErrorSink *) 0)
 Get the absolute path name for an existing file. More...
 

Member Function Documentation

◆ absolute()

static char * Puma::SysCall::absolute ( const char *  filename,
ErrorSink err = (ErrorSink *) 0 
)
static

Get the absolute path name for an existing file.

Parameters
filenameThe filename of the file.
errOptional error reporting stream.
Returns
A newly allocated string containing the absolute path name.

◆ canonical()

static bool Puma::SysCall::canonical ( Filename  filename,
Filename result,
ErrorSink err = 0 
)
static

Get the canonical path name for an existing file.

Parameters
filenameThe filename of the file.
resultThe resulting canonical path name.
errOptional error reporting stream.
Returns
True if succeeded.

◆ chdir()

static bool Puma::SysCall::chdir ( const char *  path,
ErrorSink err = (ErrorSink *) 0 
)
static

Change the current working directory.

Parameters
pathThe path to the new working directory.
errOptional error reporting stream.
Returns
True if succeeded.

◆ close()

static bool Puma::SysCall::close ( int  fd,
ErrorSink err = (ErrorSink *) 0 
)
static

Close a file opened in non-exclusive mode.

Parameters
fdThe file descriptor of the file to close.
errOptional error reporting stream.
Returns
True if closing the file succeeded.

◆ close_excl()

static bool Puma::SysCall::close_excl ( int  fd,
ErrorSink err = (ErrorSink *) 0 
)
static

Close a file opened in exclusive file locking mode.

Parameters
fdThe file descriptor of the file to close.
errOptional error reporting stream.
Returns
True if closing the file succeeded.

◆ closedir()

static bool Puma::SysCall::closedir ( DirHandle  dh,
ErrorSink err = (ErrorSink *) 0 
)
static

Close a directory stream.

Parameters
dhThe handle to the directory stream.
errOptional error reporting stream.
Returns
True if succeeded.

◆ create()

static int Puma::SysCall::create ( const char *  path,
int  mode,
ErrorSink err = (ErrorSink *) 0 
)
static

Create and open a file in non-exclusive mode.

Parameters
pathThe path to the file.
modeThe file creation mode.
errOptional error reporting stream.
Returns
The file descriptor of the opened file.

◆ create_excl()

static int Puma::SysCall::create_excl ( const char *  path,
int  mode,
ErrorSink err = (ErrorSink *) 0 
)
static

Create and open a file in exclusive file locking mode.

Parameters
pathThe path to the file.
modeThe file creation mode.
errOptional error reporting stream.
Returns
The file descriptor of the opened file.

◆ fclose()

static bool Puma::SysCall::fclose ( FileHandle  fh,
ErrorSink err = (ErrorSink *) 0 
)
static

Close a file stream.

Parameters
fhThe handle to the file stream.
errOptional error reporting stream.
Returns
True if succeeded.

◆ fopen()

static FileHandle Puma::SysCall::fopen ( const char *  path,
const char *  mode,
ErrorSink err = (ErrorSink *) 0 
)
static

Open a file stream.

Parameters
pathThe path to the file to open.
modeThe file open mode.
errOptional error reporting stream.
Returns
A handle to the file stream.

◆ fstat()

static bool Puma::SysCall::fstat ( int  fd,
FileInfo info,
ErrorSink err = (ErrorSink *) 0 
)
static

Get information about a file.

Parameters
fdThe file descriptor of the file.
infoThe file information object to fill.
errOptional error reporting stream.
Returns
True if succeeded.

◆ getcwd()

static char * Puma::SysCall::getcwd ( char *  buffer,
size_t  len,
ErrorSink err = (ErrorSink *) 0 
)
static

Get the current working directory.

Parameters
bufferA buffer to be filled with the path to the current working directory.
lenThe size of the buffer.
errOptional error reporting stream.
Returns
The buffer containing the path to the current working directory.

◆ MakeDosPath()

static void Puma::SysCall::MakeDosPath ( char *  path)
static

Transform the given path into a MS-DOS path by replacing all slashes with backslashes.

Parameters
pathThe path to transform.

◆ MakeUnixPath()

static void Puma::SysCall::MakeUnixPath ( char *  path)
static

Transform the given path into a Unix path by replacing all backslashes with slashes.

Parameters
pathThe path to transform.

◆ mkdir()

static bool Puma::SysCall::mkdir ( const char *  path,
ErrorSink err = (ErrorSink *) 0 
)
static

Create a directory.

Parameters
pathThe path to the new directory.
errOptional error reporting stream.
Returns
True if succeeded.

◆ mktemp()

static const char * Puma::SysCall::mktemp ( const char *  prefix,
ErrorSink err = (ErrorSink *) 0 
)
static

Create a temporary file name, needs to be freed by the caller.

Parameters
prefixThe file name prefix.
errOptional error reporting stream.

◆ open()

static int Puma::SysCall::open ( const char *  path,
int  flags,
ErrorSink err = (ErrorSink *) 0 
)
static

Open a file in non-exclusive mode.

Parameters
pathThe path to the file.
flagsThe file open flags.
errOptional error reporting stream.
Returns
The file descriptor of the opened file.

◆ open_excl()

static int Puma::SysCall::open_excl ( const char *  path,
int  flags,
ErrorSink err = (ErrorSink *) 0 
)
static

Open a file in exclusive file locking mode.

Parameters
pathThe path to the file.
flagsThe file open flags.
errOptional error reporting stream.
Returns
The file descriptor of the opened file.

◆ opendir()

static DirHandle Puma::SysCall::opendir ( const char *  path,
ErrorSink err = (ErrorSink *) 0 
)
static

Open a directory stream.

Parameters
pathThe path to the directory to open.
errOptional error reporting stream.
Returns
A handle to the directory stream.

◆ read()

static long Puma::SysCall::read ( int  fd,
void *  buffer,
size_t  n,
ErrorSink err = (ErrorSink *) 0 
)
static

Read n bytes from a file into the given buffer.

Parameters
fdThe file descriptor of the file to read.
bufferThe buffer to fill with the bytes read.
nThe number of bytes to read.
errOptional error reporting stream.
Returns
The number of bytes read.

◆ readdir()

static const char * Puma::SysCall::readdir ( DirHandle  dh,
DirEntryType type = 0,
ErrorSink err = (ErrorSink *) 0 
)
static

◆ readlink()

static char * Puma::SysCall::readlink ( const char *  path,
char *  buffer,
size_t  len,
ErrorSink err = (ErrorSink *) 0 
)
static

Get the path to the file the given link points to.

Parameters
pathThe path to the link.
bufferThe buffer to fill with the result.
lenThe size of the buffer.
errOptional error reporting stream.
Returns
The buffer containing the path to the linked file.

◆ stat()

static bool Puma::SysCall::stat ( const char *  path,
FileInfo info,
ErrorSink err = (ErrorSink *) 0 
)
static

Get information about a file.

Parameters
pathThe path to the file.
infoThe file information object to fill.
errOptional error reporting stream.
Returns
True if succeeded.

◆ time()

static time_t Puma::SysCall::time ( time_t *  buffer,
ErrorSink err = (ErrorSink *) 0 
)
static

Get the current time.

Parameters
bufferThe buffer to be filled with the current time.
errOptional error reporting stream.
Returns
The current time, or -1 in case of error.