1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
// **********************************************************************
//
// Copyright (c) 2003-2006 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
#include <IceUtil/DisableWarnings.h>
#include <OS.h>
#include <IceUtil/Unicode.h>
using namespace std;
using namespace OS;
#ifdef _WIN32
int
OS::osstat(const string& path, structstat* buf)
{
return ::_wstat(IceUtil::stringToWstring(path).c_str(), buf);
}
int
OS::remove(const string& path)
{
return ::_wremove(IceUtil::stringToWstring(path).c_str());
}
int
OS::rename(const string& from, const string& to)
{
return ::_wrename(IceUtil::stringToWstring(from).c_str(), IceUtil::stringToWstring(to).c_str());
}
int
OS::rmdir(const string& path)
{
return ::_wrmdir(IceUtil::stringToWstring(path).c_str());
}
int
OS::mkdir(const string& path, int)
{
return ::_wmkdir(IceUtil::stringToWstring(path).c_str());
}
FILE*
OS::fopen(const string& path, const string& mode)
{
return ::_wfopen(IceUtil::stringToWstring(path).c_str(), IceUtil::stringToWstring(mode).c_str());
}
int
OS::open(const string& path, int flags)
{
return ::_wopen(IceUtil::stringToWstring(path).c_str(), flags);
}
int
OS::getcwd(string& cwd)
{
wchar_t cwdbuf[_MAX_PATH];
if(_wgetcwd(cwdbuf, _MAX_PATH) == NULL)
{
return -1;
}
cwd = IceUtil::wstringToString(cwdbuf);
return 0;
}
#else
int
OS::osstat(const string& path, structstat* buf)
{
return ::stat(path.c_str(), buf);
}
int
OS::remove(const string& path)
{
return ::remove(path.c_str());
}
int
OS::rename(const string& from, const string& to)
{
return ::rename(from.c_str(), to.c_str());
}
int
OS::rmdir(const string& path)
{
return ::rmdir(path.c_str());
}
int
OS::mkdir(const string& path, int perm)
{
return ::mkdir(path.c_str(), perm);
}
FILE*
OS::fopen(const string& path, const string& mode)
{
return ::fopen(path.c_str(), mode.c_str());
}
int
OS::open(const string& path, int flags)
{
return ::open(path.c_str(), flags);
}
int
OS::getcwd(string& cwd)
{
char cwdbuf[PATH_MAX];
if(::getcwd(cwdbuf, PATH_MAX) == NULL)
{
return -1;
}
cwd = cwdbuf;
return 0;
}
#endif
|