wine/files/directory.c
Alexandre Julliard c7c217b31c Release 980413
Sun Apr 12 12:22:23 1997  Andreas Mohr <100.30936@germany.net>

	* [files/drive.c]
	Fixed "no free space" problem with partition sizes between 1 and 2 GB
	(cluster_sectors may not exceed 0x40).

	* [windows/msgbox.c] [if1632/user.spec] [include/windows.h]
	Implemented MessageBoxIndirect16, corrected MSGBOXPARAMS16.

	* [loader/task.c]
	DOS environment strings may never exceed 127 chars
	-> truncate Unix environment strings if necessary.

Sun Apr 12 02:51:44 1998  Dimitrie O. Paun  <dimi@mail.cs.toronto.edu>

	* [files/*.c]
	All fprintf statements were converted to appropriate debug
	messages.

	* [tools/find_debug_channels]
	Updated comments at the beginning of the file.

Sat Apr 11 15:27:21 1998  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [loader/module.c] [loader/task.c] [scheduler/process.c]
	Moved some code around to prepare the ground for CreateProcess().

	* [memory/environ.c] [loader/task.c]
	Moved Win32 environment strings functions to environ.c.
	Unified Win16 and Win32 environment management.

	* [scheduler/handle.c] [scheduler/k32obj.c] [scheduler/*.c]
	Implemented handle inheritance and DuplicateHandle().

	* [scheduler/thread.c]
	Create a 16-bit stack for all threads.

	* [windows/dialog.c]
	Implemented DIALOGEX resource format.

Fri Apr 10 20:21:51 1998  Marcus Meissner <marcus@mud.de>

	* [configure.in][include/acconfig.h][*/*][multimedia/*]
	Cleaned up the OSS detection stuff, added some more checks for
	headerfiles/functions.
	Removed a lot of OS specific #ifdefs.
	Lots of dependend multimedia cleanups.

	* [loader/pe_image.c]
	Enhanced comment, added missing reference count increase.

	* [ole/compobj.c]
	Replaced broken StringFromGUID2 by working one.

	* [misc/winsock.c]
	SO_LINGER uses unsigned 16 bit in Win16 and Win32, but unsigned
	int (32bit) for UNIX.

	* [memory/global.c]
	Allow realloc for lockcount 1 too.

Fri Apr 10 15:27:34 1998  Morten Welinder  <terra@diku.dk>

	* [graphics/x11drv/text.c]
	Handle control characters in trace.  Ignore terminating newline.

	* [multimedia/init.c]
	(MULTIMEDIA_Init): Correct allocations.

	* [tools/examine-relay]
 	Tidy up.

	* [windows/syscolor.c]
	Change highlight colour from lightblue to lightgray.  This
	looks correct for menus.

Fri Apr 10 01:49:58 1998  Douglas Ridgway  <ridgway@winehq.com>

	* [configure.in] [Make.rules.in]
	Add check for c2man before using it.

Fri Apr 10 02:59:21 1998  Douglas Ridgway  <ridgway@winehq.com>

	* [DEVELOPERS-HINTS]
	Simple description of adding API calls.

	* [include/wintypes.h] [include/windows.h]
	Get rid of Winelib16, avoid declaring some illegal functions in
	Winelib, add prototypes for some enhanced metafile functions, fix
	GetTextExtentPoint32 declarations.

	* [relay32/gdi32.spec] [objects/enhmetafile.c]
	Cosmetic and functional improvements.

	* [include/wincon.h] [programs/view/*]
	Fixes, improved compatibility with native compilers.

Thu Apr  9 15:48:49 1998  Ulrich Weigand <weigand@informatik.uni-erlangen.de>

	* [win32/kernel32.c]
	Implemented FT_Thunk / FT_Prolog / FT_Exit / FT_PrologPrime.
	Fixed Common32ThkLS thunk function.

	* [tools/build.c] [relay32/relay386.c] [if1632/relay.c]
	Changed relay code to allow register functions to modify stack layout.

	* [memory/selector.c]
	Implemented AllocMappedBuffer / FreeMappedBuffer.

	* [relay32/kernel32.spec] [if1632/kernel.spec] [win32/ordinals.c]
	Added names for undocumented functions.

	* [loader/module.c]
	Bugfix: LoadLibrary16 should *not* silently load 32-bit DLL.

Thu Apr  9 03:54:58 1998  Jim Peterson <jspeter@birch.ee.vt.edu>

	* [windows/keyboard.c]
	Fix an erroneous test in TranslateAccelerator{16,32} for the end
	of the accelerator table.

Thu Apr  8 20:36:28 1998  Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de> 

	* [misc/crtdll.c]
	Implement getenv.

	* [misc/commdlg.c]
	Make Get[Save/Open]FileName work in most situations.

	* [misc/lstr.c]
	Use wvsprintf32A instead of vsprintf in FormatMessage32X

	* [misc/version]
	Make NT3.50 a recognised version

	* [graphics/x11drv/graphics.c]
	Change the algorithme to draw arcs

	* [loader/resource.c]
	Return an empty buffer in LoadString32A if no resource found.

	* [win32/code_page.c]
	Try harder to get the right size in MultiByteToWideChar.

	* [win32/process.c]
	Call WinExec32 for CreateProcess32A.

	* [windows/user.c]
	Install default Int0 Handler in InitApp().

Thu Apr  8 19:29:48 1998  Eric Kohl <ekohl@abo.rhein-zeitung.de>

	* [misc/imagelist.c]
	Preliminary fix for drawing selected images.
	Various improvements.

	* [controls/progress.c][include/progress.c][include/commctrl.h]
	Added progress bar messages and styles for IE4.01 (dll version 4.72)
	compatibility.
	Fixed led size problem.

	* [controls/updown.c][include/commctrl.h]
	Added UDM_GETRANGE32 and UDM_SETRANGE32.

	* [objects/oembitmaps.c][include/windows.h][include/bitmaps/*]
	Added Win95 icons and fixed Win95 cursor and restore button bug.
	Now they should be visible. Sorry!!!

	* [relay32/comctl32.spec]
	Added most missing function names.

Tue Apr  6 18:48:36 1998  Matthew Becker <mbecker@glasscity.net>

	* [objects/font.c] [if1632/gdi.spec]
	GetOutlineTextMetrics: stub

	* [objects/text.c]
	GetTextCharset should just call GetTextCharsetInfo.

	* [misc/mpr.c] [relay32/mpr.spec]
	WNetCachePassword: stub

	* [scheduler/thread.c] [relay32/user32.spec]
	AttachThreadInput: stub
	Updated documentation.

	* [objects/palette.c]
	Updated documentation.

Tue Mar 31 17:06:30 1998  James Juran <jrj120@psu.edu>

	* [*/*.c]
	Finished fixing USER32 ordinal numbers in function documentation.

Mon Mar 30 20:27:38 1998  Morten Welinder  <terra@diku.dk>

	* [misc/debugstr.c] [include/debugstr.h]
	Moved _dumpstr from relay32/relay386.c.  Improved control
	character handling.

	* [msdos/int21.c]
	Implement 215E00 -- get machine name.

	* [windows/winpos.c]
	SetWindowPos32: Make an extra sync when mapping managed
	windows.  This makes sure the reconfigure event has been
	handled.  See Mshearts' what's-your-name window.

Mon Mar 30 01:13:50 1998  Alexander V. Lukyanov <lav@long.yar.ru>

	* [Makefile.in]
	Install includes from TOPSRCDIR.
1998-04-13 12:21:30 +00:00

610 lines
18 KiB
C

/*
* DOS directories functions
*
* Copyright 1995 Alexandre Julliard
*/
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include "windows.h"
#include "winerror.h"
#include "drive.h"
#include "file.h"
#include "heap.h"
#include "msdos.h"
#include "options.h"
#include "debug.h"
static DOS_FULL_NAME DIR_Windows;
static DOS_FULL_NAME DIR_System;
/***********************************************************************
* DIR_GetPath
*
* Get a path name from the wine.ini file and make sure it is valid.
*/
static int DIR_GetPath( const char *keyname, const char *defval,
DOS_FULL_NAME *full_name )
{
char path[MAX_PATHNAME_LEN];
BY_HANDLE_FILE_INFORMATION info;
PROFILE_GetWineIniString( "wine", keyname, defval, path, sizeof(path) );
if (!DOSFS_GetFullName( path, TRUE, full_name ) ||
!FILE_Stat( full_name->long_name, &info ) ||
!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
MSG("Invalid path '%s' for %s directory\n", path, keyname);
return 0;
}
return 1;
}
/***********************************************************************
* DIR_Init
*/
int DIR_Init(void)
{
char path[MAX_PATHNAME_LEN];
DOS_FULL_NAME tmp_dir;
int drive;
const char *cwd;
if (!getcwd( path, MAX_PATHNAME_LEN ))
{
perror( "Could not get current directory" );
return 0;
}
cwd = path;
if ((drive = DRIVE_FindDriveRoot( &cwd )) == -1)
{
MSG("Warning: could not find DOS drive for cwd %s; "
"starting in windows directory.\n", cwd );
}
else
{
DRIVE_SetCurrentDrive( drive );
DRIVE_Chdir( drive, cwd );
}
if (!(DIR_GetPath( "windows", "c:\\windows", &DIR_Windows )))
return 0;
if (!(DIR_GetPath( "system", "c:\\windows\\system", &DIR_System )))
return 0;
if (!(DIR_GetPath( "temp", "c:\\windows", &tmp_dir )))
return 0;
if (-1 == access( tmp_dir.long_name, W_OK ))
{
if (errno==EACCES)
MSG("Warning: The Temporary Directory (as specified in wine.conf) is NOT writeable. Please check your configuration.\n");
else
MSG("Warning: Access to Temporary Directory failed (%s).\n",
strerror(errno));
}
if (drive == -1)
{
drive = DIR_Windows.drive;
DRIVE_SetCurrentDrive( drive );
DRIVE_Chdir( drive, DIR_Windows.short_name + 2 );
}
PROFILE_GetWineIniString("wine", "path", "c:\\windows;c:\\windows\\system",
path, sizeof(path) );
/* Set the environment variables */
SetEnvironmentVariable32A( "PATH", path );
SetEnvironmentVariable32A( "TEMP", tmp_dir.short_name );
SetEnvironmentVariable32A( "windir", DIR_Windows.short_name );
SetEnvironmentVariable32A( "winsysdir", DIR_System.short_name );
TRACE(dosfs, "WindowsDir = %s (%s)\n",
DIR_Windows.short_name, DIR_Windows.long_name );
TRACE(dosfs, "SystemDir = %s (%s)\n",
DIR_System.short_name, DIR_System.long_name );
TRACE(dosfs, "TempDir = %s (%s)\n",
tmp_dir.short_name, tmp_dir.long_name );
TRACE(dosfs, "Path = %s\n", path );
TRACE(dosfs, "Cwd = %c:\\%s\n",
'A' + drive, DRIVE_GetDosCwd( drive ) );
return 1;
}
/***********************************************************************
* GetTempPath32A (KERNEL32.292)
*/
UINT32 WINAPI GetTempPath32A( UINT32 count, LPSTR path )
{
UINT32 ret;
if (!(ret = GetEnvironmentVariable32A( "TMP", path, count )))
if (!(ret = GetEnvironmentVariable32A( "TEMP", path, count )))
ret = GetCurrentDirectory32A( count, path );
return ret;
}
/***********************************************************************
* GetTempPath32W (KERNEL32.293)
*/
UINT32 WINAPI GetTempPath32W( UINT32 count, LPWSTR path )
{
static const WCHAR tmp[] = { 'T', 'M', 'P', 0 };
static const WCHAR temp[] = { 'T', 'E', 'M', 'P', 0 };
UINT32 ret;
if (!(ret = GetEnvironmentVariable32W( tmp, path, count )))
if (!(ret = GetEnvironmentVariable32W( temp, path, count )))
ret = GetCurrentDirectory32W( count, path );
return ret;
}
/***********************************************************************
* DIR_GetWindowsUnixDir
*/
UINT32 DIR_GetWindowsUnixDir( LPSTR path, UINT32 count )
{
if (path) lstrcpyn32A( path, DIR_Windows.long_name, count );
return strlen( DIR_Windows.long_name );
}
/***********************************************************************
* DIR_GetSystemUnixDir
*/
UINT32 DIR_GetSystemUnixDir( LPSTR path, UINT32 count )
{
if (path) lstrcpyn32A( path, DIR_System.long_name, count );
return strlen( DIR_System.long_name );
}
/***********************************************************************
* GetTempDrive (KERNEL.92)
*/
BYTE WINAPI GetTempDrive( BYTE ignored )
{
char buffer[2];
/* FIXME: apparently Windows does something with the ignored byte */
if (!GetTempPath32A( sizeof(buffer), buffer )) buffer[0] = 'C';
return toupper(buffer[0]) - 'A';
}
UINT32 WINAPI WIN16_GetTempDrive( BYTE ignored )
{
/* A closer look at krnl386.exe shows what the SDK doesn't mention:
*
* returns:
* AL: driveletter
* AH: ':' - yes, some kernel code even does stosw with
* the returned AX.
* DX: 1 for success
*/
return MAKELONG( GetTempDrive(ignored) | (':' << 8), 1 );
}
/***********************************************************************
* GetWindowsDirectory16 (KERNEL.134)
*/
UINT16 WINAPI GetWindowsDirectory16( LPSTR path, UINT16 count )
{
return (UINT16)GetWindowsDirectory32A( path, count );
}
/***********************************************************************
* GetWindowsDirectory32A (KERNEL32.311)
*/
UINT32 WINAPI GetWindowsDirectory32A( LPSTR path, UINT32 count )
{
if (path) lstrcpyn32A( path, DIR_Windows.short_name, count );
return strlen( DIR_Windows.short_name );
}
/***********************************************************************
* GetWindowsDirectory32W (KERNEL32.312)
*/
UINT32 WINAPI GetWindowsDirectory32W( LPWSTR path, UINT32 count )
{
if (path) lstrcpynAtoW( path, DIR_Windows.short_name, count );
return strlen( DIR_Windows.short_name );
}
/***********************************************************************
* GetSystemDirectory16 (KERNEL.135)
*/
UINT16 WINAPI GetSystemDirectory16( LPSTR path, UINT16 count )
{
return (UINT16)GetSystemDirectory32A( path, count );
}
/***********************************************************************
* GetSystemDirectory32A (KERNEL32.282)
*/
UINT32 WINAPI GetSystemDirectory32A( LPSTR path, UINT32 count )
{
if (path) lstrcpyn32A( path, DIR_System.short_name, count );
return strlen( DIR_System.short_name );
}
/***********************************************************************
* GetSystemDirectory32W (KERNEL32.283)
*/
UINT32 WINAPI GetSystemDirectory32W( LPWSTR path, UINT32 count )
{
if (path) lstrcpynAtoW( path, DIR_System.short_name, count );
return strlen( DIR_System.short_name );
}
/***********************************************************************
* CreateDirectory16 (KERNEL.144)
*/
BOOL16 WINAPI CreateDirectory16( LPCSTR path, LPVOID dummy )
{
TRACE(file,"(%s,%p)\n", path, dummy );
return (BOOL16)CreateDirectory32A( path, NULL );
}
/***********************************************************************
* CreateDirectory32A (KERNEL32.39)
*/
BOOL32 WINAPI CreateDirectory32A( LPCSTR path,
LPSECURITY_ATTRIBUTES lpsecattribs )
{
DOS_FULL_NAME full_name;
TRACE(file, "(%s,%p)\n", path, lpsecattribs );
if (DOSFS_IsDevice( path ))
{
TRACE(file, "cannot use device '%s'!\n",path);
DOS_ERROR( ER_AccessDenied, EC_AccessDenied, SA_Abort, EL_Disk );
return FALSE;
}
if (!DOSFS_GetFullName( path, FALSE, &full_name )) return 0;
if ((mkdir( full_name.long_name, 0777 ) == -1) && (errno != EEXIST))
{
WARN (file, "Errno %i trying to create directory %s.\n", errno, full_name.long_name);
FILE_SetDosError();
return FALSE;
}
return TRUE;
}
/***********************************************************************
* CreateDirectory32W (KERNEL32.42)
*/
BOOL32 WINAPI CreateDirectory32W( LPCWSTR path,
LPSECURITY_ATTRIBUTES lpsecattribs )
{
LPSTR xpath = HEAP_strdupWtoA( GetProcessHeap(), 0, path );
BOOL32 ret = CreateDirectory32A( xpath, lpsecattribs );
HeapFree( GetProcessHeap(), 0, xpath );
return ret;
}
/***********************************************************************
* CreateDirectoryEx32A (KERNEL32.40)
*/
BOOL32 WINAPI CreateDirectoryEx32A( LPCSTR template, LPCSTR path,
LPSECURITY_ATTRIBUTES lpsecattribs)
{
return CreateDirectory32A(path,lpsecattribs);
}
/***********************************************************************
* CreateDirectoryEx32W (KERNEL32.41)
*/
BOOL32 WINAPI CreateDirectoryEx32W( LPCWSTR template, LPCWSTR path,
LPSECURITY_ATTRIBUTES lpsecattribs)
{
return CreateDirectory32W(path,lpsecattribs);
}
/***********************************************************************
* RemoveDirectory16 (KERNEL)
*/
BOOL16 WINAPI RemoveDirectory16( LPCSTR path )
{
return (BOOL16)RemoveDirectory32A( path );
}
/***********************************************************************
* RemoveDirectory32A (KERNEL32.437)
*/
BOOL32 WINAPI RemoveDirectory32A( LPCSTR path )
{
DOS_FULL_NAME full_name;
TRACE(file, "'%s'\n", path );
if (DOSFS_IsDevice( path ))
{
TRACE(file, "cannot remove device '%s'!\n", path);
DOS_ERROR( ER_FileNotFound, EC_NotFound, SA_Abort, EL_Disk );
return FALSE;
}
if (!DOSFS_GetFullName( path, TRUE, &full_name )) return FALSE;
if (rmdir( full_name.long_name ) == -1)
{
FILE_SetDosError();
return FALSE;
}
return TRUE;
}
/***********************************************************************
* RemoveDirectory32W (KERNEL32.438)
*/
BOOL32 WINAPI RemoveDirectory32W( LPCWSTR path )
{
LPSTR xpath = HEAP_strdupWtoA( GetProcessHeap(), 0, path );
BOOL32 ret = RemoveDirectory32A( xpath );
HeapFree( GetProcessHeap(), 0, xpath );
return ret;
}
/***********************************************************************
* DIR_TryPath
*
* Helper function for DIR_SearchPath.
*/
static BOOL32 DIR_TryPath( const DOS_FULL_NAME *dir, LPCSTR name,
DOS_FULL_NAME *full_name )
{
LPSTR p_l = full_name->long_name + strlen(dir->long_name) + 1;
LPSTR p_s = full_name->short_name + strlen(dir->short_name) + 1;
if ((p_s >= full_name->short_name + sizeof(full_name->short_name) - 14) ||
(p_l >= full_name->long_name + sizeof(full_name->long_name) - 1))
{
DOS_ERROR( ER_PathNotFound, EC_NotFound, SA_Abort, EL_Disk );
return FALSE;
}
if (!DOSFS_FindUnixName( dir->long_name, name, p_l,
sizeof(full_name->long_name) - (p_l - full_name->long_name),
p_s, DRIVE_GetFlags( dir->drive ) ))
return FALSE;
strcpy( full_name->long_name, dir->long_name );
p_l[-1] = '/';
strcpy( full_name->short_name, dir->short_name );
p_s[-1] = '\\';
return TRUE;
}
/***********************************************************************
* DIR_TryEnvironmentPath
*
* Helper function for DIR_SearchPath.
*/
static BOOL32 DIR_TryEnvironmentPath( LPCSTR name, DOS_FULL_NAME *full_name )
{
LPSTR path, next, buffer;
BOOL32 ret = FALSE;
INT32 len = strlen(name);
DWORD size = GetEnvironmentVariable32A( "PATH", NULL, 0 );
if (!size) return FALSE;
if (!(path = HeapAlloc( GetProcessHeap(), 0, size ))) return FALSE;
if (!GetEnvironmentVariable32A( "PATH", path, size )) goto done;
next = path;
while (!ret && next)
{
LPSTR cur = next;
while (*cur == ';') cur++;
if (!*cur) break;
next = strchr( cur, ';' );
if (next) *next++ = '\0';
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, strlen(cur) + len + 2)))
goto done;
strcpy( buffer, cur );
strcat( buffer, "\\" );
strcat( buffer, name );
ret = DOSFS_GetFullName( buffer, TRUE, full_name );
HeapFree( GetProcessHeap(), 0, buffer );
}
done:
HeapFree( GetProcessHeap(), 0, path );
return ret;
}
/***********************************************************************
* DIR_TryModulePath
*
* Helper function for DIR_SearchPath.
*/
static BOOL32 DIR_TryModulePath( LPCSTR name, DOS_FULL_NAME *full_name )
{
/* FIXME: for now, GetModuleFileName32A can't return more */
/* than OFS_MAXPATHNAME. This may change with Win32. */
char buffer[OFS_MAXPATHNAME];
LPSTR p;
if (!GetCurrentTask()) return FALSE;
GetModuleFileName32A( GetCurrentTask(), buffer, sizeof(buffer) );
if (!(p = strrchr( buffer, '\\' ))) return FALSE;
if (sizeof(buffer) - (++p - buffer) <= strlen(name)) return FALSE;
strcpy( p, name );
return DOSFS_GetFullName( buffer, TRUE, full_name );
}
/***********************************************************************
* DIR_SearchPath
*
* Implementation of SearchPath32A. 'win32' specifies whether the search
* order is Win16 (module path last) or Win32 (module path first).
*
* FIXME: should return long path names.
*/
DWORD DIR_SearchPath( LPCSTR path, LPCSTR name, LPCSTR ext,
DOS_FULL_NAME *full_name, BOOL32 win32 )
{
DWORD len;
LPCSTR p;
LPSTR tmp = NULL;
BOOL32 ret = TRUE;
/* First check the supplied parameters */
p = strrchr( name, '.' );
if (p && !strchr( p, '/' ) && !strchr( p, '\\' ))
ext = NULL; /* Ignore the specified extension */
if ((*name && (name[1] == ':')) ||
strchr( name, '/' ) || strchr( name, '\\' ))
path = NULL; /* Ignore path if name already contains a path */
if (path && !*path) path = NULL; /* Ignore empty path */
len = strlen(name);
if (ext) len += strlen(ext);
if (path) len += strlen(path) + 1;
/* Allocate a buffer for the file name and extension */
if (path || ext)
{
if (!(tmp = HeapAlloc( GetProcessHeap(), 0, len + 1 )))
{
SetLastError( ERROR_OUTOFMEMORY );
return 0;
}
if (path)
{
strcpy( tmp, path );
strcat( tmp, "\\" );
strcat( tmp, name );
}
else strcpy( tmp, name );
if (ext) strcat( tmp, ext );
name = tmp;
}
/* If we have an explicit path, everything's easy */
if (path || (*name && (name[1] == ':')) ||
strchr( name, '/' ) || strchr( name, '\\' ))
{
ret = DOSFS_GetFullName( name, TRUE, full_name );
goto done;
}
/* Try the path of the current executable (for Win32 search order) */
if (win32 && DIR_TryModulePath( name, full_name )) goto done;
/* Try the current directory */
if (DOSFS_GetFullName( name, TRUE, full_name )) goto done;
/* Try the Windows directory */
if (DIR_TryPath( &DIR_Windows, name, full_name ))
goto done;
/* Try the Windows system directory */
if (DIR_TryPath( &DIR_System, name, full_name ))
goto done;
/* Try the path of the current executable (for Win16 search order) */
if (!win32 && DIR_TryModulePath( name, full_name )) goto done;
/* Try all directories in path */
ret = DIR_TryEnvironmentPath( name, full_name );
done:
if (tmp) HeapFree( GetProcessHeap(), 0, tmp );
return ret;
}
/***********************************************************************
* SearchPath32A (KERNEL32.447)
*/
DWORD WINAPI SearchPath32A( LPCSTR path, LPCSTR name, LPCSTR ext, DWORD buflen,
LPSTR buffer, LPSTR *lastpart )
{
LPSTR p, res;
DOS_FULL_NAME full_name;
if (!DIR_SearchPath( path, name, ext, &full_name, TRUE )) return 0;
lstrcpyn32A( buffer, full_name.short_name, buflen );
res = full_name.long_name +
strlen(DRIVE_GetRoot( full_name.short_name[0] - 'A' ));
while (*res == '/') res++;
if (buflen)
{
if (buflen > 3) lstrcpyn32A( buffer + 3, res, buflen - 3 );
for (p = buffer; *p; p++) if (*p == '/') *p = '\\';
if (lastpart) *lastpart = strrchr( buffer, '\\' ) + 1;
}
return *res ? strlen(res) + 2 : 3;
}
/***********************************************************************
* SearchPath32W (KERNEL32.448)
*/
DWORD WINAPI SearchPath32W( LPCWSTR path, LPCWSTR name, LPCWSTR ext,
DWORD buflen, LPWSTR buffer, LPWSTR *lastpart )
{
LPWSTR p;
LPSTR res;
DOS_FULL_NAME full_name;
LPSTR pathA = HEAP_strdupWtoA( GetProcessHeap(), 0, path );
LPSTR nameA = HEAP_strdupWtoA( GetProcessHeap(), 0, name );
LPSTR extA = HEAP_strdupWtoA( GetProcessHeap(), 0, ext );
DWORD ret = DIR_SearchPath( pathA, nameA, extA, &full_name, TRUE );
HeapFree( GetProcessHeap(), 0, extA );
HeapFree( GetProcessHeap(), 0, nameA );
HeapFree( GetProcessHeap(), 0, pathA );
if (!ret) return 0;
lstrcpynAtoW( buffer, full_name.short_name, buflen );
res = full_name.long_name +
strlen(DRIVE_GetRoot( full_name.short_name[0] - 'A' ));
while (*res == '/') res++;
if (buflen)
{
if (buflen > 3) lstrcpynAtoW( buffer + 3, res, buflen - 3 );
for (p = buffer; *p; p++) if (*p == '/') *p = '\\';
if (lastpart)
{
for (p = *lastpart = buffer; *p; p++)
if (*p == '\\') *lastpart = p + 1;
}
}
return *res ? strlen(res) + 2 : 3;
}