diff --git a/src/dos/dos_files.cpp b/src/dos/dos_files.cpp index 95f7ae07..8c725df9 100644 --- a/src/dos/dos_files.cpp +++ b/src/dos/dos_files.cpp @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* $Id: dos_files.cpp,v 1.42 2003-08-01 16:48:55 qbix79 Exp $ */ + #include #include #include @@ -110,7 +112,28 @@ bool DOS_MakeName(char * name,char * fullname,Bit8u * drive) { w=0;r++; continue; } - if (strcmp(tempdir,"..")==0) { + + Bit32u iDown, cDots; + bool dots = true; + Bit32u templen =strlen(tempdir); + for(iDown=0;(iDown < templen) && dots;iDown++) + if(tempdir[iDown] != '.') + dots = false; + + // only dots? + cDots = templen - 1; + if(dots && (cDots > 0)) + { + for(iDown=strlen(fullname)-1;iDown>=0;iDown--) + { + if(fullname[iDown]=='\\' || iDown==0) + { + lastdir = iDown; + cDots--; + if(cDots==0) + break; + } + } fullname[lastdir]=0; Bit32u t=0;lastdir=0; while (fullname[t]!=0) { @@ -121,8 +144,10 @@ bool DOS_MakeName(char * name,char * fullname,Bit8u * drive) { w=0;r++; continue; } + + lastdir=strlen(fullname); - //TODO Maybe another check for correct type because of .... stuff + if (lastdir!=0) strcat(fullname,"\\"); char * ext=strchr(tempdir,'.'); if (ext) { diff --git a/src/shell/shell_cmds.cpp b/src/shell/shell_cmds.cpp index 601ae88d..35662011 100644 --- a/src/shell/shell_cmds.cpp +++ b/src/shell/shell_cmds.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002 The DOSBox Team + * Copyright (C) 2002-2003 The DOSBox Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,6 +15,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* $Id: shell_cmds.cpp,v 1.24 2003-08-01 16:48:25 qbix79 Exp $ */ + #include #include "shell_inc.h" @@ -59,8 +62,6 @@ void DOS_Shell::DoCommand(char * line) { while (*line) { if (*line==32) break; if (*line=='/') break; - if ((*line=='.') && (*(line+1)=='.')) break; -// if ((*line=='.') && (*(line+1)==0)) break; *cmd_write++=*line++; } *cmd_write=0; diff --git a/src/shell/shell_misc.cpp b/src/shell/shell_misc.cpp index 249ccde5..bbeb9ec8 100644 --- a/src/shell/shell_misc.cpp +++ b/src/shell/shell_misc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002 The DOSBox Team + * Copyright (C) 2002-2003 The DOSBox Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* $Id: shell_misc.cpp,v 1.21 2003-08-01 16:48:25 qbix79 Exp $ */ + #include #include #include "shell_inc.h" @@ -352,22 +354,18 @@ static char which_ret[DOS_PATHLENGTH]; char * DOS_Shell::Which(char * name) { /* Parse through the Path to find the correct entry */ /* Check if name is already ok but just misses an extension */ - char * ext=strrchr(name,'.'); - if (ext) if (strlen(ext)>4) ext=0; - if (ext) { - if (DOS_FileExists(name)) return name; - } else { - /* try to find .com .exe .bat */ - strcpy(which_ret,name); - strcat(which_ret,com_ext); - if (DOS_FileExists(which_ret)) return which_ret; - strcpy(which_ret,name); - strcat(which_ret,exe_ext); - if (DOS_FileExists(which_ret)) return which_ret; - strcpy(which_ret,name); - strcat(which_ret,bat_ext); - if (DOS_FileExists(which_ret)) return which_ret; - } + if (DOS_FileExists(name)) return name; + /* try to find .com .exe .bat */ + strcpy(which_ret,name); + strcat(which_ret,com_ext); + if (DOS_FileExists(which_ret)) return which_ret; + strcpy(which_ret,name); + strcat(which_ret,exe_ext); + if (DOS_FileExists(which_ret)) return which_ret; + strcpy(which_ret,name); + strcat(which_ret,bat_ext); + if (DOS_FileExists(which_ret)) return which_ret; + /* No Path in filename look through path environment string */ static char path[DOS_PATHLENGTH];std::string temp; @@ -387,19 +385,17 @@ char * DOS_Shell::Which(char * name) { *path_write++=0; strcat(path,name); strcpy(which_ret,path); - if (ext) { - if (DOS_FileExists(which_ret)) return which_ret; - } else { - strcpy(which_ret,path); - strcat(which_ret,com_ext); - if (DOS_FileExists(which_ret)) return which_ret; - strcpy(which_ret,path); - strcat(which_ret,exe_ext); - if (DOS_FileExists(which_ret)) return which_ret; - strcpy(which_ret,path); - strcat(which_ret,bat_ext); - if (DOS_FileExists(which_ret)) return which_ret; - } + if (DOS_FileExists(which_ret)) return which_ret; + strcpy(which_ret,path); + strcat(which_ret,com_ext); + if (DOS_FileExists(which_ret)) return which_ret; + strcpy(which_ret,path); + strcat(which_ret,exe_ext); + if (DOS_FileExists(which_ret)) return which_ret; + strcpy(which_ret,path); + strcat(which_ret,bat_ext); + if (DOS_FileExists(which_ret)) return which_ret; + path_write=path; if (*pathenv) pathenv++; }