Handle "copy H*.txt file.txt" correctly
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3907
This commit is contained in:
parent
1363f5ed68
commit
e4b97eb62e
1 changed files with 12 additions and 4 deletions
|
@ -682,13 +682,16 @@ void DOS_Shell::CMD_COPY(char * args) {
|
|||
if(temp) *temp = 0;//strip off *.* from target
|
||||
|
||||
// add '\\' if target is a directory
|
||||
bool target_is_file = true;
|
||||
if (pathTarget[strlen(pathTarget)-1]!='\\') {
|
||||
if (DOS_FindFirst(pathTarget,0xffff & ~DOS_ATTR_VOLUME)) {
|
||||
dta.GetResult(name,size,date,time,attr);
|
||||
if (attr & DOS_ATTR_DIRECTORY)
|
||||
if (attr & DOS_ATTR_DIRECTORY) {
|
||||
strcat(pathTarget,"\\");
|
||||
target_is_file = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
} else target_is_file = false;
|
||||
|
||||
//Find first sourcefile
|
||||
bool ret = DOS_FindFirst(const_cast<char*>(source.filename.c_str()),0xffff & ~DOS_ATTR_VOLUME);
|
||||
|
@ -701,7 +704,8 @@ void DOS_Shell::CMD_COPY(char * args) {
|
|||
Bit16u sourceHandle,targetHandle;
|
||||
char nameTarget[DOS_PATHLENGTH];
|
||||
char nameSource[DOS_PATHLENGTH];
|
||||
|
||||
|
||||
bool second_file_of_current_source = false;
|
||||
while (ret) {
|
||||
dta.GetResult(name,size,date,time,attr);
|
||||
|
||||
|
@ -714,6 +718,10 @@ void DOS_Shell::CMD_COPY(char * args) {
|
|||
strcpy(nameTarget,pathTarget);
|
||||
if (nameTarget[strlen(nameTarget)-1]=='\\') strcat(nameTarget,name);
|
||||
|
||||
//Special variable to ensure that copy * a_file, where a_file is not a directory concats.
|
||||
bool special = second_file_of_current_source && target_is_file;
|
||||
second_file_of_current_source = true;
|
||||
if (special) oldsource.concat = true;
|
||||
//Don't create a new file when in concat mode
|
||||
if (oldsource.concat || DOS_CreateFile(nameTarget,0,&targetHandle)) {
|
||||
Bit32u dummy=0;
|
||||
|
@ -731,7 +739,7 @@ void DOS_Shell::CMD_COPY(char * args) {
|
|||
failed |= DOS_CloseFile(sourceHandle);
|
||||
failed |= DOS_CloseFile(targetHandle);
|
||||
WriteOut(" %s\n",name);
|
||||
if(!source.concat) count++; //Only count concat files once
|
||||
if(!source.concat && !special) count++; //Only count concat files once
|
||||
} else {
|
||||
DOS_CloseFile(sourceHandle);
|
||||
WriteOut(MSG_Get("SHELL_CMD_COPY_FAILURE"),const_cast<char*>(target.filename.c_str()));
|
||||
|
|
Loading…
Add table
Reference in a new issue