From 1cfbdc666fd669f07c8bc24ef86cade21454e2f1 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Tue, 23 Aug 2005 14:21:15 +0000 Subject: [PATCH] Return access_denied when an existing file fails to open in write mode Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2288 --- src/dos/dos_files.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/dos/dos_files.cpp b/src/dos/dos_files.cpp index 7f607d6e..af120ca3 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.66 2005-08-22 19:49:07 qbix79 Exp $ */ +/* $Id: dos_files.cpp,v 1.67 2005-08-23 14:21:15 qbix79 Exp $ */ #include #include @@ -467,7 +467,11 @@ bool DOS_OpenFile(char * name,Bit8u flags,Bit16u * entry) { psp.SetFileHandle(*entry,handle); return true; } else { - DOS_SetError(DOSERR_FILE_NOT_FOUND); + //Test if file exists, but opened in read-write mode (and writeprotected) + if(((flags&3) != OPEN_READ) && Drives[drive]->FileExists(fullname)) + DOS_SetError(DOSERR_ACCESS_DENIED); + else + DOS_SetError(DOSERR_FILE_NOT_FOUND); return false; } }