1
0
Fork 0

added fcb-calls:open, close, findfirst,findnext to dos

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@111
This commit is contained in:
Peter Veenstra 2002-08-06 09:20:41 +00:00
parent 1b31218f2b
commit b4f2801c7e
5 changed files with 117 additions and 77 deletions

View file

@ -195,6 +195,12 @@ bool DOS_FreeMemory(Bit16u segment);
void DOS_FreeProcessMemory(Bit16u pspseg);
Bit16u DOS_GetMemory(Bit16u pages);
/* FCB stuff */
bool DOS_FCBOpen(Bit16u seg,Bit16u offset);
bool DOS_FCBClose(Bit16u seg,Bit16u offset);
bool DOS_FCBFindFirst(Bit16u seg,Bit16u offset);
bool DOS_FCBFindNext(Bit16u seg,Bit16u offset);
/* Extra DOS Interrupts */
void DOS_SetupMisc(void);

View file

@ -82,6 +82,8 @@ public:
virtual bool GetFileAttr(char * name,Bit16u * attr)=0;
virtual bool Rename(char * oldname,char * newname)=0;
virtual bool FreeSpace(Bit16u * bytes,Bit16u * sectors,Bit16u * clusters,Bit16u * free)=0;
virtual bool FileExists(const char* name) const=0;
virtual bool FileStat(const char* name, struct stat* const stat_block) const=0;
char * GetInfo(void);
char curdir[DOS_PATHLENGTH];
char info[256];

View file

@ -164,9 +164,38 @@ static Bitu DOS_21Handler(void) {
reg_al=26;
break;
case 0x0f: /* Open File using FCB */
if(DOS_FCBOpen(Segs[ds].value,reg_dx)){
reg_al=0;
}else{
reg_al=0xff;
}
LOG_DEBUG("DOS:0x0f FCB-fileopen used");
break;
case 0x10: /* Close File using FCB */
if(DOS_FCBClose(Segs[ds].value,reg_dx)){
reg_al=0;
}else{
reg_al=0xff;
}
LOG_DEBUG("DOS:0x0f FCB-fileclose used");
break;
case 0x11: /* Find First Matching File using FCB */
if(DOS_FCBFindFirst(Segs[ds].value,reg_dx)){
reg_al=0;
}else{
reg_al=0xff;
}
LOG_DEBUG("DOS:0x0f FCB-FindFirst used");
break;
case 0x12: /* Find Next Matching File using FCB */
if(DOS_FCBFindNext(Segs[ds].value,reg_dx)){
reg_al=0;
}else{
reg_al=0xff;
}
LOG_DEBUG("DOS:0x0f FCB-FindNext used");
break;
case 0x13: /* Delete File using FCB */
case 0x14: /* Sequential read from FCB */
case 0x15: /* Sequential write to FCB */
@ -180,7 +209,7 @@ static Bitu DOS_21Handler(void) {
case 0x28: /* Random Block read to FCB */
LOG_ERROR("DOS:Unhandled call %02X, FCB Stuff",reg_ah);
reg_al=0xff; /* FCB Calls FAIL */
CALLBACK_SCF(true);
//CALLBACK_SCF(true); not needed.
break;
case 0x29: /* Parse filename into FCB */
//TODO Give errors for unsupported functions

View file

@ -18,11 +18,13 @@
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include "dosbox.h"
#include "mem.h"
#include "cpu.h"
#include "dos_inc.h"
#include "drives.h"
#include "cross.h"
#define DOS_FILESTART 4
@ -446,9 +448,10 @@ bool DOS_CreateTempFile(char * name,Bit16u * entry) {
} while (!DOS_CreateFile(name,0,entry));
return true;
}
#if 0
void FCB_MakeName (DOS_FCB* fcb, char* outname, Bit8u* outdrive){
#if 1
static bool FCB_MakeName (DOS_FCB* fcb, char* outname, Bit8u* outdrive){
char naam[15];
Bit8s teller=0;
Bit8u drive=fcb->Get_drive();
if(drive!=0){
naam[0]=(drive-1)+'A';
@ -457,21 +460,16 @@ void FCB_MakeName (DOS_FCB* fcb, char* outname, Bit8u* outdrive){
else{
naam[0]='\0';
};
char temp[9];
char temp[10];
fcb->Get_filename(temp);
temp[9]='.';
strncat(naam,temp,9);
char ext[3];
temp[8]='.';
temp[9]='\0';
strcat(naam,temp);
char ext[4];
fcb->Get_ext(ext);
if(drive!=0) {
strncat(&naam[11],ext,3);
naam[14]='\0';
}else{
strncat(&naam[9],ext,3);
naam[12]='\0';
};
DOS_MakeName(naam,outname, outdrive);
return;
ext[3]='\0';
strcat(naam,ext);
return DOS_MakeName(naam,outname, outdrive);
}
@ -479,14 +477,13 @@ bool DOS_FCBOpen(Bit16u seg,Bit16u offset) {
DOS_FCB fcb(seg,offset);
Bit8u drive;
char fullname[DOS_PATHLENGTH];
FCB_MakeName (&fcb, fullname, &drive);
if(DOS_FileExists(fullname)==false) return false;
if(!FCB_MakeName (&fcb, fullname, &drive)) return false;
if(!Drives[drive]->FileExists(fullname)) return false; //not really needed as stat will error.
struct stat stat_block;
stat(fullname, &stat_block);
struct stat stat_block;
if(!Drives[drive]->FileStat(fullname, &stat_block)) return false;
fcb.Set_filesize((Bit32u)stat_block.st_size);
Bit16u constant =0;
Bit16u constant = 0;
fcb.Set_current_block(constant);
constant=0x80;
fcb.Set_record_size(constant);
@ -494,52 +491,60 @@ bool DOS_FCBOpen(Bit16u seg,Bit16u offset) {
time=localtime(&stat_block.st_mtime);
constant=(time->tm_hour<<11)+(time->tm_min<<5)+(time->tm_sec/2); /* standard way. */
fcb->Set_time(constant);
fcb.Set_time(constant);
constant=((time->tm_year-80)<<9)+((time->tm_mon+1)<<5)+(time->tm_mday);
fcb->Set_date(constant);
fcb->Set_drive(drive +1);
fcb.Set_date(constant);
fcb.Set_drive(drive +1);
return true;
}
bool FCB_Close(void)
{ return true;}
bool DOS_FCBClose(Bit16u seg,Bit16u offset)
{ DOS_FCB fcb(seg,offset);
Bit8u drive;
char fullname[DOS_PATHLENGTH];
if(!FCB_MakeName (&fcb, fullname, &drive)) return false;
if(!Drives[drive]->FileExists(fullname)) return false;
return true;}
bool FCB_FindFirst(Bit16u seg,Bit16u offset)
{FCB* fcb = new FCB(seg,offset);
Bit8u drive;
Bitu i;
char fullname[DOS_PATHLENGTH];
FCB_MakeName (fcb, fullname, &drive);
DTA_FindBlock * dtablock=(DTA_FindBlock *)Real2Host(dos.dta);
if(Drives[drive]->FindFirst(fullname,dtablock)==false) return false;
bool DOS_FCBFindFirst(Bit16u seg,Bit16u offset)
{
DOS_FCB* fcb = new DOS_FCB(seg,offset);
Bit8u drive;
Bitu i;
char fullname[DOS_PATHLENGTH];
FCB_MakeName (fcb, fullname, &drive);
DTA_FindBlock * dtablock=(DTA_FindBlock *)Real2Host(dos.dta);
if(Drives[drive]->FindFirst(fullname,dtablock)==false) return false;
char naam[8];
char ext[3];
char * point=strrchr(dtablock->name,'.');
if(point==NULL|| *(point+1)=='\0') {
ext[0]=' ';
ext[1]=' ';
ext[2]=' ';
}else
{strcpy(ext,point+1);
Bitu i;
i=strlen(point+1);
while(i!=3) ext[i-1]=' ';
}
char naam[8];
char ext[3];
char * point=strrchr(dtablock->name,'.');
if(point==NULL|| *(point+1)=='\0') {
ext[0]=' ';
ext[1]=' ';
ext[2]=' ';
}else{
strcpy(ext,(point+1));
i=strlen((point+1));
while(i!=3) {ext[i]=' ';i++;}
}
if(point!=NULL) *point='\0';
if(point!=NULL) *point='\0';
strcpy (naam,dtablock->name);
i=strlen(dtablock->name);
while(i!=8) naam[i-1]=' ';
FCB* fcbout= new FCB((PhysPt)Real2Host(dos.dta));
fcbout->Set_drive(drive +1);
fcbout->Set_filename(naam);
fcbout->Set_ext(ext);
return true;
}
bool FCB_FindNext(Bit16u seg,Bit16u offset)
{FCB* fcb = new FCB(seg,offset);
strcpy (naam,dtablock->name);
i=strlen(dtablock->name);
while(i!=8) {naam[i]=' '; i++;}
DOS_FCB* fcbout= new DOS_FCB((PhysPt)Real2Host(dos.dta));
fcbout->Set_drive(drive +1);
fcbout->Set_filename(naam);
fcbout->Set_ext(ext);
return true;
}
bool DOS_FCBFindNext(Bit16u seg,Bit16u offset)
{
DOS_FCB* fcb = new DOS_FCB(seg,offset);
Bit8u drive;
Bitu i;
char fullname[DOS_PATHLENGTH];
@ -550,22 +555,22 @@ bool FCB_FindNext(Bit16u seg,Bit16u offset)
char ext[3];
char * point=strrchr(dtablock->name,'.');
if(point==NULL|| *(point+1)=='\0') {
ext[0]=' ';
ext[1]=' ';
ext[2]=' ';
}else
{strcpy(ext,point+1);
Bitu i;
i=strlen(point+1);
while(i!=3) ext[i-1]=' ';
ext[0]=' ';
ext[1]=' ';
ext[2]=' ';
}else
{
strcpy(ext,point+1);
i=strlen(point+1);
while(i!=3) {ext[i]=' ';i++;}
}
if(point!=NULL) *point='\0';
strcpy (naam,dtablock->name);
i=strlen(dtablock->name);
while(i!=8) naam[i-1]=' ';
FCB* fcbout= new FCB((PhysPt)Real2Host(dos.dta));
while(i!=8) {naam[i]=' '; i++;}
DOS_FCB* fcbout= new DOS_FCB((PhysPt)Real2Host(dos.dta));
fcbout->Set_drive(drive +1);
fcbout->Set_filename(naam);
fcbout->Set_ext(ext);
@ -575,12 +580,10 @@ bool FCB_FindNext(Bit16u seg,Bit16u offset)
#endif
bool DOS_FileExists(char * name) {
Bit16u handle;
if (DOS_OpenFile(name,0,&handle)) {
DOS_CloseFile(handle);
return true;
}
return false;
char fullname[DOS_PATHLENGTH];Bit8u drive;
if (!DOS_MakeName(name,fullname,&drive)) return false;
return Drives[drive]->FileExists(fullname);
}

View file

@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /G6 /MD /W3 /GX /O1 /Op /Ob2 /I "../include" /I "../src/platform/visualc" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FAs /FD /QxMi /bQipo /c
# ADD CPP /nologo /G6 /MD /W3 /GX /O1 /Op /Ob2 /I "../include" /I "../src/platform/visualc" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FAs /FR /FD /QxMi /bQipo /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe