From cb75e8608904ace0919f381aaf4fd6bd45823621 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Mon, 8 Jan 2007 21:20:23 +0000 Subject: [PATCH] Add beta2 patch. Add some basic file/path not found error. Fixes some installer. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2734 --- src/dos/dos_files.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/dos/dos_files.cpp b/src/dos/dos_files.cpp index 45d91f57..86d449f8 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.80 2007-01-08 19:45:39 qbix79 Exp $ */ +/* $Id: dos_files.cpp,v 1.81 2007-01-08 21:20:23 qbix79 Exp $ */ #include #include @@ -382,6 +382,20 @@ bool DOS_CloseFile(Bit16u entry) { return true; } +static bool PathExists(char* name) { + char* leading = strrchr(name,'\\'); + if(!leading) return true; + char temp[CROSS_LEN]; + strcpy(temp,name); + leading = strrchr(temp,'\\'); + *leading = 0; + Bit8u drive;char fulldir[DOS_PATHLENGTH]; + if (!DOS_MakeName(temp,fulldir,&drive)) return false; + if(!Drives[drive]->TestDir(fulldir)) return false; + return true; +} + + bool DOS_CreateFile(char * name,Bit16u attributes,Bit16u * entry) { // Creation of a device is the same as opening it // Tc201 installer @@ -417,6 +431,8 @@ bool DOS_CreateFile(char * name,Bit16u attributes,Bit16u * entry) { psp.SetFileHandle(*entry,handle); return true; } else { + if(!PathExists(name)) DOS_SetError(DOSERR_PATH_NOT_FOUND); + else DOS_SetError(DOSERR_FILE_NOT_FOUND); return false; } } @@ -475,8 +491,10 @@ bool DOS_OpenFile(char * name,Bit8u flags,Bit16u * entry) { //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); + else { + if(!PathExists(name)) DOS_SetError(DOSERR_PATH_NOT_FOUND); + else DOS_SetError(DOSERR_FILE_NOT_FOUND); + } return false; } }