Got rid of DRIVE_OpenDevice, and replaced it with Win32 equivalents.

This commit is contained in:
Eric Pouech 2003-11-25 01:51:07 +00:00 committed by Alexandre Julliard
parent 392cbdf7b8
commit ff0365290b
6 changed files with 30 additions and 31 deletions

View File

@ -1147,7 +1147,6 @@
@ cdecl DOSMEM_GetBlock(long ptr)
@ cdecl DOSMEM_Init(long)
@ cdecl DOSMEM_ResizeBlock(ptr long long)
@ cdecl DRIVE_OpenDevice(long long)
@ cdecl FILE_Dup2(long long)
@ cdecl LOCAL_Alloc(long long long)
@ cdecl LOCAL_Compact(long long long)

View File

@ -35,8 +35,8 @@
#endif
#include "dosexe.h"
#include "wine/server.h"
#include "wine/debug.h"
#include "drive.h"
WINE_DEFAULT_DEBUG_CHANNEL(int);
@ -98,7 +98,8 @@ static void INT13_ReadFloppyParams( CONTEXT86 *context )
int floppy_fd;
int r;
struct floppy_drive_params floppy_parm;
char root[] = "A:\\";
WCHAR root[] = {'A',':','\\',0}, drive_root[] = {'\\','\\','.','\\','A',':',0};
HANDLE h;
TRACE("in [ EDX=%08lx ]\n", context->Edx );
@ -108,7 +109,7 @@ static void INT13_ReadFloppyParams( CONTEXT86 *context )
SET_DH( context, 0 );
for (i = 0; i < MAX_DOS_DRIVES; i++, root[0]++)
if (GetDriveTypeA(root) == DRIVE_REMOVABLE) nr_of_drives++;
if (GetDriveTypeW(root) == DRIVE_REMOVABLE) nr_of_drives++;
SET_DL( context, nr_of_drives );
if (drive_nr > 1) {
@ -117,7 +118,11 @@ static void INT13_ReadFloppyParams( CONTEXT86 *context )
return;
}
if ( (floppy_fd = DRIVE_OpenDevice( drive_nr, O_RDONLY|O_NONBLOCK)) == -1)
drive_root[4] = 'A' + drive_nr;
h = CreateFileW(drive_root, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (h == INVALID_HANDLE_VALUE ||
wine_server_handle_to_fd(h, GENERIC_READ, &floppy_fd, NULL, NULL))
{
WARN("Can't determine floppy geometry !\n");
INT13_SetStatus( context, 0x07 ); /* drive parameter activity failed */
@ -126,6 +131,7 @@ static void INT13_ReadFloppyParams( CONTEXT86 *context )
r = ioctl(floppy_fd, FDGETDRVPRM, &floppy_parm);
close(floppy_fd);
CloseHandle(h);
if(r<0)
{

View File

@ -27,7 +27,6 @@
# include <unistd.h>
#endif
#include "dosexe.h"
#include "drive.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(int);
@ -40,17 +39,22 @@ WINE_DEFAULT_DEBUG_CHANNEL(int);
*/
BOOL DOSVM_RawRead(BYTE drive, DWORD begin, DWORD nr_sect, BYTE *dataptr, BOOL fake_success)
{
int fd;
WCHAR root[] = {'\\','\\','.','\\','A',':',0};
HANDLE h;
if ((fd = DRIVE_OpenDevice( drive, O_RDONLY )) != -1)
root[4] += drive;
h = CreateFileW(root, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (h != INVALID_HANDLE_VALUE)
{
lseek( fd, begin * 512, SEEK_SET );
SetFilePointer(h, begin * 512, NULL, SEEK_SET );
/* FIXME: check errors */
read( fd, dataptr, nr_sect * 512 );
close( fd );
ReadFile(h, dataptr, nr_sect * 512, NULL, NULL );
CloseHandle(h);
}
else
{
if (h != INVALID_HANDLE_VALUE) CloseHandle(h);
memset( dataptr, 0, nr_sect * 512 );
if (fake_success)
{

View File

@ -26,7 +26,6 @@
# include <unistd.h>
#endif
#include "dosexe.h"
#include "drive.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(int);
@ -39,14 +38,18 @@ WINE_DEFAULT_DEBUG_CHANNEL(int);
*/
BOOL DOSVM_RawWrite(BYTE drive, DWORD begin, DWORD nr_sect, BYTE *dataptr, BOOL fake_success)
{
int fd;
WCHAR root[] = {'\\','\\','.','\\','A',':',0};
HANDLE h;
if ((fd = DRIVE_OpenDevice( drive, O_RDONLY )) != -1)
root[4] += drive;
h = CreateFileW(root, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
0, NULL);
if (h != INVALID_HANDLE_VALUE)
{
lseek( fd, begin * 512, SEEK_SET );
SetFilePointer(h, begin * 512, NULL, SEEK_SET );
/* FIXME: check errors */
write( fd, dataptr, nr_sect * 512 );
close( fd );
WriteFile( h, dataptr, nr_sect * 512, NULL, NULL );
CloseHandle( h );
}
else if (!fake_success)
return FALSE;

View File

@ -1364,18 +1364,6 @@ BOOL WINAPI DefineDosDeviceW(DWORD flags,LPCWSTR devname,LPCWSTR targetpath)
}
/***********************************************************************
* DRIVE_OpenDevice
*
* Open the drive raw device and return a Unix fd (or -1 on error).
*/
int DRIVE_OpenDevice( int drive, int flags )
{
if (!DRIVE_IsValid( drive )) return -1;
return open( DOSDrives[drive].device, flags );
}
/***********************************************************************
* DRIVE_GetFreeSpace
*/

View File

@ -51,7 +51,6 @@ extern UINT DRIVE_GetFlags( int drive );
extern int DRIVE_Chdir( int drive, LPCWSTR path );
extern int DRIVE_Disable( int drive );
extern int DRIVE_Enable( int drive );
extern int DRIVE_OpenDevice( int drive, int flags );
extern WCHAR *DRIVE_BuildEnv(void);
#endif /* __WINE_DRIVE_H */