]> icculus.org git repositories - divverent/netradiant.git/blob - libs/cmdlib.h
Merge branch 'master' of ssh://git.xonotic.org/netradiant
[divverent/netradiant.git] / libs / cmdlib.h
1 /*
2 Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5 This file is part of GtkRadiant.
6
7 GtkRadiant 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 GtkRadiant 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 GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 */
21
22 //
23 // start of shared cmdlib stuff
24 // 
25
26 #ifndef __CMDLIB__
27 #define __CMDLIB__
28
29 #include <time.h>
30
31
32 // TTimo started adding portability code:
33 // return true if spawning was successful, false otherwise
34 // on win32 we have a bCreateConsole flag to create a new console or run inside the current one
35 //boolean Q_Exec(const char* pCmd, boolean bCreateConsole);
36 // execute a system command:
37 //   cmd: the command to run
38 //   cmdline: the command line
39 // NOTE TTimo following are win32 specific:
40 //   execdir: the directory to execute in
41 //   bCreateConsole: spawn a new console or not
42 // return values;
43 //   if the spawn was fine
44 //   TODO TTimo add functionality to track the process until it dies
45
46 bool Q_Exec(const char *cmd, char *cmdline, const char *execdir, bool bCreateConsole);
47
48 // some easy portability crap
49
50
51 #define access_owner_read 0400
52 #define access_owner_write 0200
53 #define access_owner_execute 0100
54 #define access_owner_rw_ 0600
55 #define access_owner_r_x 0500
56 #define access_owner__wx 0300
57 #define access_owner_rwx 0700
58
59 #define access_group_read 0040
60 #define access_group_write 0020
61 #define access_group_execute 0010
62 #define access_group_rw_ 0060
63 #define access_group_r_x 0050
64 #define access_group__wx 0030
65 #define access_group_rwx 0070
66
67 #define access_others_read 0004
68 #define access_others_write 0002
69 #define access_others_execute 0001
70 #define access_others_rw_ 0006
71 #define access_others_r_x 0005
72 #define access_others__wx 0003
73 #define access_others_rwx 0007
74
75
76 #define access_rwxrwxr_x (access_owner_rwx | access_group_rwx | access_others_r_x)
77 #define access_rwxrwxrwx (access_owner_rwx | access_group_rwx | access_others_rwx)
78
79 // Q_mkdir
80 // returns true if succeeded in creating directory
81 #ifdef WIN32
82 #include <direct.h>
83 inline bool Q_mkdir(const char* name)
84 {
85   return _mkdir(name) != -1; 
86 }
87 #else
88 #include <sys/stat.h>
89 inline bool Q_mkdir(const char* name)
90 {
91   return mkdir(name, access_rwxrwxr_x) != -1; 
92 }
93 #endif
94
95
96 inline double Sys_DoubleTime(void)
97 {
98   return clock()/ 1000.0;
99 }
100
101
102
103 #endif