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

Last change on this file since 10010 was 9597, checked in by sandervl, 23 years ago

changed calling convention of custom odin functions

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