wine/files/directory.c
Alexandre Julliard d90840e180 Release 960611
Tue Jun 11 15:20:43 1996  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [debugger/break.c] [loader/signal.c]
	Fixed breakpoints in 32-bit code.

	* [include/windows.h]
	Added many more Win32 versions of standard structures.

	* [include/winreg.h] [misc/registry.c]
	Moved private types into registry.c.

	* [memory/string.c] (New file)
	Moved most string functions from misc/lstr.c; added Win32 version
	of all functions.

	* [misc/wsprintf.c]
	Implemented Win32 wsprintf functions.

	* [objects/bitmap.c]
	Implemented Win32 bitmap functions.

	* [windows/dialog.c]
	Don't set dialog procedure before the controls are created. This
	avoids a crash in Winhelp.

Tue Jun 11 14:10:06 1996 Martin von Loewis <loewis@informatik.hu-berlin.de>

	* [controls/menu.c] [if1632/user.spec] [windows/message.c]
	Replace PeekMessage with PeekMessage16.

	* [if1632/kernel32.spec][misc/main.c]
	GetVersion32,GetVersionEx32A,GetVersionEx32W: new functions.
	MAIN_ParseVersion: new function, new command line option -winver.
	GetVersion: modified to take command line argument into account.

	* [if1632/kernel32.spec] [win32/process.c]
	FreeLibrary32: new function.
	TlsAlloc: initialize Tls to zero.
	InterlockedIncrement,InterlockedDecrement,InterlockedExchange: new
	functions.

	* [if1632/kernel32.spec]
	SetErrorMode,GetActiveWindow: new relays to existing functions.

	* [if1632/kernel32.spec][win32/user32.c]
	PeekMessage32A,PeekMessage32W: new functions.

	* [include/struct32.h][include/windows.h]
	Moved MSG32 to windows.h.
	Renamed MSG to MSG16.
	Modified prototypes to use MSG16

	* [include/winbase.h]
	OSVERSIONINFO32A,OSVERSIONINFO32W: new structures.

Sun Jun  9 20:53:30 1996  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>

	* [if1632/Makefile.in] [loader/builtin.c]
	version.dll,lz32.dll added.

	* [include/lzexpand.h] [if1632/lz32.spec] [if1632/lzexpand.spec]
	  [misc/lzexpand.c]
	lz32.dll added.
	Modified to new function naming standard.

	* [include/ver.h] [if1632/ver.spec] [if1632/version.spec] [misc/ver.c]
	version.dll added (win32 version of ver.dll).
	Modified to new function naming standard.
	Use registry to look up a LOCALE langids too.
	(VerInstallFile,VerFindFile still stubs)

Fri Jun  7 20:40:20 1996  Albrecht Kleine  <kleine@ak.sax.de>

	* [files/file.c]
	Added a warning if GetTempFileName() gets a bad drive parameter.

	* [misc/commdlg.c]
	Changed file listbox color to gray in SaveFile dialog 
	(just like Windows does this).
1996-06-11 16:02:08 +00:00

258 lines
7.3 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 (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;
}
/***********************************************************************
* DIR_GetTempDosDir
*/
UINT DIR_GetTempDosDir( LPSTR path, UINT count )
{
if (path) lstrcpyn32A( path, DIR_TempDosDir, count );
return strlen( DIR_TempDosDir );
}
/***********************************************************************
* 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 )
{
return DIR_TempDosDir[0];
}
/***********************************************************************
* GetWindowsDirectory (KERNEL.134)
*/
UINT GetWindowsDirectory( LPSTR path, UINT count )
{
if (path) lstrcpyn32A( path, DIR_WindowsDosDir, count );
return strlen( DIR_WindowsDosDir );
}
/***********************************************************************
* GetSystemDirectory (KERNEL.135)
*/
UINT GetSystemDirectory( LPSTR path, UINT count )
{
if (path) lstrcpyn32A( path, DIR_SystemDosDir, count );
return strlen( DIR_SystemDosDir );
}