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 
Definition: CString.h:17
Definition: Pair.h:33
Definition: InStream.h:29
Definition: OutStream.h:30
Definition: RandomAccessStream.h:34
Definition: Path.h:162
Definition: Path.h:33
Definition: System.h:39
static unsigned int random(unsigned int top)
Definition: system_System.cpp:259
static io::OutStream * appendFile(const Path &path)
Definition: system_System.cpp:346
static void makeDirs(const sys::Path &path)
static string getPluginFileName(const string &name)
static cstring library_prefix
Definition: System.h:56
static cstring getEnv(cstring key)
static string getLibraryFileName(const string &name)
static const int READ
Definition: System.h:42
int access_t
Definition: System.h:41
static int coreCount(void)
static bool hasEnv(cstring key)
static Path::DirReader contentOf(const sys::Path &dir)
static io::RandomAccessStream * openRandomFile(const Path &path, access_t access=READ)
Definition: system_System.cpp:465
static void exit(int code=0)
static void makeDir(const sys::Path &path)
static Pair< SystemInStream *, SystemOutStream * > pipe(void)
Definition: system_System.cpp:206
static const int READ_WRITE
Definition: System.h:44
static sys::Path getTempDir(void)
static sys::Path getTempFile(void)
static const int WRITE
Definition: System.h:43
static io::OutStream * createFile(const Path &path)
Definition: system_System.cpp:278
static io::InStream * readFile(const Path &path)
Definition: system_System.cpp:311
static io::RandomAccessStream * createRandomFile(const Path &path, access_t access=READ)
Definition: system_System.cpp:489
static Path getUnitPath(void *address)
Definition: system_System.cpp:517
static cstring exec_suffix
Definition: System.h:56
static cstring library_suffix
Definition: System.h:56
static void removeDir(const sys::Path &path)
static void remove(const Path &path)
static void removeFile(const Path &path)
Definition: adapter.h:26