From 4ec9803c4ff8295784649be89df2fe25c47d21da Mon Sep 17 00:00:00 2001 From: Ulf Wohlers Date: Fri, 21 Feb 2003 20:20:19 +0000 Subject: [PATCH] FCB Open : check if files are already open. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@675 --- src/dos/dos_files.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/dos/dos_files.cpp b/src/dos/dos_files.cpp index 491d8cf2..bade7461 100644 --- a/src/dos/dos_files.cpp +++ b/src/dos/dos_files.cpp @@ -656,6 +656,27 @@ bool DOS_FCBOpen(Bit16u seg,Bit16u offset) { DOS_FCB fcb(seg,offset); char shortname[DOS_FCBNAME];Bit16u handle; fcb.GetName(shortname); + + /* First check if the name is correct */ + Bit8u drive; + char fullname[DOS_PATHLENGTH]; + if (!DOS_MakeName(shortname,fullname,&drive)) return false; + + /* Check, if file is already opened */ + for (Bit16u i=0;iIsOpen() && Files[i]->IsName(fullname)) { + handle = psp.FindEntryByHandle(i); + if (handle==0xFF) { + // This shouldnt happen + LOG_ERROR("DOS: File %s is opened but has no psp entry.",shortname); + return false; + } + fcb.FileOpen((Bit8u)handle); + return true; + } + } + if (!DOS_OpenFile(shortname,2,&handle)) return false; fcb.FileOpen((Bit8u)handle); return true;