Prepare system to mode current drive to sda. Check for problems with rename.(fixes linux rename). Small warning fixes + style changes.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3345
This commit is contained in:
parent
b35cfb2e74
commit
92c5771c4d
4 changed files with 62 additions and 46 deletions
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: dos.cpp,v 1.116 2009-03-14 16:10:00 c2woody Exp $ */
|
||||
/* $Id: dos.cpp,v 1.117 2009-04-16 12:16:52 qbix79 Exp $ */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -397,7 +397,7 @@ static Bitu DOS_21Handler(void) {
|
|||
case 0x1f: /* Get drive parameter block for default drive */
|
||||
case 0x32: /* Get drive parameter block for specific drive */
|
||||
{ /* Officially a dpb should be returned as well. The disk detection part is implemented */
|
||||
Bitu drive=reg_dl;if(!drive || reg_ah==0x1f) drive=dos.current_drive;else drive--;
|
||||
Bitu drive=reg_dl;if(!drive || reg_ah==0x1f) drive = DOS_GetDefaultDrive();else drive--;
|
||||
if(Drives[drive]) {
|
||||
reg_al = 0x00;
|
||||
SegSet16(ds,dos.tables.dpb);
|
||||
|
@ -1126,6 +1126,7 @@ public:
|
|||
DOS_SetupMemory(); /* Setup first MCB */
|
||||
DOS_SetupPrograms();
|
||||
DOS_SetupMisc(); /* Some additional dos interrupts */
|
||||
DOS_SDA(DOS_SDA_SEG,DOS_SDA_OFS).SetDrive(25); /* Else the next call gives a warning. */
|
||||
DOS_SetDefaultDrive(25);
|
||||
|
||||
dos.version.major=5;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: dos_classes.cpp,v 1.55 2008-09-07 10:55:14 c2woody Exp $ */
|
||||
/* $Id: dos_classes.cpp,v 1.56 2009-04-16 12:16:52 qbix79 Exp $ */
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -210,41 +210,36 @@ void DOS_PSP::MakeNew(Bit16u mem_size) {
|
|||
if (rootpsp==0) rootpsp = seg;
|
||||
}
|
||||
|
||||
Bit8u DOS_PSP::GetFileHandle(Bit16u index)
|
||||
{
|
||||
Bit8u DOS_PSP::GetFileHandle(Bit16u index) {
|
||||
if (index>=sGet(sPSP,max_files)) return 0xff;
|
||||
PhysPt files=Real2Phys(sGet(sPSP,file_table));
|
||||
return mem_readb(files+index);
|
||||
};
|
||||
}
|
||||
|
||||
void DOS_PSP::SetFileHandle(Bit16u index, Bit8u handle)
|
||||
{
|
||||
void DOS_PSP::SetFileHandle(Bit16u index, Bit8u handle) {
|
||||
if (index<sGet(sPSP,max_files)) {
|
||||
PhysPt files=Real2Phys(sGet(sPSP,file_table));
|
||||
mem_writeb(files+index,handle);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Bit16u DOS_PSP::FindFreeFileEntry(void)
|
||||
{
|
||||
Bit16u DOS_PSP::FindFreeFileEntry(void) {
|
||||
PhysPt files=Real2Phys(sGet(sPSP,file_table));
|
||||
for (Bit16u i=0;i<sGet(sPSP,max_files);i++) {
|
||||
if (mem_readb(files+i)==0xff) return i;
|
||||
}
|
||||
return 0xff;
|
||||
};
|
||||
}
|
||||
|
||||
Bit16u DOS_PSP::FindEntryByHandle(Bit8u handle)
|
||||
{
|
||||
Bit16u DOS_PSP::FindEntryByHandle(Bit8u handle) {
|
||||
PhysPt files=Real2Phys(sGet(sPSP,file_table));
|
||||
for (Bit16u i=0;i<sGet(sPSP,max_files);i++) {
|
||||
if (mem_readb(files+i)==handle) return i;
|
||||
}
|
||||
return 0xFF;
|
||||
};
|
||||
}
|
||||
|
||||
void DOS_PSP::CopyFileTable(DOS_PSP* srcpsp,bool createchildpsp)
|
||||
{
|
||||
void DOS_PSP::CopyFileTable(DOS_PSP* srcpsp,bool createchildpsp) {
|
||||
/* Copy file table from calling process */
|
||||
for (Bit16u i=0;i<20;i++) {
|
||||
Bit8u handle = srcpsp->GetFileHandle(i);
|
||||
|
@ -266,53 +261,46 @@ void DOS_PSP::CopyFileTable(DOS_PSP* srcpsp,bool createchildpsp)
|
|||
SetFileHandle(i,handle);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void DOS_PSP::CloseFiles(void)
|
||||
{
|
||||
void DOS_PSP::CloseFiles(void) {
|
||||
for (Bit16u i=0;i<sGet(sPSP,max_files);i++) {
|
||||
DOS_CloseFile(i);
|
||||
}
|
||||
}
|
||||
|
||||
void DOS_PSP::SaveVectors(void)
|
||||
{
|
||||
void DOS_PSP::SaveVectors(void) {
|
||||
/* Save interrupt 22,23,24 */
|
||||
sSave(sPSP,int_22,RealGetVec(0x22));
|
||||
sSave(sPSP,int_23,RealGetVec(0x23));
|
||||
sSave(sPSP,int_24,RealGetVec(0x24));
|
||||
};
|
||||
}
|
||||
|
||||
void DOS_PSP::RestoreVectors(void)
|
||||
{
|
||||
void DOS_PSP::RestoreVectors(void) {
|
||||
/* Restore interrupt 22,23,24 */
|
||||
RealSetVec(0x22,sGet(sPSP,int_22));
|
||||
RealSetVec(0x23,sGet(sPSP,int_23));
|
||||
RealSetVec(0x24,sGet(sPSP,int_24));
|
||||
};
|
||||
}
|
||||
|
||||
void DOS_PSP::SetCommandTail(RealPt src)
|
||||
{
|
||||
void DOS_PSP::SetCommandTail(RealPt src) {
|
||||
if (src) { // valid source
|
||||
MEM_BlockCopy(pt+offsetof(sPSP,cmdtail),Real2Phys(src),128);
|
||||
} else { // empty
|
||||
sSave(sPSP,cmdtail.count,0x00);
|
||||
mem_writeb(pt+offsetof(sPSP,cmdtail.buffer),0x0d);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
void DOS_PSP::SetFCB1(RealPt src)
|
||||
{
|
||||
void DOS_PSP::SetFCB1(RealPt src) {
|
||||
if (src) MEM_BlockCopy(PhysMake(seg,offsetof(sPSP,fcb1)),Real2Phys(src),16);
|
||||
};
|
||||
}
|
||||
|
||||
void DOS_PSP::SetFCB2(RealPt src)
|
||||
{
|
||||
void DOS_PSP::SetFCB2(RealPt src) {
|
||||
if (src) MEM_BlockCopy(PhysMake(seg,offsetof(sPSP,fcb2)),Real2Phys(src),16);
|
||||
};
|
||||
}
|
||||
|
||||
bool DOS_PSP::SetNumFiles(Bit16u fileNum)
|
||||
{
|
||||
bool DOS_PSP::SetNumFiles(Bit16u fileNum) {
|
||||
if (fileNum>20) {
|
||||
// Allocate needed paragraphs
|
||||
fileNum+=2; // Add a few more files for safety
|
||||
|
@ -327,7 +315,7 @@ bool DOS_PSP::SetNumFiles(Bit16u fileNum)
|
|||
sSave(sPSP,max_files,fileNum);
|
||||
};
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
void DOS_DTA::SetupSearch(Bit8u _sdrive,Bit8u _sattr,char * pattern) {
|
||||
|
@ -480,7 +468,7 @@ void DOS_FCB::FileClose(Bit8u & _fhandle) {
|
|||
|
||||
Bit8u DOS_FCB::GetDrive(void) {
|
||||
Bit8u drive=sGet(sFCB,drive);
|
||||
if (!drive) return dos.current_drive;
|
||||
if (!drive) return DOS_GetDefaultDrive();
|
||||
else return drive-1;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: dos_files.cpp,v 1.107 2009-03-23 21:58:05 c2woody Exp $ */
|
||||
/* $Id: dos_files.cpp,v 1.108 2009-04-16 12:16:52 qbix79 Exp $ */
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -45,11 +45,15 @@ DOS_File * Files[DOS_FILES];
|
|||
DOS_Drive * Drives[DOS_DRIVES];
|
||||
|
||||
Bit8u DOS_GetDefaultDrive(void) {
|
||||
// return DOS_SDA(DOS_SDA_SEG,DOS_SDA_OFS).GetDrive();
|
||||
Bit8u d = DOS_SDA(DOS_SDA_SEG,DOS_SDA_OFS).GetDrive();
|
||||
if( d != dos.current_drive ) LOG(LOG_DOSMISC,LOG_ERROR)("SDA drive %d not the same as dos.current_drive %d",d,dos.current_drive);
|
||||
return dos.current_drive;
|
||||
}
|
||||
|
||||
void DOS_SetDefaultDrive(Bit8u drive) {
|
||||
if (drive<=DOS_DRIVES && ((drive<2) || Drives[drive])) dos.current_drive = drive;
|
||||
// if (drive<=DOS_DRIVES && ((drive<2) || Drives[drive])) DOS_SDA(DOS_SDA_SEG,DOS_SDA_OFS).SetDrive(drive);
|
||||
if (drive<=DOS_DRIVES && ((drive<2) || Drives[drive])) {dos.current_drive = drive; DOS_SDA(DOS_SDA_SEG,DOS_SDA_OFS).SetDrive(drive);}
|
||||
}
|
||||
|
||||
bool DOS_MakeName(char const * const name,char * const fullname,Bit8u * drive) {
|
||||
|
@ -63,7 +67,7 @@ bool DOS_MakeName(char const * const name,char * const fullname,Bit8u * drive) {
|
|||
char tempdir[DOS_PATHLENGTH];
|
||||
char upname[DOS_PATHLENGTH];
|
||||
Bitu r,w;
|
||||
*drive=dos.current_drive;
|
||||
*drive = DOS_GetDefaultDrive();
|
||||
/* First get the drive */
|
||||
if (name_int[1]==':') {
|
||||
*drive=(name_int[0] | 0x20)-'a';
|
||||
|
@ -256,8 +260,31 @@ bool DOS_Rename(char const * const oldname,char const * const newname) {
|
|||
Bit8u drivenew;char fullnew[DOS_PATHLENGTH];
|
||||
if (!DOS_MakeName(oldname,fullold,&driveold)) return false;
|
||||
if (!DOS_MakeName(newname,fullnew,&drivenew)) return false;
|
||||
//TODO Test for different drives maybe
|
||||
/* No tricks with devices */
|
||||
if ( (DOS_FindDevice(oldname) != DOS_DEVICES) ||
|
||||
(DOS_FindDevice(newname) != DOS_DEVICES) ) {
|
||||
DOS_SetError(DOSERR_FILE_NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
/* Must be on the same drive */
|
||||
if(driveold != drivenew) {
|
||||
DOS_SetError(DOSERR_NOT_SAME_DEVICE);
|
||||
return false;
|
||||
}
|
||||
/*Test if target exists => no access */
|
||||
if(Drives[drivenew]->FileExists(fullnew)) {
|
||||
DOS_SetError(DOSERR_ACCESS_DENIED);
|
||||
return false;
|
||||
}
|
||||
/* Source must exist, check for path ? */
|
||||
if(!Drives[driveold]->FileExists(fullold)) {
|
||||
DOS_SetError(DOSERR_FILE_NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Drives[drivenew]->Rename(fullold,fullnew)) return true;
|
||||
/* If it still fails. which error should we give ? PATH NOT FOUND or EACCESS */
|
||||
LOG(LOG_FILES,LOG_NORMAL)("Rename fails on %c from %s to %s, no proper errorcode returned.",driveold+'A',oldname,newname);
|
||||
DOS_SetError(DOSERR_FILE_NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
|
@ -1139,7 +1166,7 @@ bool DOS_FileExists(char const * const name) {
|
|||
}
|
||||
|
||||
bool DOS_GetAllocationInfo(Bit8u drive,Bit16u * _bytes_sector,Bit8u * _sectors_cluster,Bit16u * _total_clusters) {
|
||||
if (!drive) drive=dos.current_drive;
|
||||
if (!drive) drive = DOS_GetDefaultDrive();
|
||||
else drive--;
|
||||
if (drive >= DOS_DRIVES || !Drives[drive]) return false;
|
||||
Bit16u _free_clusters;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: dos_ioctl.cpp,v 1.34 2009-03-24 17:07:30 c2woody Exp $ */
|
||||
/* $Id: dos_ioctl.cpp,v 1.35 2009-04-16 12:16:52 qbix79 Exp $ */
|
||||
|
||||
#include <string.h>
|
||||
#include "dosbox.h"
|
||||
|
@ -40,7 +40,7 @@ bool DOS_IOCTL(void) {
|
|||
}
|
||||
} else if (reg_al<0x12) { /* those use a diskdrive except 0x0b */
|
||||
if (reg_al!=0x0b) {
|
||||
drive=reg_bl;if (!drive) drive=dos.current_drive;else drive--;
|
||||
drive=reg_bl;if (!drive) drive = DOS_GetDefaultDrive();else drive--;
|
||||
if( !(( drive < DOS_DRIVES ) && Drives[drive]) ) {
|
||||
DOS_SetError(DOSERR_INVALID_DRIVE);
|
||||
return false;
|
||||
|
|
Loading…
Add table
Reference in a new issue