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

Last change on this file since 1370 was 1370, checked in by sandervl, 26 years ago

Odin ini changes

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