Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
e8f4909a
Commit
e8f4909a
authored
Feb 07, 2024
by
Gabriel Ivăncescu
Committed by
Alexandre Julliard
Feb 12, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernelbase: Copy the read-only attribute from the source.
Signed-off-by:
Gabriel Ivăncescu
<
gabrielopcode@gmail.com
>
parent
267a5658
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
2 deletions
+52
-2
file.c
dlls/kernel32/tests/file.c
+50
-0
file.c
dlls/kernelbase/file.c
+2
-2
No files found.
dlls/kernel32/tests/file.c
View file @
e8f4909a
...
...
@@ -850,6 +850,56 @@ static void test_CopyFileA(void)
CloseHandle
(
hmapfile
);
CloseHandle
(
hfile
);
/* check read-only attribute */
ret
=
GetFileAttributesA
(
source
);
ok
(
ret
!=
INVALID_FILE_ATTRIBUTES
,
"GetFileAttributesA: error %ld
\n
"
,
GetLastError
());
ok
(
!
(
ret
&
FILE_ATTRIBUTE_READONLY
),
"source is read-only
\n
"
);
ret
=
GetFileAttributesA
(
dest
);
ok
(
ret
!=
INVALID_FILE_ATTRIBUTES
,
"GetFileAttributesA: error %ld
\n
"
,
GetLastError
());
ok
(
!
(
ret
&
FILE_ATTRIBUTE_READONLY
),
"dest is read-only
\n
"
);
/* make source read-only */
ret
=
SetFileAttributesA
(
source
,
FILE_ATTRIBUTE_READONLY
);
ok
(
ret
,
"SetFileAttributesA: error %ld
\n
"
,
GetLastError
());
ret
=
GetFileAttributesA
(
source
);
ok
(
ret
!=
INVALID_FILE_ATTRIBUTES
,
"GetFileAttributesA: error %ld
\n
"
,
GetLastError
());
ok
(
ret
&
FILE_ATTRIBUTE_READONLY
,
"source is not read-only
\n
"
);
ret
=
GetFileAttributesA
(
dest
);
ok
(
ret
!=
INVALID_FILE_ATTRIBUTES
,
"GetFileAttributesA: error %ld
\n
"
,
GetLastError
());
ok
(
!
(
ret
&
FILE_ATTRIBUTE_READONLY
),
"dest is read-only
\n
"
);
/* dest becomes read-only after copied from read-only source */
ret
=
SetFileAttributesA
(
source
,
FILE_ATTRIBUTE_READONLY
);
ok
(
ret
,
"SetFileAttributesA: error %ld
\n
"
,
GetLastError
());
ret
=
GetFileAttributesA
(
source
);
ok
(
ret
!=
INVALID_FILE_ATTRIBUTES
,
"GetFileAttributesA: error %ld
\n
"
,
GetLastError
());
ok
(
ret
&
FILE_ATTRIBUTE_READONLY
,
"source is not read-only
\n
"
);
ret
=
GetFileAttributesA
(
dest
);
ok
(
ret
!=
INVALID_FILE_ATTRIBUTES
,
"GetFileAttributesA: error %ld
\n
"
,
GetLastError
());
ok
(
!
(
ret
&
FILE_ATTRIBUTE_READONLY
),
"dest is read-only
\n
"
);
ret
=
CopyFileA
(
source
,
dest
,
FALSE
);
ok
(
ret
,
"CopyFileA: error %ld
\n
"
,
GetLastError
());
ret
=
GetFileAttributesA
(
dest
);
ok
(
ret
!=
INVALID_FILE_ATTRIBUTES
,
"GetFileAttributesA: error %ld
\n
"
,
GetLastError
());
ok
(
ret
&
FILE_ATTRIBUTE_READONLY
,
"dest is not read-only
\n
"
);
/* same when dest does not exist */
ret
=
SetFileAttributesA
(
dest
,
FILE_ATTRIBUTE_NORMAL
);
ok
(
ret
,
"SetFileAttributesA: error %ld
\n
"
,
GetLastError
());
ret
=
DeleteFileA
(
dest
);
ok
(
ret
,
"DeleteFileA: error %ld
\n
"
,
GetLastError
());
ret
=
CopyFileA
(
source
,
dest
,
TRUE
);
ok
(
ret
,
"CopyFileA: error %ld
\n
"
,
GetLastError
());
ret
=
GetFileAttributesA
(
dest
);
ok
(
ret
!=
INVALID_FILE_ATTRIBUTES
,
"GetFileAttributesA: error %ld
\n
"
,
GetLastError
());
ok
(
ret
&
FILE_ATTRIBUTE_READONLY
,
"dest is not read-only
\n
"
);
ret
=
SetFileAttributesA
(
source
,
FILE_ATTRIBUTE_NORMAL
);
ok
(
ret
,
"SetFileAttributesA: error %ld
\n
"
,
GetLastError
());
ret
=
SetFileAttributesA
(
dest
,
FILE_ATTRIBUTE_NORMAL
);
ok
(
ret
,
"SetFileAttributesA: error %ld
\n
"
,
GetLastError
());
ret
=
DeleteFileA
(
source
);
ok
(
ret
,
"DeleteFileA: error %ld
\n
"
,
GetLastError
());
ret
=
DeleteFileA
(
dest
);
...
...
dlls/kernelbase/file.c
View file @
e8f4909a
...
...
@@ -579,8 +579,8 @@ BOOL WINAPI CopyFileExW( const WCHAR *source, const WCHAR *dest, LPPROGRESS_ROUT
}
ret
=
TRUE
;
done:
/* Maintain the timestamp of source file to destination file */
info
.
FileAttributes
=
0
;
/* Maintain the timestamp of source file to destination file
and read-only attribute
*/
info
.
FileAttributes
&=
FILE_ATTRIBUTE_READONLY
;
NtSetInformationFile
(
h2
,
&
io
,
&
info
,
sizeof
(
info
),
FileBasicInformation
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
CloseHandle
(
h1
);
...
...
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