From b5d98a5162f865312af3464abbb429025082667c Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Thu, 24 Feb 2005 11:29:26 +0000 Subject: [PATCH] Fixed redirect filehandle (force duplicate). Has this function ever worked ? Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2115 --- src/dos/dos_files.cpp | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/src/dos/dos_files.cpp b/src/dos/dos_files.cpp index 63017afb..aa2a0d86 100644 --- a/src/dos/dos_files.cpp +++ b/src/dos/dos_files.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: dos_files.cpp,v 1.60 2005-02-10 10:20:51 qbix79 Exp $ */ +/* $Id: dos_files.cpp,v 1.61 2005-02-24 11:29:26 qbix79 Exp $ */ #include #include @@ -558,14 +558,12 @@ bool DOS_DuplicateEntry(Bit16u entry,Bit16u * newentry) { }; bool DOS_ForceDuplicateEntry(Bit16u entry,Bit16u newentry) { - // Dont duplicate console handles -/* if (entry<=STDPRN) { - newentry = entry; - return true; - }; -*/ - Bit8u orig=RealHandle(entry); - if (orig>=DOS_FILES) { + if(entry == newentry) { + DOS_SetError(DOSERR_INVALID_HANDLE); + return false; + } + Bit8u orig = RealHandle(entry); + if (orig >= DOS_FILES) { DOS_SetError(DOSERR_INVALID_HANDLE); return false; }; @@ -573,18 +571,13 @@ bool DOS_ForceDuplicateEntry(Bit16u entry,Bit16u newentry) { DOS_SetError(DOSERR_INVALID_HANDLE); return false; }; - Bit8u newone=RealHandle(newentry); - if (newone>=DOS_FILES) { - DOS_SetError(DOSERR_INVALID_HANDLE); - return false; - }; - if (Files[newone]) { + Bit8u newone = RealHandle(newentry); + if (newone < DOS_FILES && Files[newone]) { DOS_CloseFile(newentry); - return false; - }; + } DOS_PSP psp(dos.psp()); Files[orig]->AddRef(); - psp.SetFileHandle(newentry,(Bit8u)entry); + psp.SetFileHandle(newentry,orig); return true; }; @@ -1034,8 +1027,3 @@ void DOS_SetupFiles (void) { } Drives[25]=new Virtual_Drive(); } - - - - -