Commit bf67259a authored by Alexandre Julliard's avatar Alexandre Julliard

Use the DRIVE_* API constants instead of the DRIVETYPE enum.

Changed DRIVE_CANNOTDETERMINE and DRIVE_DOESNOTEXIST to use the correct names. Cleaned up a few dependencies on internal drive.c functions.
parent c9b3b2e8
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "user.h" #include "user.h"
#include "heap.h" #include "heap.h"
#include "controls.h" #include "controls.h"
#include "drive.h"
#include "debugtools.h" #include "debugtools.h"
#include "tweak.h" #include "tweak.h"
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "wine/winbase16.h" #include "wine/winbase16.h"
#include "winuser.h" #include "winuser.h"
#include "winerror.h" #include "winerror.h"
#include "drive.h"
#include "heap.h" #include "heap.h"
#include "spy.h" #include "spy.h"
#include "selectors.h" #include "selectors.h"
...@@ -1736,10 +1735,11 @@ static LRESULT LISTBOX_Directory( WND *wnd, LB_DESCR *descr, UINT attrib, ...@@ -1736,10 +1735,11 @@ static LRESULT LISTBOX_Directory( WND *wnd, LB_DESCR *descr, UINT attrib,
if ((ret >= 0) && (attrib & DDL_DRIVES)) if ((ret >= 0) && (attrib & DDL_DRIVES))
{ {
char buffer[] = "[-a-]"; char buffer[] = "[-a-]";
char root[] = "A:\\";
int drive; int drive;
for (drive = 0; drive < MAX_DOS_DRIVES; drive++, buffer[2]++) for (drive = 0; drive < 26; drive++, buffer[2]++, root[0]++)
{ {
if (!DRIVE_IsValid(drive)) continue; if (GetDriveTypeA(root) <= DRIVE_NO_ROOT_DIR) continue;
if ((ret = LISTBOX_InsertString( wnd, descr, -1, buffer )) < 0) if ((ret = LISTBOX_InsertString( wnd, descr, -1, buffer )) < 0)
break; break;
} }
......
...@@ -610,7 +610,7 @@ static LONG FILEDLG_WMInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam) ...@@ -610,7 +610,7 @@ static LONG FILEDLG_WMInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
for(i = 0, n = -1; i < 26; i++) for(i = 0, n = -1; i < 26; i++)
{ {
str[0] = 'a' + i; str[0] = 'a' + i;
if (GetDriveTypeA(str) != DRIVE_DOESNOTEXIST) n++; if (GetDriveTypeA(str) <= DRIVE_NO_ROOT_DIR) n++;
if (toupper(str[0]) == toupper(dir[0])) break; if (toupper(str[0]) == toupper(dir[0])) break;
} }
} }
......
...@@ -843,8 +843,8 @@ UINT16 WINAPI DriveType16( UINT16 drive ) ...@@ -843,8 +843,8 @@ UINT16 WINAPI DriveType16( UINT16 drive )
case DRIVE_CDROM: case DRIVE_CDROM:
ret = DRIVE_REMOTE; ret = DRIVE_REMOTE;
break; break;
case DRIVE_DOESNOTEXIST: case DRIVE_NO_ROOT_DIR:
ret = DRIVE_CANNOTDETERMINE; ret = DRIVE_UNKNOWN;
break; break;
} }
return ret; return ret;
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "winbase.h" #include "winbase.h"
#include "wine/winnet16.h" #include "wine/winnet16.h"
#include "winnetwk.h" #include "winnetwk.h"
#include "drive.h"
#include "debugtools.h" #include "debugtools.h"
#include "heap.h" #include "heap.h"
...@@ -167,34 +166,29 @@ WORD WINAPI WNetCancelConnection16( LPSTR lpName, BOOL16 bForce ) ...@@ -167,34 +166,29 @@ WORD WINAPI WNetCancelConnection16( LPSTR lpName, BOOL16 bForce )
WORD WINAPI WNetGetConnection16( LPSTR lpLocalName, WORD WINAPI WNetGetConnection16( LPSTR lpLocalName,
LPSTR lpRemoteName, UINT16 *cbRemoteName ) LPSTR lpRemoteName, UINT16 *cbRemoteName )
{ {
const char *path; char label[32];
TRACE( "local %s\n", lpLocalName ); TRACE( "local %s\n", lpLocalName );
if (lpLocalName[1] == ':') switch(GetDriveTypeA(lpLocalName))
{ {
int drive = toupper(lpLocalName[0]) - 'A'; case DRIVE_REMOTE:
switch(GetDriveTypeA(lpLocalName)) GetVolumeInformationA( lpLocalName, label, sizeof(label), NULL, NULL, NULL, NULL, 0 );
if (strlen(label) + 1 > *cbRemoteName)
{ {
case DRIVE_REMOTE: *cbRemoteName = strlen(label) + 1;
path = DRIVE_GetLabel(drive); return WN16_MORE_DATA;
if (strlen(path) + 1 > *cbRemoteName)
{
*cbRemoteName = strlen(path) + 1;
return WN16_MORE_DATA;
}
strcpy( lpRemoteName, path );
*cbRemoteName = strlen(lpRemoteName) + 1;
return WN16_SUCCESS;
case DRIVE_REMOVABLE:
case DRIVE_FIXED:
case DRIVE_CDROM:
TRACE("file is local\n");
return WN16_NOT_CONNECTED;
default:
return WN16_BAD_LOCALNAME;
} }
strcpy( lpRemoteName, label );
*cbRemoteName = strlen(lpRemoteName) + 1;
return WN16_SUCCESS;
case DRIVE_REMOVABLE:
case DRIVE_FIXED:
case DRIVE_CDROM:
TRACE("file is local\n");
return WN16_NOT_CONNECTED;
default:
return WN16_BAD_LOCALNAME;
} }
return WN16_BAD_LOCALNAME;
} }
/************************************************************************** /**************************************************************************
...@@ -396,7 +390,7 @@ WORD WINAPI WNetGetPropertyText16( WORD iButton, WORD nPropSel, LPSTR lpszName, ...@@ -396,7 +390,7 @@ WORD WINAPI WNetGetPropertyText16( WORD iButton, WORD nPropSel, LPSTR lpszName,
WORD WINAPI WNetGetDirectoryType16( LPSTR lpName, LPINT16 lpType ) WORD WINAPI WNetGetDirectoryType16( LPSTR lpName, LPINT16 lpType )
{ {
UINT type = GetDriveTypeA(lpName); UINT type = GetDriveTypeA(lpName);
if ( type == DRIVE_DOESNOTEXIST ) if ( type == DRIVE_NO_ROOT_DIR )
type = GetDriveTypeA(NULL); type = GetDriveTypeA(NULL);
*lpType = (type == DRIVE_REMOTE)? WNDT_NETWORK : WNDT_NORMAL; *lpType = (type == DRIVE_REMOTE)? WNDT_NETWORK : WNDT_NORMAL;
......
...@@ -11,15 +11,6 @@ ...@@ -11,15 +11,6 @@
#define MAX_DOS_DRIVES 26 #define MAX_DOS_DRIVES 26
typedef enum
{
TYPE_FLOPPY,
TYPE_HD,
TYPE_CDROM,
TYPE_NETWORK,
TYPE_INVALID
} DRIVETYPE;
/* Drive flags */ /* Drive flags */
#define DRIVE_DISABLED 0x0001 /* Drive is disabled */ #define DRIVE_DISABLED 0x0001 /* Drive is disabled */
...@@ -41,7 +32,6 @@ extern const char * DRIVE_GetDevice( int drive ); ...@@ -41,7 +32,6 @@ extern const char * DRIVE_GetDevice( int drive );
extern const char * DRIVE_GetLabel( int drive ); extern const char * DRIVE_GetLabel( int drive );
extern DWORD DRIVE_GetSerialNumber( int drive ); extern DWORD DRIVE_GetSerialNumber( int drive );
extern int DRIVE_SetSerialNumber( int drive, DWORD serial ); extern int DRIVE_SetSerialNumber( int drive, DWORD serial );
extern DRIVETYPE DRIVE_GetType( int drive );
extern UINT DRIVE_GetFlags( int drive ); extern UINT DRIVE_GetFlags( int drive );
extern int DRIVE_Chdir( int drive, const char *path ); extern int DRIVE_Chdir( int drive, const char *path );
extern int DRIVE_Disable( int drive ); extern int DRIVE_Disable( int drive );
......
...@@ -164,8 +164,8 @@ typedef struct ...@@ -164,8 +164,8 @@ typedef struct
/* GetTempFileName() Flags */ /* GetTempFileName() Flags */
#define TF_FORCEDRIVE 0x80 #define TF_FORCEDRIVE 0x80
#define DRIVE_CANNOTDETERMINE 0 #define DRIVE_UNKNOWN 0
#define DRIVE_DOESNOTEXIST 1 #define DRIVE_NO_ROOT_DIR 1
#define DRIVE_REMOVABLE 2 #define DRIVE_REMOVABLE 2
#define DRIVE_FIXED 3 #define DRIVE_FIXED 3
#define DRIVE_REMOTE 4 #define DRIVE_REMOTE 4
......
...@@ -42,8 +42,9 @@ int CDROM_Open(WINE_CDAUDIO* wcda, int drive) ...@@ -42,8 +42,9 @@ int CDROM_Open(WINE_CDAUDIO* wcda, int drive)
if (drive == -1) if (drive == -1)
{ {
for (i=0; i < MAX_DOS_DRIVES; i++) char root[] = "A:\\";
if (DRIVE_GetType(i) == TYPE_CDROM) for (i=0; i < MAX_DOS_DRIVES; i++, root[0]++)
if (GetDriveTypeA(root) == DRIVE_CDROM)
{ {
drive = i; drive = i;
avail = TRUE; avail = TRUE;
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "windef.h" #include "windef.h"
#include "miscemu.h" #include "miscemu.h"
#include "msdos.h" #include "msdos.h"
#include "drive.h"
#include "debugtools.h" #include "debugtools.h"
#include "options.h" #include "options.h"
...@@ -51,8 +50,8 @@ void WINAPI INT_Int11Handler( CONTEXT86 *context ) ...@@ -51,8 +50,8 @@ void WINAPI INT_Int11Handler( CONTEXT86 *context )
bit 2 (always set) bit 2 (always set)
*/ */
if (DRIVE_IsValid(0)) diskdrives++; if (GetDriveTypeA("A:\\") == DRIVE_REMOVABLE) diskdrives++;
if (DRIVE_IsValid(1)) diskdrives++; if (GetDriveTypeA("B:\\") == DRIVE_REMOVABLE) diskdrives++;
if (diskdrives) diskdrives--; if (diskdrives) diskdrives--;
for (x=0; x < 9; x++) for (x=0; x < 9; x++)
......
...@@ -63,11 +63,12 @@ void WINAPI INT_Int13Handler( CONTEXT86 *context ) ...@@ -63,11 +63,12 @@ void WINAPI INT_Int13Handler( CONTEXT86 *context )
BYTE drive_nr = DL_reg(context); BYTE drive_nr = DL_reg(context);
int floppy_fd; int floppy_fd;
struct floppy_drive_params floppy_parm; struct floppy_drive_params floppy_parm;
char root[] = "A:\\";
AH_reg(context) = 0x00; /* success */ AH_reg(context) = 0x00; /* success */
for (i = 0; i < MAX_DOS_DRIVES; i++) for (i = 0; i < MAX_DOS_DRIVES; i++, root[0]++)
if (DRIVE_GetType(i) == TYPE_FLOPPY) nr_of_drives++; if (GetDriveTypeA(root) == DRIVE_REMOVABLE) nr_of_drives++;
DL_reg(context) = nr_of_drives; DL_reg(context) = nr_of_drives;
if (drive_nr > 1) { /* invalid drive ? */ if (drive_nr > 1) { /* invalid drive ? */
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "miscemu.h" #include "miscemu.h"
#include "debugtools.h" #include "debugtools.h"
#include "msdos.h" #include "msdos.h"
#include "drive.h"
#include "winnt.h" #include "winnt.h"
DEFAULT_DEBUG_CHANNEL(int17); DEFAULT_DEBUG_CHANNEL(int17);
......
...@@ -383,7 +383,7 @@ static BOOL ioctlGenericBlkDevReq( CONTEXT86 *context ) ...@@ -383,7 +383,7 @@ static BOOL ioctlGenericBlkDevReq( CONTEXT86 *context )
case 0x72: case 0x72:
/* Trail on error implementation */ /* Trail on error implementation */
AX_reg(context) = GetDriveType16(BL_reg(context)) == DRIVE_CANNOTDETERMINE ? 0x0f : 0x01; AX_reg(context) = GetDriveType16(BL_reg(context)) == DRIVE_UNKNOWN ? 0x0f : 0x01;
SET_CFLAG(context); /* Seems to be set all the time */ SET_CFLAG(context); /* Seems to be set all the time */
break; break;
...@@ -1651,7 +1651,7 @@ void WINAPI DOS3Call( CONTEXT86 *context ) ...@@ -1651,7 +1651,7 @@ void WINAPI DOS3Call( CONTEXT86 *context )
INT21_DriveName( BL_reg(context))); INT21_DriveName( BL_reg(context)));
switch(GetDriveType16( DOS_GET_DRIVE( BL_reg(context) ))) switch(GetDriveType16( DOS_GET_DRIVE( BL_reg(context) )))
{ {
case DRIVE_CANNOTDETERMINE: case DRIVE_UNKNOWN:
SetLastError( ERROR_INVALID_DRIVE ); SetLastError( ERROR_INVALID_DRIVE );
AX_reg(context) = ERROR_INVALID_DRIVE; AX_reg(context) = ERROR_INVALID_DRIVE;
SET_CFLAG(context); SET_CFLAG(context);
...@@ -1670,7 +1670,7 @@ void WINAPI DOS3Call( CONTEXT86 *context ) ...@@ -1670,7 +1670,7 @@ void WINAPI DOS3Call( CONTEXT86 *context )
INT21_DriveName( BL_reg(context))); INT21_DriveName( BL_reg(context)));
switch(GetDriveType16( DOS_GET_DRIVE( BL_reg(context) ))) switch(GetDriveType16( DOS_GET_DRIVE( BL_reg(context) )))
{ {
case DRIVE_CANNOTDETERMINE: case DRIVE_UNKNOWN:
SetLastError( ERROR_INVALID_DRIVE ); SetLastError( ERROR_INVALID_DRIVE );
AX_reg(context) = ERROR_INVALID_DRIVE; AX_reg(context) = ERROR_INVALID_DRIVE;
SET_CFLAG(context); SET_CFLAG(context);
...@@ -2241,37 +2241,20 @@ void WINAPI DOS3Call( CONTEXT86 *context ) ...@@ -2241,37 +2241,20 @@ void WINAPI DOS3Call( CONTEXT86 *context )
{ {
LPCSTR driveroot = (LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs,context->Edx); LPCSTR driveroot = (LPCSTR)CTX_SEG_OFF_TO_LIN(context, context->SegDs,context->Edx);
LPSTR buffer = (LPSTR)CTX_SEG_OFF_TO_LIN(context, context->SegEs,context->Edi); LPSTR buffer = (LPSTR)CTX_SEG_OFF_TO_LIN(context, context->SegEs,context->Edi);
int drive; DWORD filename_len, flags;
UINT flags;
TRACE("LONG FILENAME - GET VOLUME INFORMATION for drive having root dir '%s'.\n", driveroot); TRACE("LONG FILENAME - GET VOLUME INFORMATION for drive having root dir '%s'.\n", driveroot);
AX_reg(context) = 0; AX_reg(context) = 0;
if (!driveroot) if (!GetVolumeInformationA( driveroot, NULL, 0, NULL, &filename_len,
{ &flags, buffer, 8 ))
INT_BARF( context, 0x21 ); {
SET_CFLAG(context); INT_BARF( context, 0x21 );
break; SET_CFLAG(context);
} break;
drive = toupper(driveroot[0]) - 'A'; }
flags = DRIVE_GetFlags(toupper(driveroot[0]) - 'A'); BX_reg(context) = flags | 0x4000; /* support for LFN functions */
BX_reg(context) = 0x4000; /* support for LFN functions */ CX_reg(context) = filename_len;
if (flags & DRIVE_CASE_SENSITIVE)
BX_reg(context) |= 1;
if (flags & DRIVE_CASE_PRESERVING)
BX_reg(context) |= 2;
/***** FIXME: not supported yet (needed ?)
if (flags & DRIVE_UNICODE)
BX_reg(context) |= 4;
if (flags & DRIVE_COMPRESSED)
BX_reg(context) |= 0x8000;
*****/
CX_reg(context) = (flags & DRIVE_SHORT_NAMES) ? 11 : 255; /* FIXME: 12 ? */
DX_reg(context) = MAX_PATH; /* FIXME: which len if DRIVE_SHORT_NAMES ? */ DX_reg(context) = MAX_PATH; /* FIXME: which len if DRIVE_SHORT_NAMES ? */
if (DRIVE_GetType(drive) == TYPE_CDROM)
/* valid for data _and_ audio */
strcpy(buffer, "CDFS"); /* FIXME: fail if no CD in drive */
else
strcpy(buffer, "FAT");
} }
break; break;
case 0xa1: /* Find close */ case 0xa1: /* Find close */
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "wine/winbase16.h" #include "wine/winbase16.h"
#include "dosexe.h" #include "dosexe.h"
#include "drive.h"
#include "miscemu.h" #include "miscemu.h"
#include "module.h" #include "module.h"
#include "task.h" #include "task.h"
...@@ -424,6 +423,13 @@ static void MSCDEX_StoreMSF(DWORD frame, BYTE* val) ...@@ -424,6 +423,13 @@ static void MSCDEX_StoreMSF(DWORD frame, BYTE* val)
val[0] = frame - CDFRAMES_PERMIN * val[2] - CDFRAMES_PERSEC * val[1]; /* frames */ val[0] = frame - CDFRAMES_PERMIN * val[2] - CDFRAMES_PERSEC * val[1]; /* frames */
} }
static int is_cdrom( int drive)
{
char root[] = "A:\\";
root[0] += drive;
return (GetDriveTypeA(root) == DRIVE_CDROM);
}
static void MSCDEX_Handler(CONTEXT86* context) static void MSCDEX_Handler(CONTEXT86* context)
{ {
int drive, count; int drive, count;
...@@ -433,19 +439,19 @@ static void MSCDEX_Handler(CONTEXT86* context) ...@@ -433,19 +439,19 @@ static void MSCDEX_Handler(CONTEXT86* context)
case 0x00: /* Installation check */ case 0x00: /* Installation check */
/* Count the number of contiguous CDROM drives /* Count the number of contiguous CDROM drives
*/ */
for (drive = count = 0; drive < MAX_DOS_DRIVES; drive++) { for (drive = count = 0; drive < 26; drive++) {
if (DRIVE_GetType(drive) == TYPE_CDROM) { if (is_cdrom(drive)) {
while (DRIVE_GetType(drive + count) == TYPE_CDROM) count++; while (is_cdrom(drive + count)) count++;
break; break;
} }
} }
TRACE("Installation check: %d cdroms, starting at %d\n", count, drive); TRACE("Installation check: %d cdroms, starting at %d\n", count, drive);
BX_reg(context) = count; BX_reg(context) = count;
CX_reg(context) = (drive < MAX_DOS_DRIVES) ? drive : 0; CX_reg(context) = (drive < 26) ? drive : 0;
break; break;
case 0x0B: /* drive check */ case 0x0B: /* drive check */
AX_reg(context) = (DRIVE_GetType(CX_reg(context)) == TYPE_CDROM); AX_reg(context) = is_cdrom(CX_reg(context));
BX_reg(context) = 0xADAD; BX_reg(context) = 0xADAD;
break; break;
...@@ -456,9 +462,9 @@ static void MSCDEX_Handler(CONTEXT86* context) ...@@ -456,9 +462,9 @@ static void MSCDEX_Handler(CONTEXT86* context)
case 0x0D: /* get drive letters */ case 0x0D: /* get drive letters */
p = CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Ebx); p = CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Ebx);
memset(p, 0, MAX_DOS_DRIVES); memset(p, 0, 26);
for (drive = 0; drive < MAX_DOS_DRIVES; drive++) { for (drive = 0; drive < 26; drive++) {
if (DRIVE_GetType(drive) == TYPE_CDROM) *p++ = drive; if (is_cdrom(drive)) *p++ = drive;
} }
TRACE("Get drive letters\n"); TRACE("Get drive letters\n");
break; break;
...@@ -490,9 +496,7 @@ static void MSCDEX_Handler(CONTEXT86* context) ...@@ -490,9 +496,7 @@ static void MSCDEX_Handler(CONTEXT86* context)
dev = CDROM_OpenDev(&wcda); dev = CDROM_OpenDev(&wcda);
TRACE("CDROM device driver -> command <%d>\n", (unsigned char)driver_request[2]); TRACE("CDROM device driver -> command <%d>\n", (unsigned char)driver_request[2]);
for (drive = 0; for (drive = 0; drive < 26; drive++) if (is_cdrom(drive)) break;
drive < MAX_DOS_DRIVES && DRIVE_GetType(drive) != TYPE_CDROM;
drive++);
/* drive contains the first CD ROM */ /* drive contains the first CD ROM */
if (CX_reg(context) != drive) { if (CX_reg(context) != drive) {
WARN("Request made doesn't match a CD ROM drive (%d/%d)\n", CX_reg(context), drive); WARN("Request made doesn't match a CD ROM drive (%d/%d)\n", CX_reg(context), drive);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment