Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
System Class Reference

#include <elm/sys/System.h>

Public Types

typedef int access_t
 

Static Public Member Functions

static Pair< SystemInStream *, SystemOutStream * > pipe (void)
 
static unsigned int random (unsigned int top)
 
static io::OutStreamcreateFile (const Path &path)
 
static io::OutStreamappendFile (const Path &path)
 
static io::InStreamreadFile (const Path &path)
 
static io::RandomAccessStreamopenRandomFile (const Path &path, access_t access=READ)
 
static io::RandomAccessStreamcreateRandomFile (const Path &path, access_t access=READ)
 
static Path getUnitPath (void *address)
 
static cstring getEnv (cstring key)
 
static bool hasEnv (cstring key)
 
static string getLibraryFileName (const string &name)
 
static string getPluginFileName (const string &name)
 
static void makeDir (const sys::Path &path)
 
static void makeDirs (const sys::Path &path)
 
static void removeDir (const sys::Path &path)
 
static void removeFile (const Path &path)
 
static void remove (const Path &path)
 
static sys::Path getTempFile (void)
 
static sys::Path getTempDir (void)
 
static int coreCount (void)
 
static void exit (int code=0)
 
static Path::DirReader contentOf (const sys::Path &dir)
 

Static Public Attributes

static const int READ = 1
 
static const int WRITE = 2
 
static const int READ_WRITE = READ | WRITE
 
static cstring library_prefix = "lib"
 
static cstring library_suffix
 
static cstring exec_suffix
 

Detailed Description

Non-instatiable object giving access to system facilities.

Member Typedef Documentation

◆ access_t

typedef int access_t

Member Function Documentation

◆ appendFile()

io::OutStream * appendFile ( const Path path)
static

Open a file for appending write. The opened file must be fried by the caller (causing the closure).

Parameters
pathPath of the file to open.
Returns
Opened file.
Exceptions
SystemExceptionThrown if there is an error.

References Path::asSysString().

Referenced by Path::append().

◆ contentOf()

static Path::DirReader contentOf ( const sys::Path dir)
static

◆ coreCount()

static int coreCount ( void  )
static

◆ createFile()

io::OutStream * createFile ( const Path path)
static

Create a new file and open it to write. The created file must be fried by the caller (causing the file closure).

Parameters
pathPath of the file to open.
Returns
Opened file.
Exceptions
SystemExceptionThrown if there is an error.

References Path::asSysString().

Referenced by Saver::Saver(), and Path::write().

◆ createRandomFile()

io::RandomAccessStream * createRandomFile ( const Path path,
access_t  access = READ 
)
static

Create a random access stream from a file, removing it if it already exists.

Parameters
pathPath of the file to open.
accessType of access (one of READ, WRITE, READ_WRITE).
Returns
Opened file.
Exceptions
IOExceptionThrown if there is an error.

References elm::_, Path::asSysString(), and System::READ.

Referenced by RandomAccessStream::createFile().

◆ exit()

static void exit ( int  code = 0)
static

◆ getEnv()

static cstring getEnv ( cstring  key)
static

◆ getLibraryFileName()

static string getLibraryFileName ( const string name)
static

◆ getPluginFileName()

static string getPluginFileName ( const string name)
static

◆ getTempDir()

static sys::Path getTempDir ( void  )
static

◆ getTempFile()

static sys::Path getTempFile ( void  )
static

◆ getUnitPath()

Path getUnitPath ( void address)
static

Get the path of the object item (library, program) containing the symbol whose address is given.

Parameters
addressAddress of the looked symbol.
Returns
Path to the object containing the symbol or an empty path if it can not be found. @notice This method gives a usable result only when the GLIBC is used. Be careful: it may be hard to get object path of an external symbol due to relocation function stub and due to duplication of some small data.

References Path::canonical(), and elm::mod().

◆ hasEnv()

static bool hasEnv ( cstring  key)
static

◆ makeDir()

static void makeDir ( const sys::Path path)
static

Referenced by Path::makeDir(), and Path::temp().

◆ makeDirs()

static void makeDirs ( const sys::Path path)
static

Referenced by Path::makeDirs().

◆ openRandomFile()

io::RandomAccessStream * openRandomFile ( const Path path,
access_t  access = READ 
)
static

Open a random access stream from a file.

Parameters
pathPath of the file to open.
accessType of access (one of READ, WRITE, READ_WRITE).
Returns
Opened file.
Exceptions
IOExceptionThrown if there is an error.

References elm::_, and Path::asSysString().

Referenced by RandomAccessStream::openFile().

◆ pipe()

Pair< SystemInStream *, SystemOutStream * > pipe ( void  )
static

Create a pipe with input / output end streams.

Returns
Linked streams.
Exceptions
Systemexception.

References elm::win::getErrorMessage(), and elm::pair().

◆ random()

unsigned int random ( unsigned int  top)
static

Generate an integer random number in interval [0, top[.

Parameters
topMaximum exclusive value.
Returns
Random number.

◆ readFile()

io::InStream * readFile ( const Path path)
static

Open a file for reading. The opened file must be fried by the caller (causing the closure).

Parameters
pathPath of the file to open.
Returns
Opened file.
Exceptions
SystemExceptionThrown if there is an error.

References Path::asSysString().

Referenced by File::load(), Parser::parse(), Plugger::plugFile(), and Path::read().

◆ remove()

static void remove ( const Path path)
static

Referenced by Path::remove().

◆ removeDir()

static void removeDir ( const sys::Path path)
static

◆ removeFile()

static void removeFile ( const Path path)
static

Member Data Documentation

◆ exec_suffix

cstring exec_suffix
static

◆ library_prefix

cstring library_prefix = "lib"
static

Prefix of the dynamic libraries of the current OS.

◆ library_suffix

cstring library_suffix
static

◆ READ

const int READ = 1
static

◆ READ_WRITE

const int READ_WRITE = READ | WRITE
static

◆ WRITE

const int WRITE = 2
static

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