Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
System.h
1 /*
2  * System class interface
3  *
4  * This file is part of OTAWA
5  * Copyright (c) 2006-12, IRIT UPS.
6  *
7  * OTAWA is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * OTAWA is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OTAWA; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 #ifndef ELM_SYS_SYSTEM_H
22 #define ELM_SYS_SYSTEM_H
23 
24 #include <elm/data/Vector.h>
25 #include <elm/sys/Path.h>
26 #include <elm/sys/SystemIO.h>
27 #include <elm/sys/SystemException.h>
28 #include <elm/util/Pair.h>
29 
30 namespace elm { namespace io {
31  class InStream;
32  class OutStream;
33  class RandomAccessStream;
34 } } // elm::io
35 
36 namespace elm { namespace sys {
37 
38 // System class
39 class System {
40 public:
41  typedef int access_t;
42  static const int READ = 1;
43  static const int WRITE = 2;
44  static const int READ_WRITE = READ | WRITE;
45 
47  static unsigned int random(unsigned int top);
48  static io::OutStream *createFile(const Path& path);
49  static io::OutStream *appendFile(const Path& path);
50  static io::InStream *readFile(const Path& path);
51  static io::RandomAccessStream *openRandomFile(const Path& path, access_t access = READ);
52  static io::RandomAccessStream *createRandomFile(const Path& path, access_t access = READ);
53  static Path getUnitPath(void *address);
54  static cstring getEnv(cstring key);
55  static bool hasEnv(cstring key);
57  static string getLibraryFileName(const string& name);
58  static string getPluginFileName(const string& name);
59  static void makeDir(const sys::Path& path);
60  static void makeDirs(const sys::Path& path);
61  static void removeDir(const sys::Path& path);
62  static void removeFile(const Path& path);
63  static void remove(const Path& path);
64  static sys::Path getTempFile(void);
65  static sys::Path getTempDir(void);
66  static int coreCount(void);
67  static void exit(int code = 0);
68  static Path::DirReader contentOf(const sys::Path& dir);
69 
70 };
71 
72 } } // elm::system
73 
74 #endif // ELM_SYS_SYSTEM_H
75 
elm::sys::System::WRITE
static const int WRITE
Definition: System.h:43
elm::sys::System::getTempFile
static sys::Path getTempFile(void)
elm::sys::System::remove
static void remove(const Path &path)
elm::sys::System::coreCount
static int coreCount(void)
elm::sys::Path
Definition: Path.h:33
elm::sys::System::random
static unsigned int random(unsigned int top)
Definition: system_System.cpp:259
elm::sys::System::openRandomFile
static io::RandomAccessStream * openRandomFile(const Path &path, access_t access=READ)
Definition: system_System.cpp:465
elm::sys::System
Definition: System.h:39
elm::sys::System::removeDir
static void removeDir(const sys::Path &path)
elm::sys::System::appendFile
static io::OutStream * appendFile(const Path &path)
Definition: system_System.cpp:346
elm::sys::System::readFile
static io::InStream * readFile(const Path &path)
Definition: system_System.cpp:311
elm::sys::Path::DirReader
Definition: Path.h:162
elm::sys::System::exit
static void exit(int code=0)
elm::sys::System::getUnitPath
static Path getUnitPath(void *address)
Definition: system_System.cpp:517
elm::Pair
Definition: Pair.h:33
elm::io::RandomAccessStream
Definition: RandomAccessStream.h:34
elm::sys::System::library_suffix
static cstring library_suffix
Definition: System.h:56
elm::CString
Definition: CString.h:17
elm::sys::System::createRandomFile
static io::RandomAccessStream * createRandomFile(const Path &path, access_t access=READ)
Definition: system_System.cpp:489
elm::sys::System::exec_suffix
static cstring exec_suffix
Definition: System.h:56
elm
Definition: adapter.h:26
elm::sys::System::getEnv
static cstring getEnv(cstring key)
elm::sys::System::getPluginFileName
static string getPluginFileName(const string &name)
elm::sys::System::makeDir
static void makeDir(const sys::Path &path)
elm::sys::System::createFile
static io::OutStream * createFile(const Path &path)
Definition: system_System.cpp:278
elm::sys::System::getLibraryFileName
static string getLibraryFileName(const string &name)
elm::io::OutStream
Definition: OutStream.h:30
elm::sys::System::removeFile
static void removeFile(const Path &path)
elm::sys::System::contentOf
static Path::DirReader contentOf(const sys::Path &dir)
elm::sys::System::makeDirs
static void makeDirs(const sys::Path &path)
elm::sys::System::access_t
int access_t
Definition: System.h:41
elm::sys::System::library_prefix
static cstring library_prefix
Definition: System.h:56
elm::sys::System::pipe
static Pair< SystemInStream *, SystemOutStream * > pipe(void)
Definition: system_System.cpp:206
elm::sys::System::hasEnv
static bool hasEnv(cstring key)
elm::sys::System::READ
static const int READ
Definition: System.h:42
elm::sys::System::getTempDir
static sys::Path getTempDir(void)
elm::sys::System::READ_WRITE
static const int READ_WRITE
Definition: System.h:44
elm::io::InStream
Definition: InStream.h:29