[PATCH v2 0/1] MR8200: cmd: COPY should output file names as they are copied.
In native Windows, the COPY command will display the names of the files as they are copied. Wine should do the same. This change enables that. -- v2: cmd: COPY should output file names as they are copied. https://gitlab.winehq.org/wine/wine/-/merge_requests/8200
From: Joe Souza <jsouza(a)yahoo.com> --- programs/cmd/builtins.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index b78ae9d293b..e4e9e12db2c 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -954,6 +954,9 @@ RETURN_CODE WCMD_copy(WCHAR * args) WCHAR *filenamepart; DWORD attributes; BOOL srcisdevice = FALSE; + BOOL havewildcards = FALSE; + BOOL displaynames = FALSE; + unsigned numcopied = 0; /* If it was not explicit, we now know whether we are concatenating or not and hence whether to copy as binary or ascii */ @@ -965,6 +968,9 @@ RETURN_CODE WCMD_copy(WCHAR * args) return errorlevel = ERROR_INVALID_FUNCTION; WINE_TRACE("Full src name is '%s'\n", wine_dbgstr_w(srcpath)); + havewildcards = wcspbrk(srcpath, L"*?") ? TRUE : FALSE; + displaynames = havewildcards; + /* If parameter is a directory, ensure it ends in \* */ attributes = GetFileAttributesW(srcpath); if (ends_with_backslash( srcpath )) { @@ -972,17 +978,19 @@ RETURN_CODE WCMD_copy(WCHAR * args) /* We need to know where the filename part starts, so append * and recalculate the full resulting path */ lstrcatW(thiscopy->name, L"*"); + displaynames = TRUE; if (!WCMD_get_fullpath(thiscopy->name, ARRAY_SIZE(srcpath), srcpath, &filenamepart)) return errorlevel = ERROR_INVALID_FUNCTION; WINE_TRACE("Directory, so full name is now '%s'\n", wine_dbgstr_w(srcpath)); - } else if ((wcspbrk(srcpath, L"*?") == NULL) && + } else if (!havewildcards && (attributes != INVALID_FILE_ATTRIBUTES) && (attributes & FILE_ATTRIBUTE_DIRECTORY)) { /* We need to know where the filename part starts, so append \* and recalculate the full resulting path */ lstrcatW(thiscopy->name, L"\\*"); + displaynames = TRUE; if (!WCMD_get_fullpath(thiscopy->name, ARRAY_SIZE(srcpath), srcpath, &filenamepart)) return errorlevel = ERROR_INVALID_FUNCTION; WINE_TRACE("Directory, so full name is now '%s'\n", wine_dbgstr_w(srcpath)); @@ -1097,6 +1105,11 @@ RETURN_CODE WCMD_copy(WCHAR * args) return_code = ERROR_INVALID_FUNCTION; } else { WINE_TRACE("Copied successfully\n"); + if (displaynames) { + WCMD_output_asis(srcpath); + WCMD_output_asis(L"\r\n"); + } + numcopied++; if (anyconcats) writtenoneconcat = TRUE; /* Append EOF if ascii destination and we are not going to add more onto the end @@ -1114,7 +1127,14 @@ RETURN_CODE WCMD_copy(WCHAR * args) return_code = ERROR_INVALID_FUNCTION; } } while (!srcisdevice && FindNextFileW(hff, &fd) != 0); - if (!srcisdevice) FindClose (hff); + if (!srcisdevice) { + FindClose (hff); + if (numcopied) { + WCHAR string[64]; + swprintf(string, ARRAY_SIZE(string), L"\t%u file(s) copied\r\n", numcopied); + WCMD_output_asis(string); + } + } } else { /* Error if the first file was not found */ if (!anyconcats || !writtenoneconcat) { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/8200
participants (2)
-
Joe Souza -
Joe Souza (@JoeS209)