mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
ca22b33dad
Fri Jul 12 17:43:05 1996 Alexandre Julliard <julliard@lrc.epfl.ch> * [controls/scroll.c] Use Win32 heap functions to allocate scroll-bar info structure. * [debugger/dbg.y] [debugger/registers.c] Added support for FS and GS segment registers. Check that segment registers value are OK before returning from the signal handler. * [tools/build.c] [if1632/relay.c] [loader/builtin.c] Changed relay debugging for Win32 function: the relay code now passes the entry point address instead of the function name. * [tools/build.c] [miscemu/*.c] Added support for data entry points in Win32 DLLs. Added 'cdecl' function type for Win32. For 'register' function, the relay code now passes a pointer to the SIGCONTEXT structure. * [include/registers.h] [include/wine.h] Moved SIGCONTEXT structure definition in registers.h. * [loader/pe_image.c] Don't die at once if some Win32 entry points cannot be found, but set them to NULL, just like we do for Win16. This allows some programs to go further before crashing. * [loader/task.c] [loader/main.c] Moved global initializations from InitTask() to MAIN_Init(), as they no longer need a task context with the new SEGPTR heap functions. * [memory/string.c] Added lstrcpynAtoW and lstrcpynWtoA; not real API functions, but very convenient. * [windows/graphics.c] Partially implemented DrawEdge(). * [windows/timer.c] [windows/caret.c] Implemented Win32 timer handling. Updated caret management to use Win32 timers (avoids having to use a Win16 callback). * [windows/win.c] Prevent programs from setting some style bits with SetWindowLong(). This should fix some BadMatch crashes. Link new windows at the end of the linked list. * [windows/winpos.c] Don't try to activate a child window in ShowWindow(). * [windows/winproc.c] Added a 32->32 thunk to support Ansi-Unicode translation. Wed Jul 10 22:11:12 1996 Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de> * [files/directory.c] Additional (undocumented) return value for GetTempDrive() added. * [files/dos_fs.c] [files/file.c] [include/windows.h] GetTempFileName32* added. GetShortPathName* added. * [memory/string.c] Win16 lstrcpy() can get NULL ptrs as argument and survive. * [misc/lzexpand.c] LZOpenFile(): also try opening with compressed filename if normal open fails. * [misc/ole2nls.c] [misc/lstr.c] [include/windows.h] Char* added. CompareString* added. Sun Jul 7 01:22:14 1996 Jukka Iivonen <iivonen@cc.helsinki.fi> * [objects/font.c] [if1632/gdi32.spec] CreateFontIndirect32A and CreateFontIndirect32W added. * [misc/ole2nls.c] GetUserDefaultLCID return values updated for new languages. Finnish support added for GetLocaleInfoA. * [object/palette] [gdi32.spec] RealizePalette32 and SelectPalette32 added. Sat Jul 6 17:27:30 1996 Ronan Waide <root@waider.ie> * [misc/shell.c] Fixup for SHELL_FindExecutable so that File->Run from progman works once more. Still needs some more fixups - grep for FIXME in this file.
310 lines
8.7 KiB
C
310 lines
8.7 KiB
C
/*
|
|
* DOS directories functions
|
|
*
|
|
* Copyright 1995 Alexandre Julliard
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
|
|
#include "windows.h"
|
|
#include "dos_fs.h"
|
|
#include "drive.h"
|
|
#include "file.h"
|
|
#include "msdos.h"
|
|
#include "options.h"
|
|
#include "xmalloc.h"
|
|
#include "string32.h"
|
|
#include "stddebug.h"
|
|
#include "debug.h"
|
|
#include "string32.h"
|
|
|
|
#define MAX_PATH_ELEMENTS 20
|
|
|
|
static char *DIR_WindowsDosDir;
|
|
static char *DIR_WindowsUnixDir;
|
|
static char *DIR_SystemDosDir;
|
|
static char *DIR_SystemUnixDir;
|
|
static char *DIR_TempDosDir;
|
|
static char *DIR_TempUnixDir;
|
|
|
|
static char *DIR_DosPath[MAX_PATH_ELEMENTS]; /* Path in DOS format */
|
|
static char *DIR_UnixPath[MAX_PATH_ELEMENTS]; /* Path in Unix format */
|
|
static int DIR_PathElements = 0;
|
|
|
|
/***********************************************************************
|
|
* 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,
|
|
char **dos_path, char **unix_path )
|
|
{
|
|
char path[MAX_PATHNAME_LEN];
|
|
const char *dos_name ,*unix_name;
|
|
BYTE attr;
|
|
|
|
PROFILE_GetWineIniString( "wine", keyname, defval, path, sizeof(path) );
|
|
if (!(unix_name = DOSFS_GetUnixFileName( path, TRUE )) ||
|
|
!FILE_Stat( unix_name, &attr, NULL, NULL, NULL ) ||
|
|
!(attr & FA_DIRECTORY))
|
|
{
|
|
fprintf(stderr, "Invalid path '%s' for %s directory\n", path, keyname);
|
|
return 0;
|
|
}
|
|
if (!(dos_name = DOSFS_GetDosTrueName( unix_name, TRUE )))
|
|
{
|
|
fprintf( stderr, "Could not get DOS name for %s directory '%s'\n",
|
|
keyname, unix_name );
|
|
return 0;
|
|
}
|
|
*unix_path = xstrdup( unix_name );
|
|
*dos_path = xstrdup( dos_name );
|
|
return 1;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DIR_ParseWindowsPath
|
|
*/
|
|
void DIR_ParseWindowsPath( char *path )
|
|
{
|
|
char *p;
|
|
const char *dos_name ,*unix_name;
|
|
BYTE attr;
|
|
int i;
|
|
|
|
for ( ; path && *path; path = p)
|
|
{
|
|
p = strchr( path, ';' );
|
|
if (p) while (*p == ';') *p++ = '\0';
|
|
|
|
if (DIR_PathElements >= MAX_PATH_ELEMENTS)
|
|
{
|
|
fprintf( stderr, "Warning: path has more than %d elements.\n",
|
|
MAX_PATH_ELEMENTS );
|
|
break;
|
|
}
|
|
if (!(unix_name = DOSFS_GetUnixFileName( path, TRUE )) ||
|
|
!FILE_Stat( unix_name, &attr, NULL, NULL, NULL ) ||
|
|
!(attr & FA_DIRECTORY))
|
|
{
|
|
fprintf(stderr,"Warning: invalid dir '%s' in path, deleting it.\n",
|
|
path );
|
|
continue;
|
|
}
|
|
if (!(dos_name = DOSFS_GetDosTrueName( unix_name, TRUE )))
|
|
{
|
|
fprintf( stderr, "Warning: could not get DOS name for '%s' in path, deleting it.\n",
|
|
unix_name );
|
|
continue;
|
|
}
|
|
DIR_UnixPath[DIR_PathElements] = xstrdup( unix_name );
|
|
DIR_DosPath[DIR_PathElements] = xstrdup( dos_name );
|
|
DIR_PathElements++;
|
|
}
|
|
|
|
if (debugging_dosfs)
|
|
for (i = 0; i < DIR_PathElements; i++)
|
|
{
|
|
dprintf_dosfs( stddeb, "Path[%d]: %s = %s\n",
|
|
i, DIR_DosPath[i], DIR_UnixPath[i] );
|
|
}
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DIR_Init
|
|
*/
|
|
int DIR_Init(void)
|
|
{
|
|
char path[MAX_PATHNAME_LEN], *env_p;
|
|
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)
|
|
{
|
|
fprintf( stderr, "Warning: could not find DOS drive for cwd %s; starting in windows directory.\n",
|
|
cwd );
|
|
}
|
|
else
|
|
{
|
|
cwd = DOSFS_GetDosTrueName( path, TRUE );
|
|
DRIVE_SetCurrentDrive( drive );
|
|
DRIVE_Chdir( drive, cwd + 2 );
|
|
}
|
|
|
|
if (!(DIR_GetPath( "windows", "c:\\windows",
|
|
&DIR_WindowsDosDir, &DIR_WindowsUnixDir ))) return 0;
|
|
if (!(DIR_GetPath( "system", "c:\\windows\\system",
|
|
&DIR_SystemDosDir, &DIR_SystemUnixDir ))) return 0;
|
|
if (!(DIR_GetPath( "temp", "c:\\windows",
|
|
&DIR_TempDosDir, &DIR_TempUnixDir ))) return 0;
|
|
|
|
if (drive == -1)
|
|
{
|
|
drive = DIR_WindowsDosDir[0] - 'A';
|
|
DRIVE_SetCurrentDrive( drive );
|
|
DRIVE_Chdir( drive, DIR_WindowsDosDir + 2 );
|
|
}
|
|
|
|
PROFILE_GetWineIniString("wine", "path", "c:\\windows;c:\\windows\\system",
|
|
path, sizeof(path) );
|
|
DIR_ParseWindowsPath( path );
|
|
|
|
dprintf_dosfs( stddeb, "WindowsDir = %s\nSystemDir = %s\n",
|
|
DIR_WindowsDosDir, DIR_SystemDosDir );
|
|
dprintf_dosfs( stddeb, "TempDir = %s\nCwd = %c:\\%s\n",
|
|
DIR_TempDosDir, 'A' + drive, DRIVE_GetDosCwd( drive ) );
|
|
|
|
/* Put the temp and Windows directories into the environment */
|
|
|
|
env_p = (char *)xmalloc( strlen(DIR_TempDosDir) + 6 );
|
|
strcpy( env_p, "TEMP=" );
|
|
strcpy( env_p + 5, DIR_TempDosDir );
|
|
putenv( env_p );
|
|
env_p = (char *)xmalloc( strlen(DIR_WindowsDosDir) + 8 );
|
|
strcpy( env_p, "windir=" );
|
|
strcpy( env_p + 7, DIR_WindowsDosDir );
|
|
putenv( env_p );
|
|
|
|
return 1;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetTempPath32A (KERNEL32.292)
|
|
*/
|
|
UINT32 GetTempPath32A( UINT32 count, LPSTR path )
|
|
{
|
|
if (path) lstrcpyn32A( path, DIR_TempDosDir, count );
|
|
return strlen( DIR_TempDosDir );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetTempPath32W (KERNEL32.293)
|
|
*/
|
|
UINT32 GetTempPath32W( UINT32 count, LPWSTR path )
|
|
{
|
|
LPSTR tmp = (char*)xmalloc(count);
|
|
UINT32 len = GetTempPath32A( count, tmp );
|
|
if (path) STRING32_AnsiToUni( path, tmp );
|
|
free(tmp);
|
|
return len;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DIR_GetTempUnixDir
|
|
*/
|
|
UINT DIR_GetTempUnixDir( LPSTR path, UINT count )
|
|
{
|
|
if (path) lstrcpyn32A( path, DIR_TempUnixDir, count );
|
|
return strlen( DIR_TempUnixDir );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DIR_GetWindowsUnixDir
|
|
*/
|
|
UINT DIR_GetWindowsUnixDir( LPSTR path, UINT count )
|
|
{
|
|
if (path) lstrcpyn32A( path, DIR_WindowsUnixDir, count );
|
|
return strlen( DIR_WindowsUnixDir );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DIR_GetSystemUnixDir
|
|
*/
|
|
UINT DIR_GetSystemUnixDir( LPSTR path, UINT count )
|
|
{
|
|
if (path) lstrcpyn32A( path, DIR_SystemUnixDir, count );
|
|
return strlen( DIR_SystemUnixDir );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DIR_GetDosPath
|
|
*/
|
|
UINT DIR_GetDosPath( int element, LPSTR path, UINT count )
|
|
{
|
|
if ((element < 0) || (element >= DIR_PathElements)) return 0;
|
|
if (path) lstrcpyn32A( path, DIR_DosPath[element], count );
|
|
return strlen( DIR_DosPath[element] );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetTempDrive (KERNEL.92)
|
|
*/
|
|
BYTE GetTempDrive( BYTE ignored )
|
|
{
|
|
/* FIXME: apparently Windows does something with the ignored byte */
|
|
return DIR_TempDosDir[0];
|
|
}
|
|
|
|
|
|
UINT32 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 );
|
|
}
|
|
|
|
/***********************************************************************
|
|
* GetWindowsDirectory (KERNEL.134)
|
|
*/
|
|
UINT GetWindowsDirectory( LPSTR path, UINT count )
|
|
{
|
|
if (path) lstrcpyn32A( path, DIR_WindowsDosDir, count );
|
|
return strlen( DIR_WindowsDosDir );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetSystemDirectory16 (KERNEL.135)
|
|
*/
|
|
UINT16 GetSystemDirectory16( LPSTR path, UINT16 count )
|
|
{
|
|
return (UINT16)GetSystemDirectory32A( path, count );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetSystemDirectory32A (KERNEL32.282)
|
|
*/
|
|
UINT32 GetSystemDirectory32A( LPSTR path, UINT32 count )
|
|
{
|
|
if (path) lstrcpyn32A( path, DIR_SystemDosDir, count );
|
|
return strlen( DIR_SystemDosDir );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetSystemDirectory32W (KERNEL32.283)
|
|
*/
|
|
UINT32 GetSystemDirectory32W( LPWSTR path, UINT32 count )
|
|
{
|
|
if (path)
|
|
{
|
|
LPWSTR tmp = STRING32_DupAnsiToUni( DIR_SystemDosDir );
|
|
lstrcpyn32W( path, tmp, count );
|
|
free (tmp);
|
|
}
|
|
return strlen( DIR_SystemDosDir );
|
|
}
|