cmd: Support copy to an 'ascii' destination.

This commit is contained in:
Jason Edmeades 2012-10-12 00:37:24 +01:00 committed by Alexandre Julliard
parent a65314c8fa
commit 260210f6e6
2 changed files with 48 additions and 11 deletions

View file

@ -370,6 +370,36 @@ void WCMD_choice (const WCHAR * command) {
}
}
/****************************************************************************
* WCMD_AppendEOF
*
* Adds an EOF onto the end of a file
* Returns TRUE on success
*/
static BOOL WCMD_AppendEOF(WCHAR *filename)
{
HANDLE h;
char eof = '\x1a';
WINE_TRACE("Appending EOF to %s\n", wine_dbgstr_w(filename));
h = CreateFileW(filename, GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (h == NULL) {
WINE_ERR("Failed to open %s (%d)\n", wine_dbgstr_w(filename), GetLastError());
return FALSE;
} else {
SetFilePointer (h, 0, NULL, FILE_END);
if (!WriteFile(h, &eof, 1, NULL, NULL)) {
WINE_ERR("Failed to append EOF to %s (%d)\n", wine_dbgstr_w(filename), GetLastError());
return FALSE;
}
CloseHandle(h);
}
return TRUE;
}
/****************************************************************************
* WCMD_copy
*
@ -800,10 +830,6 @@ void WCMD_copy(WCHAR * command) {
WINE_FIXME("Need to ascii copy %s to %s - dropping to binary copy\n",
wine_dbgstr_w(srcpath), wine_dbgstr_w(outname));
}
/* Append EOF if ascii destination and we are not going to add more onto the end */
if (!destination->binarycopy && !anyconcats) {
WINE_FIXME("Need to ascii copy destination (append EOF)\n");
}
status = CopyFileW(srcpath, outname, FALSE);
if (!status) {
WCMD_print_error ();
@ -811,6 +837,14 @@ void WCMD_copy(WCHAR * command) {
} else {
WINE_TRACE("Copied successfully\n");
if (anyconcats) writtenoneconcat = TRUE;
/* Append EOF if ascii destination and we are not going to add more onto the end */
if (!destination->binarycopy && !anyconcats) {
if (!WCMD_AppendEOF(outname)) {
WCMD_print_error ();
errorlevel = 1;
}
}
}
}
}
@ -829,8 +863,11 @@ void WCMD_copy(WCHAR * command) {
}
/* Append EOF if ascii destination and we were concatenating */
if (!destination->binarycopy && anyconcats && writtenoneconcat) {
WINE_FIXME("Need to ascii copy destination (append EOF) to concatenated file\n");
if (!errorlevel && !destination->binarycopy && anyconcats && writtenoneconcat) {
if (!WCMD_AppendEOF(destination->name)) {
WCMD_print_error ();
errorlevel = 1;
}
}
/* Exit out of the routine, freeing any remaing allocated memory */

View file

@ -879,14 +879,14 @@ Passed: file size check on file2 [8]@or_broken@Skipping file size check on NT4
Passed: file size check on file3 [11]@or_broken@Skipping file size check on NT4
Passed: file size check on file1_default [5]@or_broken@Skipping file size check on NT4
Passed: file size check on file1_default2 [5]@or_broken@Skipping file size check on NT4
@todo_wine@Passed: file size check on file1_plus_eof [6]@or_broken@Skipping file size check on NT4
@todo_wine@Passed: file size check on file2_plus_eof [9]@or_broken@Skipping file size check on NT4
@todo_wine@Passed: file size check on file3_plus_eof [12]@or_broken@Skipping file size check on NT4
Passed: file size check on file1_plus_eof [6]@or_broken@Skipping file size check on NT4
Passed: file size check on file2_plus_eof [9]@or_broken@Skipping file size check on NT4
Passed: file size check on file3_plus_eof [12]@or_broken@Skipping file size check on NT4
@todo_wine@Passed: file size check on file12_plus_eof [14]@or_broken@Skipping file size check on NT4
@todo_wine@Passed: file size check on file12_no_eof [13]@or_broken@Skipping file size check on NT4
@todo_wine@Passed: file size check on file12_eof2 [14]@or_broken@Skipping file size check on NT4
@todo_wine@Passed: file size check on file1_binary_srccopy [6]@or_broken@Skipping file size check on NT4
Passed: file size check on file1_ascii_srccopy [5]@or_broken@Skipping file size check on NT4
Passed: file size check on file1_binary_srccopy [6]@or_broken@Skipping file size check on NT4
@todo_wine@Passed: file size check on file1_ascii_srccopy [5]@or_broken@Skipping file size check on NT4
@todo_wine@Passed: file size check on file123_default_copy [25]@or_broken@Skipping file size check on NT4
@todo_wine@Passed: file size check on file123_ascii_copy [25]@or_broken@Skipping file size check on NT4
@todo_wine@Passed: file size check on file123_binary_copy [27]@or_broken@Skipping file size check on NT4