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

Last change on this file since 22018 was 21916, checked in by dmik, 14 years ago

Merge branch gcc-kmk to trunk.

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