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
44aa4503
Commit
44aa4503
authored
Jun 14, 2010
by
Damjan Jovanovic
Committed by
Alexandre Julliard
Jun 14, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Revert
3f1404bf
and add better CopyFile tests.
parent
1145b29d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
6 deletions
+55
-6
path.c
dlls/kernel32/path.c
+1
-1
file.c
dlls/kernel32/tests/file.c
+54
-5
No files found.
dlls/kernel32/path.c
View file @
44aa4503
...
...
@@ -911,7 +911,7 @@ BOOL WINAPI CopyFileW( LPCWSTR source, LPCWSTR dest, BOOL fail_if_exists )
return
FALSE
;
}
if
((
h2
=
CreateFileW
(
dest
,
GENERIC_WRITE
,
FILE_SHARE_READ
,
NULL
,
if
((
h2
=
CreateFileW
(
dest
,
GENERIC_WRITE
,
FILE_SHARE_READ
|
FILE_SHARE_WRITE
,
NULL
,
fail_if_exists
?
CREATE_NEW
:
CREATE_ALWAYS
,
info
.
dwFileAttributes
,
h1
))
==
INVALID_HANDLE_VALUE
)
{
...
...
dlls/kernel32/tests/file.c
View file @
44aa4503
...
...
@@ -591,6 +591,11 @@ static void test_CopyFileA(void)
ret
=
MoveFileA
(
source
,
source
);
todo_wine
ok
(
ret
,
"MoveFileA: failed, error %d
\n
"
,
GetLastError
());
/* copying a file to itself must fail */
retok
=
CopyFileA
(
source
,
source
,
FALSE
);
todo_wine
ok
(
!
retok
&&
(
GetLastError
()
==
ERROR_SHARING_VIOLATION
||
broken
(
GetLastError
()
==
ERROR_FILE_EXISTS
)
/* Win 9x */
),
"copying a file to itself didn't fail (ret=%d, err=%d)
\n
"
,
retok
,
GetLastError
());
/* make the source have not zero size */
hfile
=
CreateFileA
(
source
,
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
ok
(
hfile
!=
INVALID_HANDLE_VALUE
,
"failed to open source file
\n
"
);
...
...
@@ -598,10 +603,6 @@ static void test_CopyFileA(void)
ok
(
retok
&&
ret
==
sizeof
(
prefix
),
"WriteFile error %d
\n
"
,
GetLastError
());
ok
(
GetFileSize
(
hfile
,
NULL
)
==
sizeof
(
prefix
),
"source file has wrong size
\n
"
);
/* copying a file to itself must fail */
retok
=
CopyFileA
(
source
,
source
,
FALSE
);
ok
(
!
retok
&&
(
GetLastError
()
==
ERROR_SHARING_VIOLATION
||
broken
(
GetLastError
()
==
ERROR_FILE_EXISTS
)
/* Win 9x */
),
"copying a file to itself didn't fail (ret=%d, err=%d)
\n
"
,
retok
,
GetLastError
());
/* get the file time and change it to prove the difference */
ret
=
GetFileTime
(
hfile
,
NULL
,
NULL
,
&
ft1
);
ok
(
ret
,
"GetFileTime error %d
\n
"
,
GetLastError
());
...
...
@@ -622,7 +623,35 @@ static void test_CopyFileA(void)
ret
=
CopyFileA
(
source
,
dest
,
FALSE
);
ok
(
ret
,
"CopyFileA: error %d
\n
"
,
GetLastError
());
/* destination file is write-locked during copy */
/* copying from a read-locked source fails */
hfile
=
CreateFileA
(
source
,
GENERIC_READ
,
FILE_SHARE_WRITE
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
ok
(
hfile
!=
INVALID_HANDLE_VALUE
,
"failed to open source file, error %d
\n
"
,
GetLastError
());
retok
=
CopyFileA
(
source
,
dest
,
FALSE
);
ok
(
!
retok
&&
GetLastError
()
==
ERROR_SHARING_VIOLATION
,
"copying from a read-locked file succeeded when it shouldn't have
\n
"
);
/* in addition, the source is opened before the destination */
retok
=
CopyFileA
(
"25f99d3b-4ba4-4f66-88f5-2906886993cc"
,
dest
,
FALSE
);
ok
(
!
retok
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
"copying from a file that doesn't exist failed in an unexpected way (ret=%d, err=%d)
\n
"
,
retok
,
GetLastError
());
CloseHandle
(
hfile
);
/* copying from a r+w opened, r shared source succeeds */
hfile
=
CreateFileA
(
source
,
GENERIC_READ
|
GENERIC_WRITE
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
ok
(
hfile
!=
INVALID_HANDLE_VALUE
,
"failed to open source file, error %d
\n
"
,
GetLastError
());
retok
=
CopyFileA
(
source
,
dest
,
FALSE
);
ok
(
retok
,
"copying from an r+w opened and r shared file failed (ret=%d, err=%d)
\n
"
,
ret
,
GetLastError
());
CloseHandle
(
hfile
);
/* copying from a delete-locked source is unreliable */
hfile
=
CreateFileA
(
source
,
DELETE
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
ok
(
hfile
!=
INVALID_HANDLE_VALUE
,
"failed to open source file, error %d
\n
"
,
GetLastError
());
retok
=
CopyFileA
(
source
,
dest
,
FALSE
);
ok
((
!
retok
&&
GetLastError
()
==
ERROR_SHARING_VIOLATION
)
||
broken
(
retok
)
/* 98, Vista, 2k8, 7 */
,
"copying from a delete-locked file failed (ret=%d, err=%d)
\n
"
,
ret
,
GetLastError
());
CloseHandle
(
hfile
);
/* copying to a write-locked destination fails */
hfile
=
CreateFileA
(
dest
,
GENERIC_WRITE
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
ok
(
hfile
!=
INVALID_HANDLE_VALUE
,
"failed to open destination file, error %d
\n
"
,
GetLastError
());
retok
=
CopyFileA
(
source
,
dest
,
FALSE
);
...
...
@@ -630,6 +659,26 @@ static void test_CopyFileA(void)
"copying to a write-locked file didn't fail (ret=%d, err=%d)
\n
"
,
ret
,
GetLastError
());
CloseHandle
(
hfile
);
/* copying to a r+w opened, w shared destination mostly succeeds */
hfile
=
CreateFileA
(
dest
,
GENERIC_READ
|
GENERIC_WRITE
,
FILE_SHARE_WRITE
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
ok
(
hfile
!=
INVALID_HANDLE_VALUE
,
"failed to open destination file, error %d
\n
"
,
GetLastError
());
retok
=
CopyFileA
(
source
,
dest
,
FALSE
);
ok
(
retok
||
broken
(
!
retok
&&
GetLastError
()
==
ERROR_SHARING_VIOLATION
)
/* Win 9x */
,
"copying to a r+w opened and w shared file failed (ret=%d, err=%d)
\n
"
,
ret
,
GetLastError
());
CloseHandle
(
hfile
);
/* copying to a delete-locked destination fails, even when the destination is delete-shared */
hfile
=
CreateFileA
(
dest
,
DELETE
,
FILE_SHARE_READ
|
FILE_SHARE_WRITE
|
FILE_SHARE_DELETE
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
ok
(
hfile
!=
INVALID_HANDLE_VALUE
||
broken
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
)
/* Win 9x */
,
"failed to open destination file, error %d
\n
"
,
GetLastError
());
if
(
hfile
!=
INVALID_HANDLE_VALUE
)
{
retok
=
CopyFileA
(
source
,
dest
,
FALSE
);
ok
(
!
retok
&&
GetLastError
()
==
ERROR_SHARING_VIOLATION
,
"copying to a delete-locked shared file didn't fail (ret=%d, err=%d)
\n
"
,
ret
,
GetLastError
());
CloseHandle
(
hfile
);
}
/* make sure that destination has correct size */
hfile
=
CreateFileA
(
dest
,
GENERIC_READ
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
ok
(
hfile
!=
INVALID_HANDLE_VALUE
,
"failed to open destination file
\n
"
);
...
...
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