diff --git a/src/dos/dos_files.cpp b/src/dos/dos_files.cpp index 9abfb119..9e9c6e19 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.99 2008-09-07 10:55:14 c2woody Exp $ */ +/* $Id: dos_files.cpp,v 1.100 2008-09-20 14:51:52 c2woody Exp $ */ #include #include @@ -421,7 +421,7 @@ bool DOS_CreateFile(char const * name,Bit16u attributes,Bit16u * entry) { // Creation of a device is the same as opening it // Tc201 installer if (DOS_FindDevice(name) != DOS_DEVICES) - return DOS_OpenFile(name, 0, entry); + return DOS_OpenFile(name, OPEN_READ, entry); LOG(LOG_FILES,LOG_NORMAL)("file create attributes %X file %s",attributes,name); char fullname[DOS_PATHLENGTH];Bit8u drive; @@ -446,7 +446,7 @@ bool DOS_CreateFile(char const * name,Bit16u attributes,Bit16u * entry) { return false; } /* Don't allow directories to be created */ - if (attributes&0x10) { + if (attributes&DOS_ATTR_DIRECTORY) { DOS_SetError(DOSERR_ACCESS_DENIED); return false; } @@ -529,13 +529,13 @@ bool DOS_OpenFileExtended(char const * name, Bit16u flags, Bit16u createAttr, Bi // FIXME: Not yet supported : Bit 13 of flags (int 0x24 on critical error { Bit16u result = 0; - if (DOS_OpenFile(name, (Bit8u)flags, entry)) { + if (DOS_OpenFile(name, (Bit8u)(flags&0xff), entry)) { // File already exists switch (action & 0x0f) { case 0x00 : return false; // failed case 0x01 : result = 1; break; // file open (already done) case 0x02 : DOS_CloseFile(*entry); // replace - if (!DOS_CreateFile(name, flags, entry)) return false; + if (!DOS_CreateFile(name, createAttr, entry)) return false; result = 3; break; default : E_Exit("DOS: OpenFileExtended: Unknown action."); @@ -544,7 +544,7 @@ bool DOS_OpenFileExtended(char const * name, Bit16u flags, Bit16u createAttr, Bi // File doesnt exist if ((action & 0xf0)==0) return false; // Create File - if (!DOS_CreateFile(name, flags, entry)) return false; + if (!DOS_CreateFile(name, createAttr, entry)) return false; result = 2; }; *status = result; @@ -840,7 +840,7 @@ bool DOS_FCBCreate(Bit16u seg,Bit16u offset) { DOS_FCB fcb(seg,offset); char shortname[DOS_FCBNAME];Bit16u handle; fcb.GetName(shortname); - if (!DOS_CreateFile(shortname,2,&handle)) return false; + if (!DOS_CreateFile(shortname,DOS_ATTR_ARCHIVE,&handle)) return false; fcb.FileOpen((Bit8u)handle); return true; } @@ -870,7 +870,7 @@ bool DOS_FCBOpen(Bit16u seg,Bit16u offset) { } } - if (!DOS_OpenFile(shortname,2,&handle)) return false; + if (!DOS_OpenFile(shortname,OPEN_READWRITE,&handle)) return false; fcb.FileOpen((Bit8u)handle); return true; } @@ -1017,7 +1017,7 @@ bool DOS_FCBGetFileSize(Bit16u seg,Bit16u offset) { char shortname[DOS_PATHLENGTH];Bit16u entry;Bit8u handle;Bit16u rec_size; DOS_FCB fcb(seg,offset); fcb.GetName(shortname); - if (!DOS_OpenFile(shortname,0,&entry)) return false; + if (!DOS_OpenFile(shortname,OPEN_READ,&entry)) return false; handle = RealHandle(entry); Bit32u size = 0; Files[handle]->Seek(&size,DOS_SEEK_END); diff --git a/src/shell/shell.cpp b/src/shell/shell.cpp index 744c9952..8a8fb976 100644 --- a/src/shell/shell.cpp +++ b/src/shell/shell.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: shell.cpp,v 1.94 2008-09-07 10:55:16 c2woody Exp $ */ +/* $Id: shell.cpp,v 1.95 2008-09-20 14:51:53 c2woody Exp $ */ #include #include @@ -212,34 +212,34 @@ void DOS_Shell::ParseLine(char * line) { num = GetRedirection(line,&in, &out,&append); if (num>1) LOG_MSG("SHELL:Multiple command on 1 line not supported"); if (in || out) { - normalstdin = (psp->GetFileHandle(0) != 0xff); - normalstdout = (psp->GetFileHandle(1) != 0xff); + normalstdin = (psp->GetFileHandle(0) != 0xff); + normalstdout = (psp->GetFileHandle(1) != 0xff); } if (in) { - if(DOS_OpenFile(in,0,&dummy)) { //Test if file exists + if(DOS_OpenFile(in,OPEN_READ,&dummy)) { //Test if file exists DOS_CloseFile(dummy); LOG_MSG("SHELL:Redirect input from %s",in); - if(normalstdin) DOS_CloseFile(0); //Close stdin - DOS_OpenFile(in,0,&dummy); //Open new stdin + if(normalstdin) DOS_CloseFile(0); //Close stdin + DOS_OpenFile(in,OPEN_READ,&dummy); //Open new stdin } } if (out){ LOG_MSG("SHELL:Redirect output to %s",out); if(normalstdout) DOS_CloseFile(1); - if(!normalstdin && !in) DOS_OpenFile("con",2,&dummy); + if(!normalstdin && !in) DOS_OpenFile("con",OPEN_READWRITE,&dummy); bool status = true; /* Create if not exist. Open if exist. Both in read/write mode */ if(append) { - if( (status = DOS_OpenFile(out,2,&dummy)) ) { + if( (status = DOS_OpenFile(out,OPEN_READWRITE,&dummy)) ) { DOS_SeekFile(1,&bigdummy,DOS_SEEK_END); } else { - status = DOS_CreateFile(out,2,&dummy); //Create if not exists. + status = DOS_CreateFile(out,DOS_ATTR_ARCHIVE,&dummy); //Create if not exists. } + } else { + status = DOS_OpenFileExtended(out,OPEN_READWRITE,DOS_ATTR_ARCHIVE,0x12,&dummy,&dummy2); } - else - status = DOS_OpenFileExtended(out,2,2,0x12,&dummy,&dummy2); - if(!status && normalstdout) DOS_OpenFile("con",2,&dummy); //Read only file, open con again + if(!status && normalstdout) DOS_OpenFile("con",OPEN_READWRITE,&dummy); //Read only file, open con again if(!normalstdin && !in) DOS_CloseFile(0); } /* Run the actual command */ @@ -247,13 +247,13 @@ void DOS_Shell::ParseLine(char * line) { /* Restore handles */ if(in) { DOS_CloseFile(0); - if(normalstdin) DOS_OpenFile("con",2,&dummy); + if(normalstdin) DOS_OpenFile("con",OPEN_READWRITE,&dummy); free(in); } if(out) { DOS_CloseFile(1); - if(!normalstdin) DOS_OpenFile("con",2,&dummy); - if(normalstdout) DOS_OpenFile("con",2,&dummy); + if(!normalstdin) DOS_OpenFile("con",OPEN_READWRITE,&dummy); + if(normalstdout) DOS_OpenFile("con",OPEN_READWRITE,&dummy); if(!normalstdin) DOS_CloseFile(0); free(out); } @@ -321,8 +321,8 @@ void DOS_Shell::Run(void) { WriteOut_NoParsing("\n"); }; }; - ParseLine(input_line); - if (echo) WriteOut("\n"); + ParseLine(input_line); + if (echo) WriteOut("\n"); } } else { if (echo) ShowPrompt(); @@ -616,13 +616,13 @@ void SHELL_Init() { * In order to achieve this: First open 2 files. Close the first and * duplicate the second (so the entries get 01) */ Bit16u dummy=0; - DOS_OpenFile("CON",2,&dummy);/* STDIN */ - DOS_OpenFile("CON",2,&dummy);/* STDOUT */ - DOS_CloseFile(0); /* Close STDIN */ - DOS_ForceDuplicateEntry(1,0);/* "new" STDIN */ - DOS_ForceDuplicateEntry(1,2);/* STDERR */ - DOS_OpenFile("CON",2,&dummy);/* STDAUX */ - DOS_OpenFile("CON",2,&dummy);/* STDPRN */ + DOS_OpenFile("CON",OPEN_READWRITE,&dummy); /* STDIN */ + DOS_OpenFile("CON",OPEN_READWRITE,&dummy); /* STDOUT */ + DOS_CloseFile(0); /* Close STDIN */ + DOS_ForceDuplicateEntry(1,0); /* "new" STDIN */ + DOS_ForceDuplicateEntry(1,2); /* STDERR */ + DOS_OpenFile("CON",OPEN_READWRITE,&dummy); /* STDAUX */ + DOS_OpenFile("CON",OPEN_READWRITE,&dummy); /* STDPRN */ psp.SetParent(psp_seg); /* Set the environment */