mirror of
https://github.com/reactos/wine.git
synced 2024-12-11 13:26:00 +00:00
2c69f6d8e9
Fri Sep 27 14:18:42 1996 Alexandre Julliard <julliard@lrc.epfl.ch> * [controls/button.c] Fixed focus rectangle size and clipping. * [controls/scroll.c] Converted to Win32 and added support for scroll page. Completed SetScrollInfo() and implemented other Win32 functions. * [files/file.c] Removed FILE_Read() (use _lread32 instead). * [objects/dce.c] [include/dce.h] Allocate DCE on the Win32 heap, and use pointers instead of handles. Implemented Win32 version of DC functions. * [windows/painting.c] Attempt to make CS_PARENTDC style work again. Wed Sep 25 23:40:52 1996 Alex Korobka <alex@trantor.pharm.sunysb.edu> * [windows/dce.c] [windows/winpos.c] Override SaveUnder attribute when painting took place in a window below. Force X to raise activated window in seamless mode. * [misc/clipboard.c] [windows/event.c] Translation between DOS and Unix text formats and several other fixes for the sudden selection loss. * [windows/message.c] Apply "first" and "last" when checking for WM_QUIT in MSG_PeekMessage(). * [windows/win.c] Rearranged DestroyWindow() to fit "Windows Internals" description. * [windows/win.c] [windows/winpos.c] [windows/nonclient.c] Misc. fixes to CBT hook calls. * [controls/menu.c] [misc/user.c] Fixup resident popup menu window so that it doesn't get destroyed by USER_AppExit(). * [loader/module.c] [loader/task.c] [windows/event.c] Process "unsafe" X events outside the scheduler to prevent deadlocks. * [windows/message.c] [windows/queue.c] [windows/winpos.c] Lots of fixes for better Win16 multitasking. Wed Sep 25 20:36:30 1996 Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de> * [include/windows.h] Added some missing HOOK defines. * [misc/shell.c][if1632/shell32.spec][include/shell.h] SHGetFileInfoA stub added (win95 mplayer.exe /play bla.avi). * [win32/console.c][include/wincon.h] GetConsoleScreenBufferInfo, GetLargestConsoleWindowSize added. * [misc/registry.c] Some null ptr fixes. * [loader/pe_image.c] Fixed exported function lookup. (msvcrt20.dll) Add debugsyms for entrypoint, exported functions and sections. * [multimedia/mmsystem.c] MCIOpen: support for element opens (mplayer.exe /play bla.avi). * [several] Added several missing things/stubs/simple thunks from win32 to win16 code. Sat Sep 21 17:27:44 1996 O.Flebbe <flebbe@science-computing.uni-tuebingen.de> * [windows/property.c] Fixed debugging of 16 Bit RemoveProp(). * [debugger/memory.c] Added DEBUG_checkmap_bad() for linux. Thu Sep 19 20:48:31 1996 Albrecht Kleine <kleine@ak.sax.de> * [windows/event.c] [windows/hook.c] Use EnableHardwareInput() for JournalPlayback hook. * [controls/listbox.c] Changed handling of LB_GETITEMRECT in empty listboxes. Thu Sep 19 13:34:35 1996 Slaven Rezic <eserte@cs.tu-berlin.de> * [misc/main.c] Fixes to X resources handling. Wed Sep 18 00:31:15 1996 Huw D. M. Davies <h.davies1@physics.oxford.ac.uk> * [objects/metafile.c] [include/gdi.h] [objects/dc.c] Individual handle table created for each metafile. Fixed GlobalReAlloc() bug in MF_AddHandleDC() (was MF_AddHandleInternal). * [windows/graphics.c] [objects/dc.c] Rectangle() changed to work better with wide pens and PS_NULL. Use JoinMiter. * [windows/winpos.c] Make the whole (non X) window invalid on resize if CS_[VH]REDRAW is set. * [windows/nonclient.c] AdjustWindowRectEx() should perform calculations even if the window is minimized. * [windows/mdi.c] Better handling of system button painting. Maximized windows can contain scroll bars. Icons now maximize properly. * [windows/defwnd.c] [windows/nonclient.c] [controls/menu.c] Improved greying of items in system menu. WM_INITMEMUPOPUP no longer caught in DefWndProc, DEFWND_InitSysMenuPopup moved to menu.c. Mon Sep 16 21:30:00 1996 Uwe Bonnes <bon@elektron.ikp.physik.th-darmstadt.de> * [several files] Fix missing includes and wrong printing arguments. * [controls/listbox.c] Don't sort drives in ListBoxDirectory(). Sat Sep 14 09:05:47 1996 Petri Tuomola <ptuomola@xs4all.nl> * [windows/dialog.c] Fixed handling of Shift-TAB in dialogs. Thu Sep 12 18:31:00 1996 Thomas Sandford <t.d.g.sandford@prds-grn.demon.co.uk> * [if1632/gdi32.spec] Added SelectClipRgn - call win16 version. * [if1632/user32.spec] Added GetAsyncKeyState, GetMenuItemID and GetMenuStringA. * [include/wincon.h] Added COORD and SMALL_RECT typedefs, moved CONSOLE_SCREEN_BUFFER_INFO out of #if 0 protected portion of file. * [loader/pe_image.c] PE_InitTEB() - Tidy up, bug fix to stack pointer value (Borland programs now work better) * [win32/console.c] Added stub functions for GetConsoleScreenBufferInfo and GetLargestConsoleWindowSize * [win32/findfile.c] FindFirstFile32A() - removed erroneous strcpy * [windows/keyboard.c] GetAsyncKeyState() - bug fix - now returns value as per Microsoft specification. NB - I still have doubts about some other functions in this file.
327 lines
9.4 KiB
C
327 lines
9.4 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 "stddebug.h"
|
|
#include "debug.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 (-1==access(DIR_TempUnixDir,W_OK)) {
|
|
if (errno==EACCES)
|
|
fprintf(stderr,"Warning: The Temporary Directory (as specified in wine.conf) is NOT writeable. Please check your configuration.\n");
|
|
else
|
|
fprintf(stderr,"Warning: Access to Temporary Directory failed (%s).\n",strerror(errno));
|
|
}
|
|
|
|
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 )
|
|
{
|
|
if (path) lstrcpynAtoW( path, DIR_TempDosDir, count );
|
|
return strlen( DIR_TempDosDir );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DIR_GetTempUnixDir
|
|
*/
|
|
UINT32 DIR_GetTempUnixDir( LPSTR path, UINT32 count )
|
|
{
|
|
if (path) lstrcpyn32A( path, DIR_TempUnixDir, count );
|
|
return strlen( DIR_TempUnixDir );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DIR_GetWindowsUnixDir
|
|
*/
|
|
UINT32 DIR_GetWindowsUnixDir( LPSTR path, UINT32 count )
|
|
{
|
|
if (path) lstrcpyn32A( path, DIR_WindowsUnixDir, count );
|
|
return strlen( DIR_WindowsUnixDir );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DIR_GetSystemUnixDir
|
|
*/
|
|
UINT32 DIR_GetSystemUnixDir( LPSTR path, UINT32 count )
|
|
{
|
|
if (path) lstrcpyn32A( path, DIR_SystemUnixDir, count );
|
|
return strlen( DIR_SystemUnixDir );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DIR_GetDosPath
|
|
*/
|
|
UINT32 DIR_GetDosPath( INT32 element, LPSTR path, UINT32 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 );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetWindowsDirectory16 (KERNEL.134)
|
|
*/
|
|
UINT16 GetWindowsDirectory16( LPSTR path, UINT16 count )
|
|
{
|
|
return (UINT16)GetWindowsDirectory32A( path, count );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetWindowsDirectory32A (KERNEL32.311)
|
|
*/
|
|
UINT32 GetWindowsDirectory32A( LPSTR path, UINT32 count )
|
|
{
|
|
if (path) lstrcpyn32A( path, DIR_WindowsDosDir, count );
|
|
return strlen( DIR_WindowsDosDir );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetWindowsDirectory32W (KERNEL32.312)
|
|
*/
|
|
UINT32 GetWindowsDirectory32W( LPWSTR path, UINT32 count )
|
|
{
|
|
if (path) lstrcpynAtoW( 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) lstrcpynAtoW( path, DIR_SystemDosDir, count );
|
|
return strlen( DIR_SystemDosDir );
|
|
}
|