Revision 415, 0.9 kB
(checked in by smidl, 15 years ago)
|
compilation fixes by Karel Vrbensky
|
-
Property svn:eol-style set to
native
|
Line | |
---|
1 | // |
---|
2 | // C++ Implementation: osutils |
---|
3 | // |
---|
4 | // Description: |
---|
5 | // |
---|
6 | // |
---|
7 | // Author: smidl <smidl@utia.cas.cz>, (C) 2008 |
---|
8 | // |
---|
9 | // Copyright: See COPYING file that comes with this distribution |
---|
10 | // |
---|
11 | // |
---|
12 | |
---|
13 | #include "osutils.h" |
---|
14 | #include <iostream> |
---|
15 | |
---|
16 | #ifdef WIN32 |
---|
17 | #include <direct.h> |
---|
18 | #else |
---|
19 | #include <sys/types.h> |
---|
20 | #include <sys/stat.h> |
---|
21 | #endif |
---|
22 | |
---|
23 | #include <fcntl.h> |
---|
24 | #include <errno.h> |
---|
25 | |
---|
26 | |
---|
27 | void get_fname ( char* filename, string &dirname, string &f ) { |
---|
28 | #ifdef WIN32 |
---|
29 | sprintf ( filename, "%s\\%s", dirname.c_str(), f.c_str() ); |
---|
30 | #else |
---|
31 | sprintf ( filename, "%s/%s", dirname.c_str() , f.c_str() ); |
---|
32 | #endif |
---|
33 | } |
---|
34 | |
---|
35 | void makedir ( string &dirname, bool rewrite ) { |
---|
36 | #ifdef WIN32 |
---|
37 | if ( _mkdir ( dirname.c_str() ) == -1 ) // Create the directory |
---|
38 | #else |
---|
39 | if ( mkdir ( dirname.c_str(), 00755 ) == -1 ) // Create the directory |
---|
40 | #endif |
---|
41 | { |
---|
42 | if ( ( rewrite ) && ( errno == EEXIST ) ) it_warning ( "rewriting directory" ); |
---|
43 | else it_error ( "dirfilelog:: cannot create directory" ); |
---|
44 | } |
---|
45 | } |
---|