2001-05-17 15:11:01 +00:00
|
|
|
// os.h copyright "Ruurd A. Reitsma" <R.A.Reitsma@wbmt.tudelft.nl>
|
|
|
|
|
|
|
|
#ifndef OS_H
|
|
|
|
#define OS_H
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "LString.h"
|
|
|
|
|
|
|
|
/// Do we need a base class for this?
|
|
|
|
class os {
|
|
|
|
public:
|
|
|
|
//
|
|
|
|
enum shell_type {
|
|
|
|
UNIX, // Do we have to distinguish sh and csh?
|
|
|
|
CMD_EXE
|
|
|
|
};
|
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
//
|
2001-05-17 15:11:01 +00:00
|
|
|
static void init(int * argc, char ** argv[]);
|
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
//
|
2001-10-23 08:44:03 +00:00
|
|
|
static string binpath() {return binpath_;}
|
2001-05-17 15:11:01 +00:00
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
//
|
2001-10-23 08:44:03 +00:00
|
|
|
static string binname() {return binname_;}
|
2001-05-17 15:11:01 +00:00
|
|
|
|
|
|
|
// system_tempdir actually doesn't belong here.
|
|
|
|
// I put it here only to avoid a global variable.
|
2001-10-23 08:44:03 +00:00
|
|
|
static void setTmpDir(string p) {tmpdir_ = p;}
|
2001-05-17 15:11:01 +00:00
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
//
|
2001-10-23 08:44:03 +00:00
|
|
|
static string getTmpDir() {return tmpdir_;}
|
2001-05-17 15:11:01 +00:00
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
//
|
2001-05-17 15:11:01 +00:00
|
|
|
static string current_root();
|
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
//
|
2001-10-23 08:44:03 +00:00
|
|
|
static os::shell_type shell() {return _shell;}
|
2001-05-17 15:11:01 +00:00
|
|
|
|
|
|
|
// DBCS aware!
|
2001-10-08 14:09:06 +00:00
|
|
|
static string::size_type common_path(string const &p1,
|
|
|
|
string const &p2);
|
2001-05-17 15:11:01 +00:00
|
|
|
|
|
|
|
// no-op on UNIX, '\\'->'/' on OS/2 and Win32, ':'->'/' on MacOS, etc.
|
|
|
|
static string slashify_path(string p);
|
2001-10-04 09:57:02 +00:00
|
|
|
// converts a host OS path to unix style
|
2001-10-08 14:09:06 +00:00
|
|
|
static string external_path(string const &p);
|
2001-10-04 09:57:02 +00:00
|
|
|
// converts a unix path to host OS style
|
2001-10-08 14:09:06 +00:00
|
|
|
static string internal_path(string const &p);
|
|
|
|
// is path absolute?
|
|
|
|
static bool is_absolute_path(string const & p);
|
2002-02-08 14:32:17 +00:00
|
|
|
// returns a string suitable to be passed to fopen/popen when
|
|
|
|
// reading a file
|
|
|
|
static char const * read_mode();
|
2001-10-08 14:09:06 +00:00
|
|
|
//
|
2001-05-17 15:11:01 +00:00
|
|
|
static void warn(string mesg);
|
|
|
|
private:
|
|
|
|
static string binpath_;
|
|
|
|
static string binname_;
|
|
|
|
static string tmpdir_;
|
|
|
|
static os::shell_type _shell;
|
2001-10-04 09:57:02 +00:00
|
|
|
// Used only on OS/2 to determine file system encoding.
|
2002-03-21 17:09:55 +00:00
|
|
|
static unsigned long cp_;
|
2001-05-17 15:11:01 +00:00
|
|
|
|
|
|
|
// Never initialize static variables in the header!
|
|
|
|
// Anyway I bet this class will never be constructed.
|
|
|
|
os() {};
|
|
|
|
|
|
|
|
// Ignore warning!
|
|
|
|
~os() {};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|