1
0
Fork 0

added support for the don't inheritance flag and changed the psp routines to use this flag

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@981
This commit is contained in:
Peter Veenstra 2003-05-02 11:01:22 +00:00
parent 100f13016e
commit cb364036b2
4 changed files with 28 additions and 15 deletions

View file

@ -95,11 +95,12 @@ bool DOS_Terminate(bool tsr) {
dos.return_mode=RETURN_EXIT;
Bit16u mempsp = dos.psp;
DOS_PSP curpsp(dos.psp);
if (dos.psp==curpsp.GetParent()) return true;
/* Free Files owned by process */
if (!tsr) curpsp.CloseFiles();
if (!tsr) curpsp.CloseFiles();
/* Get the termination address */
RealPt old22 = curpsp.GetInt22();
/* Restore vector 22,23,24 */
@ -173,10 +174,18 @@ bool DOS_NewPSP(Bit16u segment, Bit16u size)
DOS_PSP psp(segment);
psp.MakeNew(size);
DOS_PSP psp_parent(psp.GetParent());
psp.CopyFileTable(&psp_parent);
psp.CopyFileTable(&psp_parent,false);
return true;
};
bool DOS_ChildPSP(Bit16u segment, Bit16u size)
{
DOS_PSP psp(segment);
psp.MakeNew(size);
DOS_PSP psp_parent(psp.GetParent());
psp.CopyFileTable(&psp_parent,true);
return true;
};
static void SetupPSP(Bit16u pspseg,Bit16u memsize,Bit16u envseg) {
/* Fix the PSP for psp and environment MCB's */
@ -188,11 +197,11 @@ static void SetupPSP(Bit16u pspseg,Bit16u memsize,Bit16u envseg) {
DOS_PSP psp(pspseg);
psp.MakeNew(memsize);
psp.SetEnvironment(envseg);
/* Copy file handles */
if (DOS_PSP::rootpsp!=dos.psp) {
/* Copy file handles //QBIX::ALWAYS COPY BUT LEFT ORIGINAL INCASE OF MISTAKES
/* if (DOS_PSP::rootpsp!=dos.psp) { */
// TODO: Improve this
// If prog wasnt started from commandline copy file table (California Games 2)
DOS_PSP oldpsp(dos.psp);
/* DOS_PSP oldpsp(dos.psp);
psp.CopyFileTable(&oldpsp);
} else {
psp.SetFileHandle(STDIN ,DOS_FindDevice("CON"));
@ -201,8 +210,11 @@ static void SetupPSP(Bit16u pspseg,Bit16u memsize,Bit16u envseg) {
psp.SetFileHandle(STDAUX,DOS_FindDevice("CON"));
psp.SetFileHandle(STDNUL,DOS_FindDevice("CON"));
psp.SetFileHandle(STDPRN,DOS_FindDevice("CON"));
}
} */
/* Save old DTA in psp */
DOS_PSP oldpsp(dos.psp);
psp.CopyFileTable(&oldpsp,true);
psp.SetDTA(dos.dta);
/* Setup the DTA */
dos.dta=RealMake(pspseg,0x80);

View file

@ -287,13 +287,11 @@ bool DOS_CloseFile(Bit16u entry) {
DOS_SetError(DOSERR_INVALID_HANDLE);
return false;
};
//TODO Figure this out with devices :)
DOS_PSP psp(dos.psp);
if (entry>STDPRN) psp.SetFileHandle(entry,0xff);
/* Devices won't allow themselves to be closed or killed */
if (Files[handle]->Close()) {
if (Files[handle]->Close())
{ //if close succesfull => delete file/update psp
DOS_PSP psp(dos.psp);
psp.SetFileHandle(entry,0xff);
delete Files[handle];
Files[handle]=0;
}
@ -335,7 +333,7 @@ bool DOS_OpenFile(char * name,Bit8u flags,Bit16u * entry) {
/* First check for devices */
if (flags>2) LOG(LOG_FILES|LOG_ERROR,"Special file open command %X file %s",flags,name);
else LOG(LOG_FILES,"file open command %X file %s",flags,name);
flags&=3;
DOS_PSP psp(dos.psp);
Bit8u handle=DOS_FindDevice((char *)name);
bool device=false;char fullname[DOS_PATHLENGTH];Bit8u drive;Bit8u i;

View file

@ -55,12 +55,13 @@ bool localDrive::FileCreate(DOS_File * * file,char * name,Bit16u attributes) {
dirCache.AddEntry(newname, true);
/* Make the 16 bit device information */
*file=new localFile(name,hand,0x202);
return true;
};
bool localDrive::FileOpen(DOS_File * * file,char * name,Bit32u flags) {
char * type;
switch (flags) {
switch (flags &3) {
case OPEN_READ:type="rb"; break;
case OPEN_WRITE:type="rb+"; break;
case OPEN_READWRITE:type="rb+"; break;
@ -80,6 +81,7 @@ bool localDrive::FileOpen(DOS_File * * file,char * name,Bit32u flags) {
// Bit32u err=errno;
if (!hand) return false;
*file=new localFile(name,hand,0x202);
(*file)->flags=flags; //for the inheritance flag and maybe check for others.
// (*file)->SetFileName(newname);
return true;
};

View file

@ -132,6 +132,7 @@ bool Virtual_Drive::FileOpen(DOS_File * * file,char * name,Bit32u flags) {
if (strcasecmp(name,cur_file->name)==0) {
/* We have a match */
*file=new Virtual_File(cur_file->data,cur_file->size);
(*file)->flags=flags;
return true;
}
cur_file=cur_file->next;