Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
d16f4e70
Commit
d16f4e70
authored
Nov 09, 2012
by
Jason Edmeades
Committed by
Alexandre Julliard
Nov 20, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd: Add support for NUL in copy.
parent
2e928530
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
16 deletions
+61
-16
builtins.c
programs/cmd/builtins.c
+38
-14
test_builtins.cmd
programs/cmd/tests/test_builtins.cmd
+16
-1
test_builtins.cmd.exp
programs/cmd/tests/test_builtins.cmd.exp
+7
-1
No files found.
programs/cmd/builtins.c
View file @
d16f4e70
...
...
@@ -47,6 +47,7 @@ const WCHAR slashW[] = {'\\','\0'};
const
WCHAR
equalW
[]
=
{
'='
,
'\0'
};
const
WCHAR
wildcardsW
[]
=
{
'*'
,
'?'
,
'\0'
};
const
WCHAR
slashstarW
[]
=
{
'\\'
,
'*'
,
'\0'
};
const
WCHAR
deviceW
[]
=
{
'\\'
,
'\\'
,
'.'
,
'\\'
,
'\0'
};
const
WCHAR
inbuilt
[][
10
]
=
{
{
'C'
,
'A'
,
'L'
,
'L'
,
'\0'
},
{
'C'
,
'D'
,
'\0'
},
...
...
@@ -414,7 +415,7 @@ static BOOL WCMD_ManualCopy(WCHAR *srcname, WCHAR *dstname, BOOL ascii, BOOL app
BOOL
ok
;
DWORD
bytesread
,
byteswritten
;
WINE_TRACE
(
"
ASCII
Copying %s to %s (append?%d)
\n
"
,
WINE_TRACE
(
"
Manual
Copying %s to %s (append?%d)
\n
"
,
wine_dbgstr_w
(
srcname
),
wine_dbgstr_w
(
dstname
),
append
);
in
=
CreateFileW
(
srcname
,
GENERIC_READ
,
0
,
NULL
,
...
...
@@ -502,7 +503,7 @@ void WCMD_copy(WCHAR * args) {
int
argno
=
0
;
WCHAR
*
rawarg
;
WIN32_FIND_DATAW
fd
;
HANDLE
hff
;
HANDLE
hff
=
INVALID_HANDLE_VALUE
;
int
binarymode
=
-
1
;
/* -1 means use the default, 1 is binary, 0 ascii */
BOOL
concatnextfilename
=
FALSE
;
/* True if we have just processed a + */
BOOL
anyconcats
=
FALSE
;
/* Have we found any + options */
...
...
@@ -514,6 +515,7 @@ void WCMD_copy(WCHAR * args) {
BOOL
status
;
WCHAR
copycmd
[
4
];
DWORD
len
;
BOOL
dstisdevice
=
FALSE
;
static
const
WCHAR
copyCmdW
[]
=
{
'C'
,
'O'
,
'P'
,
'Y'
,
'C'
,
'M'
,
'D'
,
'\0'
};
typedef
struct
_COPY_FILES
...
...
@@ -785,6 +787,12 @@ void WCMD_copy(WCHAR * args) {
WINE_TRACE
(
"Resolved destination is '%s' (calc later %d)
\n
"
,
wine_dbgstr_w
(
destname
),
appendfirstsource
);
/* Remember if the destination is a device */
if
(
strncmpW
(
destination
->
name
,
deviceW
,
strlenW
(
deviceW
))
==
0
)
{
WINE_TRACE
(
"Destination is a device
\n
"
);
dstisdevice
=
TRUE
;
}
/* Now we need to walk the set of sources, and process each name we come to.
If anyconcats is true, we are writing to one file, otherwise we are using
the source name each time.
...
...
@@ -800,8 +808,10 @@ void WCMD_copy(WCHAR * args) {
while
(
thiscopy
!=
NULL
)
{
WCHAR
srcpath
[
MAX_PATH
];
const
WCHAR
*
srcname
;
WCHAR
*
filenamepart
;
DWORD
attributes
;
BOOL
srcisdevice
=
FALSE
;
/* If it was not explicit, we now know whether we are concatenating or not and
hence whether to copy as binary or ascii */
...
...
@@ -836,29 +846,41 @@ void WCMD_copy(WCHAR * args) {
WINE_TRACE
(
"Copy source (calculated): path: '%s' (Concats: %d)
\n
"
,
wine_dbgstr_w
(
srcpath
),
anyconcats
);
/* Loop through all source files */
WINE_TRACE
(
"Searching for: '%s'
\n
"
,
wine_dbgstr_w
(
srcpath
));
hff
=
FindFirstFileW
(
srcpath
,
&
fd
);
if
(
hff
!=
INVALID_HANDLE_VALUE
)
{
/* If the source is a device, just use it, otherwise search */
if
(
strncmpW
(
srcpath
,
deviceW
,
strlenW
(
deviceW
))
==
0
)
{
WINE_TRACE
(
"Source is a device
\n
"
);
srcisdevice
=
TRUE
;
srcname
=
&
srcpath
[
4
];
/* After the \\.\ prefix */
}
else
{
/* Loop through all source files */
WINE_TRACE
(
"Searching for: '%s'
\n
"
,
wine_dbgstr_w
(
srcpath
));
hff
=
FindFirstFileW
(
srcpath
,
&
fd
);
if
(
hff
!=
INVALID_HANDLE_VALUE
)
{
srcname
=
fd
.
cFileName
;
}
}
if
(
srcisdevice
||
hff
!=
INVALID_HANDLE_VALUE
)
{
do
{
WCHAR
outname
[
MAX_PATH
];
BOOL
overwrite
;
/* Skip . and .., and directories */
if
(
fd
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
{
if
(
!
srcisdevice
&&
fd
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
{
WINE_TRACE
(
"Skipping directories
\n
"
);
}
else
{
/* Build final destination name */
strcpyW
(
outname
,
destination
->
name
);
if
(
destisdirectory
||
appendfirstsource
)
strcatW
(
outname
,
fd
.
cFileN
ame
);
if
(
destisdirectory
||
appendfirstsource
)
strcatW
(
outname
,
srcn
ame
);
/* Build source name */
strcpyW
(
filenamepart
,
fd
.
cFileN
ame
);
if
(
!
srcisdevice
)
strcpyW
(
filenamepart
,
srcn
ame
);
/* Do we just overwrite */
/* Do we just overwrite
(we do if we are writing to a device)
*/
overwrite
=
!
prompt
;
if
(
anyconcats
&&
writtenoneconcat
)
{
if
(
dstisdevice
||
(
anyconcats
&&
writtenoneconcat
)
)
{
overwrite
=
TRUE
;
}
...
...
@@ -879,7 +901,7 @@ void WCMD_copy(WCHAR * args) {
else
overwrite
=
TRUE
;
}
/* If we needed t
y
o save away the first filename, do it */
/* If we needed to save away the first filename, do it */
if
(
appendfirstsource
&&
overwrite
)
{
heap_free
(
destination
->
name
);
destination
->
name
=
heap_strdupW
(
outname
);
...
...
@@ -898,6 +920,8 @@ void WCMD_copy(WCHAR * args) {
}
}
else
if
(
!
thiscopy
->
binarycopy
)
{
status
=
WCMD_ManualCopy
(
srcpath
,
outname
,
TRUE
,
FALSE
);
}
else
if
(
srcisdevice
)
{
status
=
WCMD_ManualCopy
(
srcpath
,
outname
,
FALSE
,
FALSE
);
}
else
{
status
=
CopyFileW
(
srcpath
,
outname
,
FALSE
);
}
...
...
@@ -921,8 +945,8 @@ void WCMD_copy(WCHAR * args) {
}
}
}
}
while
(
FindNextFileW
(
hff
,
&
fd
)
!=
0
);
FindClose
(
hff
);
}
while
(
!
srcisdevice
&&
FindNextFileW
(
hff
,
&
fd
)
!=
0
);
if
(
!
srcisdevice
)
FindClose
(
hff
);
}
else
{
/* Error if the first file was not found */
if
(
!
anyconcats
||
(
anyconcats
&&
!
writtenoneconcat
))
{
...
...
programs/cmd/tests/test_builtins.cmd
View file @
d16f4e70
...
...
@@ -607,7 +607,22 @@ if exist foo (
) else (
echo ***
)
cd .. & rd foobar
echo 1234 >a.a
copy a.a+NUL b.b >nul
call :CheckFileSize a.a 7 b.b 8
copy NUL+a.a b.b >nul
call :CheckFileSize a.a 7 b.b 8
mkdir subdir
copy a.a+NUL subdir\ >nul
call :CheckFileSize a.a 7 subdir\a.a 8
del subdir\a.a
cd subdir
copy ..\a.a NUL >nul
if exist a.a echo Failed
cd ..
rd subdir /s /q
del a.a b.b
cd .. & rd foobar /s /q
echo ------------ Testing if/else ------------
echo --- if/else should work with blocks
...
...
programs/cmd/tests/test_builtins.cmd.exp
View file @
d16f4e70
...
...
@@ -415,7 +415,13 @@ bar
bar
bar
NUL
@todo_wine@foo created
foo created
Passed: file size check on a.a [7]@or_broken@Skipping file size check on NT4
Passed: file size check on b.b [8]@or_broken@Skipping file size check on NT4
Passed: file size check on a.a [7]@or_broken@Skipping file size check on NT4
Passed: file size check on b.b [8]@or_broken@Skipping file size check on NT4
Passed: file size check on a.a [7]@or_broken@Skipping file size check on NT4
Passed: file size check on subdir\a.a [8]@or_broken@Skipping file size check on NT4
------------ Testing if/else ------------
--- if/else should work with blocks
if seems to work
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment