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

Last change on this file since 7334 was 7334, checked in by phaller, 24 years ago

replaced heap alloc by stack alloc

File size: 22.7 KB
Line 
1/* $Id: directory.cpp,v 1.41 2001-11-14 12:30:30 phaller Exp $ */
2
3/*
4 * Win32 Directory functions for OS/2
5 *
6 * Copyright 1998 Sander van Leeuwen
7 *
8 * NOTE: Directory creation has to be done in install program (odin\win)
9 *
10 * Parts based on Wine code (991031) (files\directory.c)
11 *
12 * DOS directories functions
13 *
14 * Copyright 1995 Alexandre Julliard
15 *
16 * TODO:
17 * - System/window directories should be created by install program!
18 *
19 * Project Odin Software License can be found in LICENSE.TXT
20 *
21 */
22
23
24/*****************************************************************************
25 * Includes *
26 *****************************************************************************/
27
28#include <odin.h>
29#include <odinwrap.h>
30#include <os2win.h>
31#include <stdlib.h>
32#include <unicode.h>
33#include <heapstring.h>
34#include <options.h>
35#include "initterm.h"
36#include <win\file.h>
37#include <string.h>
38#include "oslibdos.h"
39#include "profile.h"
40#include "fileio.h"
41
42#define DBG_LOCALLOG DBG_directory
43#include "dbglocal.h"
44
45ODINDEBUGCHANNEL(KERNEL32-DIRECTORY)
46
47
48/*****************************************************************************
49 * Local Prototypes *
50 *****************************************************************************/
51
52
53static char DIR_Windows[MAX_PATHNAME_LEN];
54static char DIR_System[MAX_PATHNAME_LEN];
55static BOOL fDirInit = FALSE;
56
57//******************************************************************************
58//******************************************************************************
59char *InternalGetWindowsDirectoryA()
60{
61 return DIR_Windows;
62}
63//******************************************************************************
64//******************************************************************************
65char *InternalGetSystemDirectoryA()
66{
67 return DIR_System;
68}
69//******************************************************************************
70//******************************************************************************
71void InitDirectories()
72{
73 char *endofwinpath, *tmp;
74 int len;
75
76 if(fDirInit == TRUE) return;
77
78 fDirInit = TRUE;
79 strcpy(DIR_System, kernel32Path);
80 len = strlen(DIR_System);
81 if(DIR_System[len-1] == '\\') {
82 DIR_System[len-1] = 0;
83 }
84 len = PROFILE_GetOdinIniString(ODINDIRECTORIES,"WINDOWS","",DIR_Windows,sizeof(DIR_Windows));
85 if (len > 2) {
86 if(DIR_Windows[len-1] == '\\') {
87 DIR_Windows[len-1] = 0;
88 }
89 }
90 else {
91 strcpy(DIR_Windows, DIR_System);
92 endofwinpath = tmp = strchr(DIR_Windows, '\\');
93 while(tmp) {
94 tmp = strchr(endofwinpath+1, '\\');
95 if(tmp)
96 endofwinpath = tmp;
97 }
98 if(endofwinpath) {
99 *endofwinpath = 0; //remove \SYSTEM32
100 }
101 else DebugInt3();
102 }
103 dprintf(("Windows dir: %s", DIR_Windows));
104 dprintf(("System32 dir: %s", DIR_System));
105}
106//*****************************************************************************
107//*****************************************************************************
108void InitDirectoriesCustom(char *szSystemDir, char *szWindowsDir)
109{
110 int len;
111
112 if(fDirInit == TRUE) return;
113 fDirInit = TRUE;
114
115 strcpy(DIR_System, szSystemDir);
116 len = strlen(DIR_System);
117 if(DIR_System[len-1] == '\\') {
118 DIR_System[len-1] = 0;
119 }
120 strcpy(DIR_Windows, szWindowsDir);
121 len = strlen(DIR_Windows);
122 if(DIR_Windows[len-1] == '\\') {
123 DIR_Windows[len-1] = 0;
124 }
125
126 dprintf(("Windows dir: %s", DIR_Windows));
127 dprintf(("System32 dir: %s", DIR_System));
128}
129/*****************************************************************************
130 * Name : GetCurrentDirectoryA
131 * Purpose : query the current directory
132 * Parameters:
133 * Variables :
134 * Result :
135 * Remark : returned length is number of characters required or used for current dir
136 * *excluding* terminator
137 * Status :
138 *
139 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
140 *****************************************************************************/
141
142ODINFUNCTION2(UINT, GetCurrentDirectoryA, UINT, nBufferLength,
143 LPSTR, lpBuffer)
144{
145 UINT rc;
146
147 rc = OSLibDosQueryDir(nBufferLength, lpBuffer);
148 if(rc && rc < nBufferLength) {
149 dprintf(("CurrentDirectory = %s (%d)", lpBuffer, rc));
150 }
151 else dprintf(("CurrentDirectory returned %d", rc));
152 return rc;
153}
154
155
156/*****************************************************************************
157 * Name : GetCurrentDirectoryW
158 * Purpose : query the current directory
159 * Parameters:
160 * Variables :
161 * Result :
162 * Remark :
163 * Status :
164 *
165 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
166 *****************************************************************************/
167
168ODINFUNCTION2(UINT, GetCurrentDirectoryW, UINT, nBufferLength,
169 LPWSTR, lpBuffer)
170{
171 char *asciidir = (char *)malloc(nBufferLength+1);
172 int rc;
173
174 rc = CALL_ODINFUNC(GetCurrentDirectoryA)(nBufferLength, asciidir);
175 if(rc != 0)
176 AsciiToUnicode(asciidir, lpBuffer);
177 free(asciidir);
178 return(rc);
179}
180
181
182/*****************************************************************************
183 * Name : SetCurrentDirectoryA
184 * Purpose :
185 * Parameters:
186 * Variables :
187 * Result :
188 * Remark :
189 * Status :
190 *
191 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
192 *****************************************************************************/
193
194
195ODINFUNCTION1(BOOL, SetCurrentDirectoryA,
196 LPCSTR, lpstrDirectory)
197{
198 if(HIWORD(lpstrDirectory) == 0)
199 {
200 SetLastError(ERROR_INVALID_PARAMETER);
201 return FALSE;
202 }
203
204 // cut off trailing backslashes
205 // not if a process wants to change to the root directory
206 int len = lstrlenA(lpstrDirectory);
207 if ( ( (lpstrDirectory[len - 1] == '\\') ||
208 (lpstrDirectory[len - 1] == '/') ) &&
209 (len != 1) )
210 {
211 LPSTR lpTemp = (LPSTR)_alloca(len);
212 lstrcpynA(lpTemp,
213 lpstrDirectory,
214 len); // len is including trailing NULL!!
215 lpstrDirectory = lpTemp;
216 }
217
218 dprintf(("SetCurrentDirectoryA %s", lpstrDirectory));
219 return O32_SetCurrentDirectory((LPSTR)lpstrDirectory);
220}
221
222
223/*****************************************************************************
224 * Name : SetCurrentDirectoryW
225 * Purpose :
226 * Parameters:
227 * Variables :
228 * Result :
229 * Remark :
230 * Status :
231 *
232 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
233 *****************************************************************************/
234
235ODINFUNCTION1(BOOL,SetCurrentDirectoryW,LPCWSTR,lpPathName)
236{
237 char *asciipath;
238 BOOL rc;
239
240 asciipath = UnicodeToAsciiString((LPWSTR)lpPathName);
241 rc = SetCurrentDirectoryA(asciipath);
242 FreeAsciiString(asciipath);
243 return(rc);
244}
245
246
247/*****************************************************************************
248 * Name : CreateDirectoryA
249 * Purpose :
250 * Parameters:
251 * Variables :
252 * Result :
253 * Remark :
254 * Status :
255 *
256 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
257 *****************************************************************************/
258
259ODINFUNCTION2(BOOL, CreateDirectoryA,
260 LPCSTR, lpstrDirectory,
261 PSECURITY_ATTRIBUTES,arg2)
262{
263 // 2001-05-28 PH
264 // verify filename first (NT4SP6)
265 // @@@PH: if (IsBadStringPtr( (LPVOID)lpstrDirectory, 0xFFFF))
266 if (lpstrDirectory == NULL)
267 {
268 SetLastError(ERROR_PATH_NOT_FOUND);
269 return FALSE;
270 }
271
272 int len = strlen(lpstrDirectory);
273
274 // cut off trailing backslashes
275 if ( (lpstrDirectory[len - 1] == '\\') ||
276 (lpstrDirectory[len - 1] == '/') )
277 {
278 LPSTR lpTemp = (LPSTR)_alloca(len);
279 lstrcpynA(lpTemp,
280 lpstrDirectory,
281 len ); // len is including trailing NULL!!
282 lpstrDirectory = lpTemp;
283 }
284
285 dprintf(("CreateDirectoryA %s", lpstrDirectory));
286
287 // PH Note 2000/06/12:
288 // Creation of an existing directory is NO ERROR it seems.
289 DWORD dwAttr = GetFileAttributesA(lpstrDirectory);
290 if(dwAttr != -1)
291 {
292 if (dwAttr & FILE_ATTRIBUTE_DIRECTORY)
293 {
294 SetLastError(ERROR_SUCCESS);
295 return TRUE;
296 }
297 }
298 return(OSLibDosCreateDirectory(lpstrDirectory));
299}
300
301/*****************************************************************************
302 * Name : CreateDirectoryW
303 * Purpose :
304 * Parameters:
305 * Variables :
306 * Result :
307 * Remark :
308 * Status :
309 *
310 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
311 *****************************************************************************/
312
313ODINFUNCTION2(BOOL,CreateDirectoryW,LPCWSTR, arg1,
314 PSECURITY_ATTRIBUTES,arg2)
315{
316 BOOL rc;
317 char *astring;
318
319 astring = UnicodeToAsciiString((LPWSTR)arg1);
320 rc = CALL_ODINFUNC(CreateDirectoryA)(astring, arg2);
321 FreeAsciiString(astring);
322 return(rc);
323}
324
325/*****************************************************************************
326 * Name : BOOL WIN32API CreateDirectoryExA
327 * Purpose : The CreateDirectoryExA function creates a new directory with a
328 * specified path that retains the attributes of a specified
329 * template directory. If the underlying file system supports
330 * security on files and directories, the function applies a
331 * specified security descriptor to the new directory.
332 * The new directory retains the other attributes of the specified
333 * template directory. Note that CreateDirectoryEx has a template
334 * parameter, while CreateDirectory does not.
335 * Parameters: LPCSTR lpTemplateDirectory pointer to path string of template
336 * directory
337 * LPCSTR lpNewDirectory pointer to path string of directory
338 * to create
339 * LPSECURITY_ATTRIBUTES lpSecurityAttributes pointer to security
340 * descriptor
341 *
342 * Variables :
343 * Result : If the function succeeds, the return value is nonzero.
344 * If the function fails, the return value is zero.
345 * To get extended error information, call GetLastError.
346 * Remark :
347 * Status : UNTESTED STUB
348 *
349 * Author : Markus Montkowski [Tha, 1998/05/21 17:46]
350 *****************************************************************************/
351
352ODINFUNCTION3(BOOL, CreateDirectoryExA,
353 LPCSTR, lpTemplateDirectory,
354 LPCSTR, lpNewDirectory,
355 LPSECURITY_ATTRIBUTES, lpSecurityAttributes)
356{
357
358 dprintf(("KERNEL32:CreateDirectoryExA(%s,%s,%08xh) not properly implemented\n",
359 lpTemplateDirectory,lpNewDirectory,lpSecurityAttributes
360 ));
361
362 return CreateDirectoryA(lpNewDirectory, lpSecurityAttributes);
363}
364
365/*****************************************************************************
366 * Name : BOOL WIN32API CreateDirectoryExW
367 * Purpose : The CreateDirectoryExW function creates a new directory with a
368 * specified path that retains the attributes of a specified
369 * template directory. If the underlying file system supports
370 * security on files and directories, the function applies a
371 * specified security descriptor to the new directory.
372 * The new directory retains the other attributes of the specified
373 * template directory. Note that CreateDirectoryEx has a template
374 * parameter, while CreateDirectory does not.
375 * Parameters: LPCWSTR lpTemplateDirectory pointer to path string of template
376 * directory
377 * LPCWSTR lpNewDirectory pointer to path string of directory
378 * to create
379 * LPSECURITY_ATTRIBUTES lpSecurityAttributes pointer to security
380 * descriptor
381 *
382 * Variables :
383 * Result : If the function succeeds, the return value is nonzero.
384 * If the function fails, the return value is zero.
385 * To get extended error information, call GetLastError.
386 * Remark :
387 * Status : UNTESTED STUB
388 *
389 * Author : Markus Montkowski [Tha, 1998/05/21 17:46]
390 *****************************************************************************/
391
392ODINFUNCTION3(BOOL, CreateDirectoryExW,
393 LPCWSTR, lpTemplateDirectory,
394 LPCWSTR, lpNewDirectory,
395 LPSECURITY_ATTRIBUTES, lpSecurityAttributes)
396{
397
398 dprintf(("KERNEL32:CreateDirectoryExW(%08x,%08x,%08x) not properly implemented\n",
399 lpTemplateDirectory,lpNewDirectory,lpSecurityAttributes
400 ));
401
402 return CreateDirectoryW(lpNewDirectory, lpSecurityAttributes);
403}
404
405/*****************************************************************************
406 * Name : GetSystemDirectoryA
407 * Purpose :
408 * Parameters:
409 * Variables :
410 * Result :
411 * Remark : Should return length of system dir even if lpBuffer == NULL
412 * Status :
413 *
414 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
415 *****************************************************************************/
416
417ODINFUNCTION2(UINT,GetSystemDirectoryA,LPSTR,lpBuffer,
418 UINT,uSize)
419{
420 int len;
421 char *dir;
422
423 dir = InternalGetSystemDirectoryA();
424 len = lstrlenA(dir);
425 if(lpBuffer)
426 lstrcpynA(lpBuffer, dir, uSize);
427 return len;
428}
429
430
431/*****************************************************************************
432 * Name : GetSystemDirectoryW
433 * Purpose :
434 * Parameters:
435 * Variables :
436 * Result :
437 * Remark : Should return length of system dir even if lpBuffer == NULL
438 * Status :
439 *
440 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
441 *****************************************************************************/
442
443ODINFUNCTION2(UINT,GetSystemDirectoryW,LPWSTR,lpBuffer,
444 UINT, uSize)
445{
446 char *asciibuffer = NULL;
447 UINT rc;
448
449 if(lpBuffer)
450 asciibuffer = (char *)alloca(uSize+1);
451
452 if(lpBuffer && asciibuffer == NULL)
453 {
454 DebugInt3();
455 }
456
457 rc = GetSystemDirectoryA(asciibuffer, uSize);
458 if(rc && asciibuffer)
459 AsciiToUnicode(asciibuffer, lpBuffer);
460
461 return(rc);
462}
463
464
465/*****************************************************************************
466 * Name : GetWindowsDirectoryA
467 * Purpose :
468 * Parameters:
469 * Variables :
470 * Result :
471 * Remark : Should return length of system dir even if lpBuffer == NULL
472 * Status :
473 *
474 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
475 *****************************************************************************/
476
477ODINFUNCTION2(UINT,GetWindowsDirectoryA,LPSTR,lpBuffer,
478 UINT,uSize)
479{
480 char *dir;
481 int len;
482
483 dir = InternalGetWindowsDirectoryA();
484 len = lstrlenA(dir);
485 if(lpBuffer)
486 lstrcpynA(lpBuffer, dir, uSize);
487 return len;
488}
489
490
491/*****************************************************************************
492 * Name : GetWindowsDirectoryW
493 * Purpose :
494 * Parameters:
495 * Variables :
496 * Result :
497 * Remark : Should return length of system dir even if lpBuffer == NULL
498 * Status :
499 *
500 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
501 *****************************************************************************/
502
503ODINFUNCTION2(UINT,GetWindowsDirectoryW,LPWSTR,lpBuffer,
504 UINT, uSize)
505{
506 char *asciibuffer = NULL;
507 UINT rc;
508
509 if(lpBuffer)
510 asciibuffer = (char *)alloca(uSize+1);
511
512 if(lpBuffer && asciibuffer == NULL)
513 {
514 DebugInt3();
515 }
516
517 rc = GetWindowsDirectoryA(asciibuffer, uSize);
518 if(rc && asciibuffer)
519 AsciiToUnicode(asciibuffer, lpBuffer);
520
521 return(rc);
522}
523
524
525/*****************************************************************************
526 * Name : RemoveDirectoryA
527 * Purpose :
528 * Parameters:
529 * Variables :
530 * Result :
531 * Remark :
532 * Status :
533 *
534 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
535 *****************************************************************************/
536
537
538ODINFUNCTION1(BOOL, RemoveDirectoryA, LPCSTR, lpstrDirectory)
539{
540 int len = strlen(lpstrDirectory);
541
542 if(lpstrDirectory == NULL) {
543 SetLastError(ERROR_INVALID_PARAMETER);
544 return FALSE;
545 }
546 // cut off trailing backslashes
547 if ( (lpstrDirectory[len - 1] == '\\') ||
548 (lpstrDirectory[len - 1] == '/') )
549 {
550 LPSTR lpTemp = (LPSTR)_alloca(len);
551 lstrcpynA(lpTemp,
552 lpstrDirectory,
553 len ); // len is including trailing NULL!!
554 lpstrDirectory = lpTemp;
555 }
556
557 dprintf(("RemoveDirectory %s", lpstrDirectory));
558
559 return OSLibDosRemoveDir(lpstrDirectory);
560}
561
562
563/*****************************************************************************
564 * Name : RemoveDirectoryW
565 * Purpose :
566 * Parameters:
567 * Variables :
568 * Result :
569 * Remark :
570 * Status :
571 *
572 * Author : Patrick Haller [Wed, 1999/09/28 20:44]
573 *****************************************************************************/
574
575ODINFUNCTION1(BOOL,RemoveDirectoryW,LPCWSTR,lpPathName)
576{
577 char *asciipath;
578 BOOL rc;
579
580 asciipath = UnicodeToAsciiString((LPWSTR)lpPathName);
581 rc = RemoveDirectoryA(asciipath);
582 FreeAsciiString(asciipath);
583 return(rc);
584}
585
586/***********************************************************************
587 * DIR_TryModulePath
588 *
589 * Helper function for DIR_SearchPath.
590 */
591static BOOL DIR_TryModulePath( LPCSTR name, char *full_name )
592{
593 char buffer[OFS_MAXPATHNAME];
594 LPSTR p;
595
596 if (!GetModuleFileNameA( 0, buffer, sizeof(buffer) ))
597 buffer[0]='\0';
598
599 if (!(p = strrchr( buffer, '\\' ))) return FALSE;
600 if (sizeof(buffer) - (++p - buffer) <= strlen(name)) return FALSE;
601 strcpy( p, name );
602
603 return OSLibDosSearchPath(OSLIB_SEARCHFILE, NULL, buffer, full_name, MAX_PATHNAME_LEN);
604}
605
606
607/***********************************************************************
608 * DIR_SearchPath
609 *
610 * Implementation of SearchPath32A. 'win32' specifies whether the search
611 * order is Win16 (module path last) or Win32 (module path first).
612 *
613 * FIXME: should return long path names.
614 */
615DWORD DIR_SearchPath( LPCSTR path, LPCSTR name, LPCSTR ext,
616 char *full_name )
617{
618 DWORD len;
619 LPCSTR p;
620 LPSTR tmp = NULL;
621 BOOL ret = TRUE;
622
623 /* First check the supplied parameters */
624
625 p = strrchr( name, '.' );
626 if (p && !strchr( p, '/' ) && !strchr( p, '\\' ))
627 ext = NULL; /* Ignore the specified extension */
628 if ((*name && (name[1] == ':')) ||
629 strchr( name, '/' ) || strchr( name, '\\' ))
630 path = NULL; /* Ignore path if name already contains a path */
631 if (path && !*path) path = NULL; /* Ignore empty path */
632
633 /* See if path is a list of directories to search. If so, only search
634 those (according to SDK docs) */
635 if ((path != NULL) && strchr(path, ';')) {
636 ret = OSLibDosSearchPath(OSLIB_SEARCHDIR, (LPSTR)path, (LPSTR)name,
637 full_name, MAX_PATHNAME_LEN);
638 goto done;
639 }
640
641 len = strlen(name);
642 if (ext) len += strlen(ext);
643 if (path) len += strlen(path) + 1;
644
645 /* Allocate a buffer for the file name and extension */
646
647 if (path || ext)
648 {
649 if (!(tmp = (LPSTR)HeapAlloc( GetProcessHeap(), 0, len + 1 )))
650 {
651 SetLastError( ERROR_OUTOFMEMORY );
652 return 0;
653 }
654 if (path)
655 {
656 strcpy( tmp, path );
657 strcat( tmp, "\\" );
658 strcat( tmp, name );
659 }
660 else strcpy( tmp, name );
661 if (ext) strcat( tmp, ext );
662 name = tmp;
663 }
664
665 /* If we have an explicit path, everything's easy */
666
667 if (path || (*name && (name[1] == ':')) ||
668 strchr( name, '/' ) || strchr( name, '\\' ))
669 {
670 ret = OSLibDosSearchPath(OSLIB_SEARCHFILE, NULL, (LPSTR)name, full_name, MAX_PATHNAME_LEN);
671 goto done;
672 }
673
674 /* Try the path of the current executable (for Win32 search order) */
675 if (DIR_TryModulePath( name, full_name )) goto done;
676
677 /* Try the current directory */
678 if (OSLibDosSearchPath(OSLIB_SEARCHCURDIR, NULL, (LPSTR)name, full_name, MAX_PATHNAME_LEN))
679 goto done;
680
681 /* Try the Windows system directory */
682 if (OSLibDosSearchPath(OSLIB_SEARCHDIR, (LPSTR)&DIR_System, (LPSTR)name, full_name, MAX_PATHNAME_LEN))
683 goto done;
684
685 /* Try the Windows directory */
686 if (OSLibDosSearchPath(OSLIB_SEARCHDIR, (LPSTR)&DIR_Windows, (LPSTR)name, full_name, MAX_PATHNAME_LEN))
687 goto done;
688
689 /* Try all directories in path */
690 ret = OSLibDosSearchPath(OSLIB_SEARCHENV, "PATH", (LPSTR)name, full_name, MAX_PATHNAME_LEN);
691
692done:
693 if (tmp) HeapFree( GetProcessHeap(), 0, tmp );
694 return ret;
695}
696
697
698/***********************************************************************
699 * SearchPath32A [KERNEL32.447]
700 *
701 * Searches for a specified file in the search path.
702 *
703 * PARAMS
704 * path [I] Path to search
705 * name [I] Filename to search for.
706 * ext [I] File extension to append to file name. The first
707 * character must be a period. This parameter is
708 * specified only if the filename given does not
709 * contain an extension.
710 * buflen [I] size of buffer, in characters
711 * buffer [O] buffer for found filename
712 * lastpart [O] address of pointer to last used character in
713 * buffer (the final '\')
714 *
715 * RETURNS
716 * Success: length of string copied into buffer, not including
717 * terminating null character. If the filename found is
718 * longer than the length of the buffer, the length of the
719 * filename is returned.
720 * Failure: Zero
721 *
722 * NOTES
723 * Should call SetLastError(but currently doesn't).
724 */
725ODINFUNCTION6(DWORD, SearchPathA,
726 LPCSTR, path,
727 LPCSTR, name,
728 LPCSTR, ext,
729 DWORD, buflen,
730 LPSTR, buffer,
731 LPSTR *, lastpart )
732{
733 char full_name[MAX_PATHNAME_LEN];
734
735 if (!DIR_SearchPath( path, name, ext, (LPSTR)full_name )) return 0;
736 lstrcpynA( buffer, (LPSTR)full_name, buflen);
737 SetLastError(0);
738 return strlen(full_name);
739}
740
741
742/***********************************************************************
743 * SearchPath32W (KERNEL32.448)
744 */
745ODINFUNCTION6(DWORD, SearchPathW,
746 LPCWSTR, path,
747 LPCWSTR, name,
748 LPCWSTR, ext,
749 DWORD, buflen,
750 LPWSTR, buffer,
751 LPWSTR *, lastpart )
752{
753 char full_name[MAX_PATHNAME_LEN];
754
755#ifdef __WIN32OS2__
756 LPSTR pathA;
757 LPSTR nameA;
758 LPSTR extA;
759 STACK_strdupWtoA(path, pathA)
760 STACK_strdupWtoA(name, nameA)
761 STACK_strdupWtoA(ext, extA)
762#else
763 LPSTR pathA = HEAP_strdupWtoA( GetProcessHeap(), 0, path );
764 LPSTR nameA = HEAP_strdupWtoA( GetProcessHeap(), 0, name );
765 LPSTR extA = HEAP_strdupWtoA( GetProcessHeap(), 0, ext );
766#endif
767
768 DWORD ret = DIR_SearchPath( pathA, nameA, extA, (LPSTR)full_name );
769
770#ifndef __WIN32OS2__
771 HeapFree( GetProcessHeap(), 0, extA );
772 HeapFree( GetProcessHeap(), 0, nameA );
773 HeapFree( GetProcessHeap(), 0, pathA );
774#endif
775
776 if (!ret) return 0;
777
778 lstrcpynAtoW( buffer, full_name, buflen);
779 SetLastError(0);
780 return ret;
781}
Note: See TracBrowser for help on using the repository browser.