source: trunk/src/kernel32/directory.cpp@ 1330

Last change on this file since 1330 was 1076, checked in by phaller, 26 years ago

Fix: source cleanup, introduction ov WIN32.DIR.SYSTEM and WIN32.DIR.WINDOWS as overrrides

File size: 8.0 KB
Line 
1/* $Id: directory.cpp,v 1.5 1999-09-28 01:17:01 phaller Exp $ */
2
3/*
4 * Win32 Directory functions for OS/2
5 *
6 * Copyright 1998 Sander van Leeuwen
7 *
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 */
12
13
14/*****************************************************************************
15 * Includes *
16 *****************************************************************************/
17
18#include <odin.h>
19#include <odinwrap.h>
20#include <os2win.h>
21#include <stdlib.h>
22#include <unicode.h>
23#include <heapstring.h>
24
25
26ODINDEBUGCHANNEL(KERNEL32-DIRECTORY)
27
28
29/*****************************************************************************
30 * Name : GetCurrentDirectoryA
31 * Purpose : query the current directory
32 * Parameters:
33 * Variables :
34 * Result :
35 * Remark :
36 * Status :
37 *
38 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
39 *****************************************************************************/
40
41ODINFUNCTION2(UINT, GetCurrentDirectoryA, UINT, nBufferLength,
42 LPSTR, lpBuffer)
43{
44 return O32_GetCurrentDirectory(nBufferLength, lpBuffer);
45}
46
47
48/*****************************************************************************
49 * Name : GetCurrentDirectoryW
50 * Purpose : query the current directory
51 * Parameters:
52 * Variables :
53 * Result :
54 * Remark :
55 * Status :
56 *
57 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
58 *****************************************************************************/
59
60ODINFUNCTION2(UINT, GetCurrentDirectoryW, UINT, nBufferLength,
61 LPWSTR, lpBuffer)
62{
63 char *asciidir = (char *)malloc(nBufferLength+1);
64 int rc;
65
66 rc = O32_GetCurrentDirectory(nBufferLength, asciidir);
67 if(rc != 0)
68 AsciiToUnicode(asciidir, lpBuffer);
69 free(asciidir);
70 return(rc);
71}
72
73
74/*****************************************************************************
75 * Name : SetCurrentDirectoryA
76 * Purpose :
77 * Parameters:
78 * Variables :
79 * Result :
80 * Remark :
81 * Status :
82 *
83 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
84 *****************************************************************************/
85
86ODINFUNCTION1(BOOL,SetCurrentDirectoryA,LPCSTR,lpPathName)
87{
88 return O32_SetCurrentDirectory((LPSTR)lpPathName);
89}
90
91
92/*****************************************************************************
93 * Name : SetCurrentDirectoryW
94 * Purpose :
95 * Parameters:
96 * Variables :
97 * Result :
98 * Remark :
99 * Status :
100 *
101 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
102 *****************************************************************************/
103
104ODINFUNCTION1(BOOL,SetCurrentDirectoryW,LPCWSTR,lpPathName)
105{
106 char *asciipath;
107 BOOL rc;
108
109 asciipath = UnicodeToAsciiString((LPWSTR)lpPathName);
110 rc = SetCurrentDirectoryA(asciipath);
111 FreeAsciiString(asciipath);
112 return(rc);
113}
114
115
116/*****************************************************************************
117 * Name : CreateDirectoryA
118 * Purpose :
119 * Parameters:
120 * Variables :
121 * Result :
122 * Remark :
123 * Status :
124 *
125 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
126 *****************************************************************************/
127
128ODINFUNCTION2(BOOL,CreateDirectoryA,LPCSTR, arg1,
129 PSECURITY_ATTRIBUTES,arg2)
130{
131 return O32_CreateDirectory(arg1, arg2);
132}
133
134
135/*****************************************************************************
136 * Name : CreateDirectoryW
137 * Purpose :
138 * Parameters:
139 * Variables :
140 * Result :
141 * Remark :
142 * Status :
143 *
144 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
145 *****************************************************************************/
146
147ODINFUNCTION2(BOOL,CreateDirectoryW,LPCWSTR, arg1,
148 PSECURITY_ATTRIBUTES,arg2)
149{
150 BOOL rc;
151 char *astring;
152
153 astring = UnicodeToAsciiString((LPWSTR)arg1);
154 rc = CreateDirectoryA(astring, arg2);
155 FreeAsciiString(astring);
156 return(rc);
157}
158
159
160/*****************************************************************************
161 * Name : GetSystemDirectoryA
162 * Purpose :
163 * Parameters:
164 * Variables :
165 * Result :
166 * Remark :
167 * Status :
168 *
169 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
170 *****************************************************************************/
171
172ODINFUNCTION2(UINT,GetSystemDirectoryA,LPSTR,arg1,
173 UINT, arg2)
174{
175 LPSTR lpstrEnv = getenv("WIN32.DIR.SYSTEM"); /* query environment */
176
177 if (lpstrEnv != NULL)
178 {
179 lstrcpynA(arg1, /* copy environment variable to buffer */
180 lpstrEnv,
181 arg2);
182 return (lstrlenA(arg1)); /* return number of copies bytes */
183 }
184 else
185 /* if no override by environment is available */
186 return O32_GetSystemDirectory(arg1, arg2);
187}
188
189
190/*****************************************************************************
191 * Name : GetSystemDirectoryW
192 * Purpose :
193 * Parameters:
194 * Variables :
195 * Result :
196 * Remark :
197 * Status :
198 *
199 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
200 *****************************************************************************/
201
202ODINFUNCTION2(UINT,GetSystemDirectoryW,LPWSTR,lpBuffer,
203 UINT, uSize)
204{
205 char *asciibuffer = (char *)malloc(uSize+1);
206 UINT rc;
207
208 rc = GetSystemDirectoryA(asciibuffer, uSize);
209 if(rc) AsciiToUnicode(asciibuffer, lpBuffer);
210 free(asciibuffer);
211 return(rc);
212}
213
214
215/*****************************************************************************
216 * Name : GetWindowsDirectoryA
217 * Purpose :
218 * Parameters:
219 * Variables :
220 * Result :
221 * Remark :
222 * Status :
223 *
224 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
225 *****************************************************************************/
226
227ODINFUNCTION2(UINT,GetWindowsDirectoryA,LPSTR,arg1,
228 UINT, arg2)
229{
230 LPSTR lpstrEnv = getenv("WIN32.DIR.WINDOWS"); /* query environment */
231
232 if (lpstrEnv != NULL)
233 {
234 lstrcpynA(arg1, /* copy environment variable to buffer */
235 lpstrEnv,
236 arg2);
237 return (lstrlenA(arg1)); /* return number of copies bytes */
238 }
239 else
240 /* if no override by environment is available */
241 return O32_GetWindowsDirectory(arg1,
242 arg2);
243}
244
245
246/*****************************************************************************
247 * Name : GetWindowsDirectoryW
248 * Purpose :
249 * Parameters:
250 * Variables :
251 * Result :
252 * Remark :
253 * Status :
254 *
255 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
256 *****************************************************************************/
257
258ODINFUNCTION2(UINT,GetWindowsDirectoryW,LPWSTR,lpBuffer,
259 UINT, uSize)
260{
261 char *asciibuffer = (char *)malloc(uSize+1);
262 UINT rc;
263
264 rc = GetWindowsDirectoryA(asciibuffer, uSize);
265 AsciiToUnicode(asciibuffer, lpBuffer);
266 free(asciibuffer);
267 return(rc);
268}
269
270
271/*****************************************************************************
272 * Name : RemoveDirectoryA
273 * Purpose :
274 * Parameters:
275 * Variables :
276 * Result :
277 * Remark :
278 * Status :
279 *
280 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
281 *****************************************************************************/
282
283ODINFUNCTION1(BOOL,RemoveDirectoryA,LPCSTR,arg1)
284{
285 return O32_RemoveDirectory(arg1);
286}
287
288
289/*****************************************************************************
290 * Name : RemoveDirectoryW
291 * Purpose :
292 * Parameters:
293 * Variables :
294 * Result :
295 * Remark :
296 * Status :
297 *
298 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
299 *****************************************************************************/
300
301ODINFUNCTION1(BOOL,RemoveDirectoryW,LPCWSTR,lpPathName)
302{
303 char *asciipath;
304 BOOL rc;
305
306 asciipath = UnicodeToAsciiString((LPWSTR)lpPathName);
307 rc = RemoveDirectoryA(asciipath);
308 FreeAsciiString(asciipath);
309 return(rc);
310}
311
Note: See TracBrowser for help on using the repository browser.