return drive and not-written bit for ioctl function 0
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2614
This commit is contained in:
parent
4b2a7a92c7
commit
e332fed532
7 changed files with 40 additions and 23 deletions
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: dos_system.h,v 1.34 2006-04-15 15:53:37 qbix79 Exp $ */
|
||||
/* $Id: dos_system.h,v 1.35 2006-04-23 14:20:57 c2woody Exp $ */
|
||||
|
||||
#ifndef DOSBOX_DOS_SYSTEM_H
|
||||
#define DOSBOX_DOS_SYSTEM_H
|
||||
|
@ -62,7 +62,7 @@ class DOS_DTA;
|
|||
|
||||
class DOS_File {
|
||||
public:
|
||||
DOS_File():flags(0) { name=0; refCtr = 0; };
|
||||
DOS_File():flags(0) { name=0; refCtr = 0; hdrive=0xff; };
|
||||
DOS_File(const DOS_File& orig);
|
||||
DOS_File & operator= (const DOS_File & orig);
|
||||
virtual ~DOS_File(){if(name) delete [] name;};
|
||||
|
@ -78,6 +78,8 @@ public:
|
|||
virtual void AddRef() { refCtr++; };
|
||||
virtual Bits RemoveRef() { return --refCtr; };
|
||||
virtual bool UpdateDateTimeFromHost() { return true; }
|
||||
void SetDrive(Bit8u drv) { hdrive=drv;}
|
||||
Bit8u GetDrive(void) { return hdrive;}
|
||||
Bit8u type;
|
||||
Bit32u flags;
|
||||
Bit16u time;
|
||||
|
@ -88,6 +90,8 @@ public:
|
|||
bool open;
|
||||
char* name;
|
||||
/* Some Device Specific Stuff */
|
||||
private:
|
||||
Bit8u hdrive;
|
||||
};
|
||||
|
||||
class DOS_Device : public DOS_File {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: dos_files.cpp,v 1.72 2006-03-10 09:38:24 qbix79 Exp $ */
|
||||
/* $Id: dos_files.cpp,v 1.73 2006-04-23 14:20:57 c2woody Exp $ */
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -410,6 +410,7 @@ bool DOS_CreateFile(char * name,Bit16u attributes,Bit16u * entry) {
|
|||
}
|
||||
bool foundit=Drives[drive]->FileCreate(&Files[handle],fullname,attributes);
|
||||
if (foundit) {
|
||||
Files[handle]->SetDrive(drive);
|
||||
Files[handle]->AddRef();
|
||||
psp.SetFileHandle(*entry,handle);
|
||||
return true;
|
||||
|
@ -462,6 +463,7 @@ bool DOS_OpenFile(char * name,Bit8u flags,Bit16u * entry) {
|
|||
Files[handle]=new DOS_Device(*Devices[devnum]);
|
||||
} else {
|
||||
exists=Drives[drive]->FileOpen(&Files[handle],fullname,flags);
|
||||
if (exists) Files[handle]->SetDrive(drive);
|
||||
}
|
||||
if (exists || device ) {
|
||||
Files[handle]->AddRef();
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: dos_ioctl.cpp,v 1.27 2006-04-07 16:34:07 c2woody Exp $ */
|
||||
/* $Id: dos_ioctl.cpp,v 1.28 2006-04-23 14:20:57 c2woody Exp $ */
|
||||
|
||||
#include <string.h>
|
||||
#include "dosbox.h"
|
||||
|
@ -49,8 +49,13 @@ bool DOS_IOCTL(void) {
|
|||
if (Files[handle]->GetInformation() & 0x8000) { //Check for device
|
||||
reg_dx=Files[handle]->GetInformation();
|
||||
} else {
|
||||
Bit8u hdrive=Files[handle]->GetDrive();
|
||||
if (hdrive==0xff) {
|
||||
LOG(LOG_IOCTL,LOG_NORMAL)("00:No drive set");
|
||||
hdrive=2; // defaulting to C:
|
||||
}
|
||||
/* return drive number in lower 5 bits for block devices */
|
||||
reg_dx=(Files[handle]->GetInformation()&0xffe0)|drive;
|
||||
reg_dx=(Files[handle]->GetInformation()&0xffe0)|hdrive;
|
||||
}
|
||||
reg_ax=reg_dx; //Destroyed officially
|
||||
return true;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: drive_fat.cpp,v 1.13 2006-04-17 10:45:32 qbix79 Exp $ */
|
||||
/* $Id: drive_fat.cpp,v 1.14 2006-04-23 14:20:58 c2woody Exp $ */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -232,7 +232,7 @@ bool fatFile::Close() {
|
|||
}
|
||||
|
||||
Bit16u fatFile::GetInformation(void) {
|
||||
return 0x202;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool fatFile::UpdateDateTimeFromHost(void) {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: drive_iso.cpp,v 1.12 2006-02-12 13:32:30 qbix79 Exp $ */
|
||||
/* $Id: drive_iso.cpp,v 1.13 2006-04-23 14:20:58 c2woody Exp $ */
|
||||
|
||||
#include <cctype>
|
||||
#include <cstring>
|
||||
|
@ -30,7 +30,7 @@ using namespace std;
|
|||
|
||||
class isoFile : public DOS_File {
|
||||
public:
|
||||
isoFile(isoDrive *drive, const char *name, FileStat_Block *stat, Bit32u offset, Bit16u info);
|
||||
isoFile(isoDrive *drive, const char *name, FileStat_Block *stat, Bit32u offset);
|
||||
bool Read(Bit8u *data, Bit16u *size);
|
||||
bool Write(Bit8u *data, Bit16u *size);
|
||||
bool Seek(Bit32u *pos, Bit32u type);
|
||||
|
@ -46,7 +46,7 @@ private:
|
|||
Bit16u info;
|
||||
};
|
||||
|
||||
isoFile::isoFile(isoDrive *drive, const char *name, FileStat_Block *stat, Bit32u offset, Bit16u info)
|
||||
isoFile::isoFile(isoDrive *drive, const char *name, FileStat_Block *stat, Bit32u offset)
|
||||
{
|
||||
this->drive = drive;
|
||||
time = stat->time;
|
||||
|
@ -58,7 +58,6 @@ isoFile::isoFile(isoDrive *drive, const char *name, FileStat_Block *stat, Bit32u
|
|||
fileEnd = fileBegin + size;
|
||||
cachedSector = -1;
|
||||
open = true;
|
||||
this->info = info;
|
||||
this->name = NULL;
|
||||
SetName(name);
|
||||
}
|
||||
|
@ -136,7 +135,7 @@ bool isoFile::Close()
|
|||
|
||||
Bit16u isoFile::GetInformation(void)
|
||||
{
|
||||
return info;
|
||||
return 0x40; // read-only drive
|
||||
}
|
||||
|
||||
int MSCDEX_AddDrive(char driveLetter, const char* physicalPath, Bit8u& subUnit);
|
||||
|
@ -201,7 +200,7 @@ bool isoDrive::FileOpen(DOS_File **file, char *name, Bit32u flags)
|
|||
file_stat.attr = DOS_ATTR_ARCHIVE | DOS_ATTR_READ_ONLY;
|
||||
file_stat.date = DOS_PackDate(1900 + de.dateYear, de.dateMonth, de.dateDay);
|
||||
file_stat.time = DOS_PackTime(de.timeHour, de.timeMin, de.timeSec);
|
||||
*file = new isoFile(this, name, &file_stat, EXTENT_LOCATION(de) * ISO_FRAMESIZE, 0x202);
|
||||
*file = new isoFile(this, name, &file_stat, EXTENT_LOCATION(de) * ISO_FRAMESIZE);
|
||||
(*file)->flags = flags;
|
||||
}
|
||||
return success;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: drive_local.cpp,v 1.66 2006-04-17 10:45:30 qbix79 Exp $ */
|
||||
/* $Id: drive_local.cpp,v 1.67 2006-04-23 14:20:58 c2woody Exp $ */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -33,17 +33,18 @@
|
|||
|
||||
class localFile : public DOS_File {
|
||||
public:
|
||||
localFile(const char* name, FILE * handle,Bit16u devinfo);
|
||||
localFile(const char* name, FILE * handle);
|
||||
bool Read(Bit8u * data,Bit16u * size);
|
||||
bool Write(Bit8u * data,Bit16u * size);
|
||||
bool Seek(Bit32u * pos,Bit32u type);
|
||||
bool Close();
|
||||
Bit16u GetInformation(void);
|
||||
bool UpdateDateTimeFromHost(void);
|
||||
void FlagReadOnlyMedium(void);
|
||||
private:
|
||||
FILE * fhandle;
|
||||
bool read_only_medium;
|
||||
enum { NONE,READ,WRITE } last_action;
|
||||
Bit16u info;
|
||||
};
|
||||
|
||||
|
||||
|
@ -72,7 +73,7 @@ bool localDrive::FileCreate(DOS_File * * file,char * name,Bit16u attributes) {
|
|||
|
||||
if(!existing_file) dirCache.AddEntry(newname, true);
|
||||
/* Make the 16 bit device information */
|
||||
*file=new localFile(name,hand,0x202);
|
||||
*file=new localFile(name,hand);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
@ -108,7 +109,7 @@ bool localDrive::FileOpen(DOS_File * * file,char * name,Bit32u flags) {
|
|||
return false;
|
||||
}
|
||||
|
||||
*file=new localFile(name,hand,0x202);
|
||||
*file=new localFile(name,hand);
|
||||
(*file)->flags=flags; //for the inheritance flag and maybe check for others.
|
||||
// (*file)->SetFileName(newname);
|
||||
return true;
|
||||
|
@ -486,13 +487,12 @@ bool localFile::Close() {
|
|||
}
|
||||
|
||||
Bit16u localFile::GetInformation(void) {
|
||||
return info;
|
||||
return read_only_medium?0x40:0;
|
||||
}
|
||||
|
||||
|
||||
localFile::localFile(const char* _name, FILE * handle,Bit16u devinfo) {
|
||||
localFile::localFile(const char* _name, FILE * handle) {
|
||||
fhandle=handle;
|
||||
info=devinfo;
|
||||
struct stat temp_stat;
|
||||
fstat(fileno(handle),&temp_stat);
|
||||
struct tm * ltime;
|
||||
|
@ -505,12 +505,17 @@ localFile::localFile(const char* _name, FILE * handle,Bit16u devinfo) {
|
|||
size=(Bit32u)temp_stat.st_size;
|
||||
attr=DOS_ATTR_ARCHIVE;
|
||||
last_action=NONE;
|
||||
read_only_medium=false;
|
||||
|
||||
open=true;
|
||||
name=0;
|
||||
SetName(_name);
|
||||
}
|
||||
|
||||
void localFile::FlagReadOnlyMedium(void) {
|
||||
read_only_medium = true;
|
||||
}
|
||||
|
||||
bool localFile::UpdateDateTimeFromHost(void) {
|
||||
if(!open) return false;
|
||||
struct stat temp_stat;
|
||||
|
@ -554,7 +559,9 @@ bool cdromDrive::FileOpen(DOS_File * * file,char * name,Bit32u flags)
|
|||
DOS_SetError(DOSERR_ACCESS_DENIED);
|
||||
return false;
|
||||
}
|
||||
return localDrive::FileOpen(file,name,flags);
|
||||
bool retcode = localDrive::FileOpen(file,name,flags);
|
||||
((localFile*)(*file))->FlagReadOnlyMedium();
|
||||
return retcode;
|
||||
};
|
||||
|
||||
bool cdromDrive::FileCreate(DOS_File * * file,char * name,Bit16u attributes)
|
||||
|
|
|
@ -129,7 +129,7 @@ bool Virtual_File::Close(){
|
|||
|
||||
|
||||
Bit16u Virtual_File::GetInformation(void) {
|
||||
return 0;
|
||||
return 0x40; // read-only drive
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue