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
57d44382
Commit
57d44382
authored
Aug 21, 2015
by
Qian Hong
Committed by
Alexandre Julliard
Aug 21, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll/tests: Add tests for FileLinkInformation class.
Based on the FileRenameInformation tests by Sebastian Lackner.
parent
3bed65b5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
630 additions
and
0 deletions
+630
-0
file.c
dlls/ntdll/tests/file.c
+630
-0
No files found.
dlls/ntdll/tests/file.c
View file @
57d44382
...
...
@@ -2079,6 +2079,635 @@ static void test_file_rename_information(void)
delete_object
(
newpath
);
}
static
void
test_file_link_information
(
void
)
{
static
const
WCHAR
foo_txtW
[]
=
{
'\\'
,
'f'
,
'o'
,
'o'
,
'.'
,
't'
,
'x'
,
't'
,
0
};
static
const
WCHAR
fooW
[]
=
{
'f'
,
'o'
,
'o'
,
0
};
WCHAR
tmp_path
[
MAX_PATH
],
oldpath
[
MAX_PATH
+
16
],
newpath
[
MAX_PATH
+
16
],
*
filename
,
*
p
;
FILE_LINK_INFORMATION
*
fli
;
FILE_NAME_INFORMATION
*
fni
;
BOOL
success
,
fileDeleted
;
UNICODE_STRING
name_str
;
HANDLE
handle
,
handle2
;
IO_STATUS_BLOCK
io
;
NTSTATUS
res
;
GetTempPathW
(
MAX_PATH
,
tmp_path
);
/* oldpath is a file, newpath doesn't exist */
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
oldpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
handle
=
CreateFileW
(
oldpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
newpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
pRtlDosPathNameToNtPathName_U
(
newpath
,
&
name_str
,
NULL
,
NULL
);
DeleteFileW
(
newpath
);
fli
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_LINK_INFORMATION
)
+
name_str
.
Length
);
fli
->
ReplaceIfExists
=
FALSE
;
fli
->
RootDirectory
=
NULL
;
fli
->
FileNameLength
=
name_str
.
Length
;
memcpy
(
fli
->
FileName
,
name_str
.
Buffer
,
name_str
.
Length
);
pRtlFreeUnicodeString
(
&
name_str
);
U
(
io
).
Status
=
0xdeadbeef
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
fli
,
sizeof
(
FILE_LINK_INFORMATION
)
+
fli
->
FileNameLength
,
FileLinkInformation
);
todo_wine
ok
(
U
(
io
).
Status
==
STATUS_SUCCESS
,
"io.Status expected STATUS_SUCCESS, got %x
\n
"
,
U
(
io
).
Status
);
todo_wine
ok
(
res
==
STATUS_SUCCESS
,
"res expected STATUS_SUCCESS, got %x
\n
"
,
res
);
fileDeleted
=
GetFileAttributesW
(
oldpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
fileDeleted
=
GetFileAttributesW
(
newpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
todo_wine
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
fni
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_NAME_INFORMATION
)
+
MAX_PATH
*
sizeof
(
WCHAR
)
);
res
=
pNtQueryInformationFile
(
handle
,
&
io
,
fni
,
sizeof
(
FILE_NAME_INFORMATION
)
+
MAX_PATH
*
sizeof
(
WCHAR
),
FileNameInformation
);
ok
(
res
==
STATUS_SUCCESS
,
"res expected STATUS_SUCCESS, got %x
\n
"
,
res
);
fni
->
FileName
[
fni
->
FileNameLength
/
sizeof
(
WCHAR
)
]
=
0
;
ok
(
!
lstrcmpW
(
fni
->
FileName
,
oldpath
+
2
),
"FileName expected %s, got %s
\n
"
,
wine_dbgstr_w
(
oldpath
+
2
),
wine_dbgstr_w
(
fni
->
FileName
)
);
HeapFree
(
GetProcessHeap
(),
0
,
fni
);
CloseHandle
(
handle
);
HeapFree
(
GetProcessHeap
(),
0
,
fli
);
delete_object
(
oldpath
);
delete_object
(
newpath
);
/* oldpath is a file, newpath is a file, ReplaceIfExists = FALSE */
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
oldpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
handle
=
CreateFileW
(
oldpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
newpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
pRtlDosPathNameToNtPathName_U
(
newpath
,
&
name_str
,
NULL
,
NULL
);
fli
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_LINK_INFORMATION
)
+
name_str
.
Length
);
fli
->
ReplaceIfExists
=
FALSE
;
fli
->
RootDirectory
=
NULL
;
fli
->
FileNameLength
=
name_str
.
Length
;
memcpy
(
fli
->
FileName
,
name_str
.
Buffer
,
name_str
.
Length
);
pRtlFreeUnicodeString
(
&
name_str
);
U
(
io
).
Status
=
0xdeadbeef
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
fli
,
sizeof
(
FILE_LINK_INFORMATION
)
+
fli
->
FileNameLength
,
FileLinkInformation
);
todo_wine
ok
(
U
(
io
).
Status
==
0xdeadbeef
,
"io.Status expected 0xdeadbeef, got %x
\n
"
,
U
(
io
).
Status
);
todo_wine
ok
(
res
==
STATUS_OBJECT_NAME_COLLISION
,
"res expected STATUS_OBJECT_NAME_COLLISION, got %x
\n
"
,
res
);
fileDeleted
=
GetFileAttributesW
(
oldpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
fileDeleted
=
GetFileAttributesW
(
newpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
CloseHandle
(
handle
);
HeapFree
(
GetProcessHeap
(),
0
,
fli
);
delete_object
(
oldpath
);
delete_object
(
newpath
);
/* oldpath is a file, newpath is a file, ReplaceIfExists = TRUE */
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
oldpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
handle
=
CreateFileW
(
oldpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
newpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
pRtlDosPathNameToNtPathName_U
(
newpath
,
&
name_str
,
NULL
,
NULL
);
fli
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_LINK_INFORMATION
)
+
name_str
.
Length
);
fli
->
ReplaceIfExists
=
TRUE
;
fli
->
RootDirectory
=
NULL
;
fli
->
FileNameLength
=
name_str
.
Length
;
memcpy
(
fli
->
FileName
,
name_str
.
Buffer
,
name_str
.
Length
);
pRtlFreeUnicodeString
(
&
name_str
);
U
(
io
).
Status
=
0xdeadbeef
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
fli
,
sizeof
(
FILE_LINK_INFORMATION
)
+
fli
->
FileNameLength
,
FileLinkInformation
);
todo_wine
ok
(
U
(
io
).
Status
==
STATUS_SUCCESS
,
"io.Status expected STATUS_SUCCESS, got %x
\n
"
,
U
(
io
).
Status
);
todo_wine
ok
(
res
==
STATUS_SUCCESS
,
"res expected STATUS_SUCCESS, got %x
\n
"
,
res
);
fileDeleted
=
GetFileAttributesW
(
oldpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
fileDeleted
=
GetFileAttributesW
(
newpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
CloseHandle
(
handle
);
HeapFree
(
GetProcessHeap
(),
0
,
fli
);
delete_object
(
oldpath
);
delete_object
(
newpath
);
/* oldpath is a file, newpath is a file, ReplaceIfExists = FALSE, target file opened */
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
oldpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
handle
=
CreateFileW
(
oldpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
newpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
handle2
=
CreateFileW
(
newpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
ok
(
handle2
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
pRtlDosPathNameToNtPathName_U
(
newpath
,
&
name_str
,
NULL
,
NULL
);
fli
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_LINK_INFORMATION
)
+
name_str
.
Length
);
fli
->
ReplaceIfExists
=
FALSE
;
fli
->
RootDirectory
=
NULL
;
fli
->
FileNameLength
=
name_str
.
Length
;
memcpy
(
fli
->
FileName
,
name_str
.
Buffer
,
name_str
.
Length
);
pRtlFreeUnicodeString
(
&
name_str
);
U
(
io
).
Status
=
0xdeadbeef
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
fli
,
sizeof
(
FILE_LINK_INFORMATION
)
+
fli
->
FileNameLength
,
FileLinkInformation
);
todo_wine
ok
(
U
(
io
).
Status
==
0xdeadbeef
,
"io.Status expected 0xdeadbeef, got %x
\n
"
,
U
(
io
).
Status
);
todo_wine
ok
(
res
==
STATUS_OBJECT_NAME_COLLISION
,
"res expected STATUS_OBJECT_NAME_COLLISION, got %x
\n
"
,
res
);
fileDeleted
=
GetFileAttributesW
(
oldpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
fileDeleted
=
GetFileAttributesW
(
newpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
CloseHandle
(
handle
);
CloseHandle
(
handle2
);
HeapFree
(
GetProcessHeap
(),
0
,
fli
);
delete_object
(
oldpath
);
delete_object
(
newpath
);
/* oldpath is a file, newpath is a file, ReplaceIfExists = TRUE, target file opened */
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
oldpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
handle
=
CreateFileW
(
oldpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
newpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
handle2
=
CreateFileW
(
newpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
ok
(
handle2
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
pRtlDosPathNameToNtPathName_U
(
newpath
,
&
name_str
,
NULL
,
NULL
);
fli
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_LINK_INFORMATION
)
+
name_str
.
Length
);
fli
->
ReplaceIfExists
=
TRUE
;
fli
->
RootDirectory
=
NULL
;
fli
->
FileNameLength
=
name_str
.
Length
;
memcpy
(
fli
->
FileName
,
name_str
.
Buffer
,
name_str
.
Length
);
pRtlFreeUnicodeString
(
&
name_str
);
U
(
io
).
Status
=
0xdeadbeef
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
fli
,
sizeof
(
FILE_LINK_INFORMATION
)
+
fli
->
FileNameLength
,
FileLinkInformation
);
todo_wine
ok
(
U
(
io
).
Status
==
0xdeadbeef
,
"io.Status expected 0xdeadbeef, got %x
\n
"
,
U
(
io
).
Status
);
todo_wine
ok
(
res
==
STATUS_ACCESS_DENIED
,
"res expected STATUS_ACCESS_DENIED, got %x
\n
"
,
res
);
fileDeleted
=
GetFileAttributesW
(
oldpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
fileDeleted
=
GetFileAttributesW
(
newpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
CloseHandle
(
handle
);
CloseHandle
(
handle2
);
HeapFree
(
GetProcessHeap
(),
0
,
fli
);
delete_object
(
oldpath
);
delete_object
(
newpath
);
/* oldpath is a directory, newpath doesn't exist, ReplaceIfExists = FALSE */
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
oldpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
DeleteFileW
(
oldpath
);
success
=
CreateDirectoryW
(
oldpath
,
NULL
);
ok
(
success
!=
0
,
"failed to create temp directory
\n
"
);
handle
=
CreateFileW
(
oldpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
OPEN_EXISTING
,
FILE_FLAG_BACKUP_SEMANTICS
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
newpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
pRtlDosPathNameToNtPathName_U
(
newpath
,
&
name_str
,
NULL
,
NULL
);
DeleteFileW
(
newpath
);
fli
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_LINK_INFORMATION
)
+
name_str
.
Length
);
fli
->
ReplaceIfExists
=
FALSE
;
fli
->
RootDirectory
=
NULL
;
fli
->
FileNameLength
=
name_str
.
Length
;
memcpy
(
fli
->
FileName
,
name_str
.
Buffer
,
name_str
.
Length
);
pRtlFreeUnicodeString
(
&
name_str
);
U
(
io
).
Status
=
0xdeadbeef
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
fli
,
sizeof
(
FILE_LINK_INFORMATION
)
+
fli
->
FileNameLength
,
FileLinkInformation
);
todo_wine
ok
(
U
(
io
).
Status
==
0xdeadbeef
,
"io.Status expected 0xdeadbeef, got %x
\n
"
,
U
(
io
).
Status
);
todo_wine
ok
(
res
==
STATUS_FILE_IS_A_DIRECTORY
,
"res expected STATUS_FILE_IS_A_DIRECTORY, got %x
\n
"
,
res
);
fileDeleted
=
GetFileAttributesW
(
oldpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
fileDeleted
=
GetFileAttributesW
(
newpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
fileDeleted
,
"file should not exist
\n
"
);
fni
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_NAME_INFORMATION
)
+
MAX_PATH
*
sizeof
(
WCHAR
)
);
res
=
pNtQueryInformationFile
(
handle
,
&
io
,
fni
,
sizeof
(
FILE_NAME_INFORMATION
)
+
MAX_PATH
*
sizeof
(
WCHAR
),
FileNameInformation
);
ok
(
res
==
STATUS_SUCCESS
,
"res expected STATUS_SUCCESS, got %x
\n
"
,
res
);
fni
->
FileName
[
fni
->
FileNameLength
/
sizeof
(
WCHAR
)
]
=
0
;
ok
(
!
lstrcmpW
(
fni
->
FileName
,
oldpath
+
2
),
"FileName expected %s, got %s
\n
"
,
wine_dbgstr_w
(
oldpath
+
2
),
wine_dbgstr_w
(
fni
->
FileName
)
);
HeapFree
(
GetProcessHeap
(),
0
,
fni
);
CloseHandle
(
handle
);
HeapFree
(
GetProcessHeap
(),
0
,
fli
);
delete_object
(
oldpath
);
delete_object
(
newpath
);
/* oldpath is a directory (but child object opened), newpath doesn't exist, ReplaceIfExists = FALSE */
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
oldpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
DeleteFileW
(
oldpath
);
success
=
CreateDirectoryW
(
oldpath
,
NULL
);
ok
(
success
!=
0
,
"failed to create temp directory
\n
"
);
handle
=
CreateFileW
(
oldpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
OPEN_EXISTING
,
FILE_FLAG_BACKUP_SEMANTICS
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
lstrcpyW
(
newpath
,
oldpath
);
lstrcatW
(
newpath
,
foo_txtW
);
handle2
=
CreateFileW
(
newpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_FLAG_DELETE_ON_CLOSE
,
0
);
ok
(
handle2
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
newpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
pRtlDosPathNameToNtPathName_U
(
newpath
,
&
name_str
,
NULL
,
NULL
);
DeleteFileW
(
newpath
);
fli
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_LINK_INFORMATION
)
+
name_str
.
Length
);
fli
->
ReplaceIfExists
=
FALSE
;
fli
->
RootDirectory
=
NULL
;
fli
->
FileNameLength
=
name_str
.
Length
;
memcpy
(
fli
->
FileName
,
name_str
.
Buffer
,
name_str
.
Length
);
pRtlFreeUnicodeString
(
&
name_str
);
U
(
io
).
Status
=
0xdeadbeef
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
fli
,
sizeof
(
FILE_LINK_INFORMATION
)
+
fli
->
FileNameLength
,
FileLinkInformation
);
todo_wine
ok
(
U
(
io
).
Status
==
0xdeadbeef
,
"io.Status expected 0xdeadbeef, got %x
\n
"
,
U
(
io
).
Status
);
todo_wine
ok
(
res
==
STATUS_FILE_IS_A_DIRECTORY
,
"res expected STATUS_FILE_IS_A_DIRECTORY, got %x
\n
"
,
res
);
fileDeleted
=
GetFileAttributesW
(
oldpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
fileDeleted
=
GetFileAttributesW
(
newpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
fileDeleted
,
"file should not exist
\n
"
);
CloseHandle
(
handle
);
CloseHandle
(
handle2
);
HeapFree
(
GetProcessHeap
(),
0
,
fli
);
delete_object
(
oldpath
);
delete_object
(
newpath
);
/* oldpath is a directory, newpath is a file, ReplaceIfExists = FALSE */
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
oldpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
DeleteFileW
(
oldpath
);
success
=
CreateDirectoryW
(
oldpath
,
NULL
);
ok
(
success
!=
0
,
"failed to create temp directory
\n
"
);
handle
=
CreateFileW
(
oldpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
OPEN_EXISTING
,
FILE_FLAG_BACKUP_SEMANTICS
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
newpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
pRtlDosPathNameToNtPathName_U
(
newpath
,
&
name_str
,
NULL
,
NULL
);
fli
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_LINK_INFORMATION
)
+
name_str
.
Length
);
fli
->
ReplaceIfExists
=
FALSE
;
fli
->
RootDirectory
=
NULL
;
fli
->
FileNameLength
=
name_str
.
Length
;
memcpy
(
fli
->
FileName
,
name_str
.
Buffer
,
name_str
.
Length
);
pRtlFreeUnicodeString
(
&
name_str
);
U
(
io
).
Status
=
0xdeadbeef
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
fli
,
sizeof
(
FILE_LINK_INFORMATION
)
+
fli
->
FileNameLength
,
FileLinkInformation
);
todo_wine
ok
(
U
(
io
).
Status
==
0xdeadbeef
,
"io.Status expected 0xdeadbeef, got %x
\n
"
,
U
(
io
).
Status
);
todo_wine
ok
(
res
==
STATUS_OBJECT_NAME_COLLISION
||
res
==
STATUS_FILE_IS_A_DIRECTORY
/* > Win XP */
,
"res expected STATUS_OBJECT_NAME_COLLISION or STATUS_FILE_IS_A_DIRECTORY, got %x
\n
"
,
res
);
fileDeleted
=
GetFileAttributesW
(
oldpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
fileDeleted
=
GetFileAttributesW
(
newpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
CloseHandle
(
handle
);
HeapFree
(
GetProcessHeap
(),
0
,
fli
);
delete_object
(
oldpath
);
delete_object
(
newpath
);
/* oldpath is a directory, newpath is a file, ReplaceIfExists = FALSE, target file opened */
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
oldpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
DeleteFileW
(
oldpath
);
success
=
CreateDirectoryW
(
oldpath
,
NULL
);
ok
(
success
!=
0
,
"failed to create temp directory
\n
"
);
handle
=
CreateFileW
(
oldpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
OPEN_EXISTING
,
FILE_FLAG_BACKUP_SEMANTICS
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
newpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
handle2
=
CreateFileW
(
newpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
ok
(
handle2
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
pRtlDosPathNameToNtPathName_U
(
newpath
,
&
name_str
,
NULL
,
NULL
);
fli
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_LINK_INFORMATION
)
+
name_str
.
Length
);
fli
->
ReplaceIfExists
=
FALSE
;
fli
->
RootDirectory
=
NULL
;
fli
->
FileNameLength
=
name_str
.
Length
;
memcpy
(
fli
->
FileName
,
name_str
.
Buffer
,
name_str
.
Length
);
pRtlFreeUnicodeString
(
&
name_str
);
U
(
io
).
Status
=
0xdeadbeef
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
fli
,
sizeof
(
FILE_LINK_INFORMATION
)
+
fli
->
FileNameLength
,
FileLinkInformation
);
todo_wine
ok
(
U
(
io
).
Status
==
0xdeadbeef
,
"io.Status expected 0xdeadbeef, got %x
\n
"
,
U
(
io
).
Status
);
todo_wine
ok
(
res
==
STATUS_OBJECT_NAME_COLLISION
||
res
==
STATUS_FILE_IS_A_DIRECTORY
/* > Win XP */
,
"res expected STATUS_OBJECT_NAME_COLLISION or STATUS_FILE_IS_A_DIRECTORY, got %x
\n
"
,
res
);
fileDeleted
=
GetFileAttributesW
(
oldpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
fileDeleted
=
GetFileAttributesW
(
newpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
CloseHandle
(
handle
);
CloseHandle
(
handle2
);
HeapFree
(
GetProcessHeap
(),
0
,
fli
);
delete_object
(
oldpath
);
delete_object
(
newpath
);
/* oldpath is a directory, newpath is a file, ReplaceIfExists = TRUE */
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
oldpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
DeleteFileW
(
oldpath
);
success
=
CreateDirectoryW
(
oldpath
,
NULL
);
ok
(
success
!=
0
,
"failed to create temp directory
\n
"
);
handle
=
CreateFileW
(
oldpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
OPEN_EXISTING
,
FILE_FLAG_BACKUP_SEMANTICS
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
newpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
pRtlDosPathNameToNtPathName_U
(
newpath
,
&
name_str
,
NULL
,
NULL
);
fli
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_LINK_INFORMATION
)
+
name_str
.
Length
);
fli
->
ReplaceIfExists
=
TRUE
;
fli
->
RootDirectory
=
NULL
;
fli
->
FileNameLength
=
name_str
.
Length
;
memcpy
(
fli
->
FileName
,
name_str
.
Buffer
,
name_str
.
Length
);
pRtlFreeUnicodeString
(
&
name_str
);
U
(
io
).
Status
=
0xdeadbeef
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
fli
,
sizeof
(
FILE_LINK_INFORMATION
)
+
fli
->
FileNameLength
,
FileLinkInformation
);
todo_wine
ok
(
U
(
io
).
Status
==
0xdeadbeef
,
"io.Status expected 0xdeadbeef, got %x
\n
"
,
U
(
io
).
Status
);
todo_wine
ok
(
res
==
STATUS_FILE_IS_A_DIRECTORY
,
"res expected STATUS_FILE_IS_A_DIRECTORY, got %x
\n
"
,
res
);
fileDeleted
=
GetFileAttributesW
(
oldpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
fileDeleted
=
GetFileAttributesW
(
newpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
CloseHandle
(
handle
);
HeapFree
(
GetProcessHeap
(),
0
,
fli
);
delete_object
(
oldpath
);
delete_object
(
newpath
);
/* oldpath is a directory, newpath is a file, ReplaceIfExists = TRUE, target file opened */
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
oldpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
DeleteFileW
(
oldpath
);
success
=
CreateDirectoryW
(
oldpath
,
NULL
);
ok
(
success
!=
0
,
"failed to create temp directory
\n
"
);
handle
=
CreateFileW
(
oldpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
OPEN_EXISTING
,
FILE_FLAG_BACKUP_SEMANTICS
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
newpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
handle2
=
CreateFileW
(
newpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
ok
(
handle2
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
pRtlDosPathNameToNtPathName_U
(
newpath
,
&
name_str
,
NULL
,
NULL
);
fli
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_LINK_INFORMATION
)
+
name_str
.
Length
);
fli
->
ReplaceIfExists
=
TRUE
;
fli
->
RootDirectory
=
NULL
;
fli
->
FileNameLength
=
name_str
.
Length
;
memcpy
(
fli
->
FileName
,
name_str
.
Buffer
,
name_str
.
Length
);
pRtlFreeUnicodeString
(
&
name_str
);
U
(
io
).
Status
=
0xdeadbeef
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
fli
,
sizeof
(
FILE_LINK_INFORMATION
)
+
fli
->
FileNameLength
,
FileLinkInformation
);
todo_wine
ok
(
U
(
io
).
Status
==
0xdeadbeef
,
"io.Status expected 0xdeadbeef, got %x
\n
"
,
U
(
io
).
Status
);
todo_wine
ok
(
res
==
STATUS_FILE_IS_A_DIRECTORY
,
"res expected STATUS_FILE_IS_A_DIRECTORY, got %x
\n
"
,
res
);
fileDeleted
=
GetFileAttributesW
(
oldpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
fileDeleted
=
GetFileAttributesW
(
newpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
CloseHandle
(
handle
);
CloseHandle
(
handle2
);
HeapFree
(
GetProcessHeap
(),
0
,
fli
);
delete_object
(
oldpath
);
delete_object
(
newpath
);
/* oldpath is a directory, newpath is a directory, ReplaceIfExists = FALSE */
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
oldpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
DeleteFileW
(
oldpath
);
success
=
CreateDirectoryW
(
oldpath
,
NULL
);
ok
(
success
!=
0
,
"failed to create temp directory
\n
"
);
handle
=
CreateFileW
(
oldpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
OPEN_EXISTING
,
FILE_FLAG_BACKUP_SEMANTICS
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
newpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
DeleteFileW
(
newpath
);
success
=
CreateDirectoryW
(
newpath
,
NULL
);
ok
(
success
!=
0
,
"failed to create temp directory
\n
"
);
pRtlDosPathNameToNtPathName_U
(
newpath
,
&
name_str
,
NULL
,
NULL
);
fli
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_LINK_INFORMATION
)
+
name_str
.
Length
);
fli
->
ReplaceIfExists
=
FALSE
;
fli
->
RootDirectory
=
NULL
;
fli
->
FileNameLength
=
name_str
.
Length
;
memcpy
(
fli
->
FileName
,
name_str
.
Buffer
,
name_str
.
Length
);
pRtlFreeUnicodeString
(
&
name_str
);
U
(
io
).
Status
=
0xdeadbeef
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
fli
,
sizeof
(
FILE_LINK_INFORMATION
)
+
fli
->
FileNameLength
,
FileLinkInformation
);
todo_wine
ok
(
U
(
io
).
Status
==
0xdeadbeef
,
"io.Status expected 0xdeadbeef, got %x
\n
"
,
U
(
io
).
Status
);
todo_wine
ok
(
res
==
STATUS_OBJECT_NAME_COLLISION
||
res
==
STATUS_FILE_IS_A_DIRECTORY
/* > Win XP */
,
"res expected STATUS_OBJECT_NAME_COLLISION or STATUS_FILE_IS_A_DIRECTORY, got %x
\n
"
,
res
);
fileDeleted
=
GetFileAttributesW
(
oldpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
fileDeleted
=
GetFileAttributesW
(
newpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
CloseHandle
(
handle
);
HeapFree
(
GetProcessHeap
(),
0
,
fli
);
delete_object
(
oldpath
);
delete_object
(
newpath
);
/* oldpath is a directory, newpath is a directory, ReplaceIfExists = TRUE */
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
oldpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
DeleteFileW
(
oldpath
);
success
=
CreateDirectoryW
(
oldpath
,
NULL
);
ok
(
success
!=
0
,
"failed to create temp directory
\n
"
);
handle
=
CreateFileW
(
oldpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
OPEN_EXISTING
,
FILE_FLAG_BACKUP_SEMANTICS
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
newpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
DeleteFileW
(
newpath
);
success
=
CreateDirectoryW
(
newpath
,
NULL
);
ok
(
success
!=
0
,
"failed to create temp directory
\n
"
);
pRtlDosPathNameToNtPathName_U
(
newpath
,
&
name_str
,
NULL
,
NULL
);
fli
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_LINK_INFORMATION
)
+
name_str
.
Length
);
fli
->
ReplaceIfExists
=
TRUE
;
fli
->
RootDirectory
=
NULL
;
fli
->
FileNameLength
=
name_str
.
Length
;
memcpy
(
fli
->
FileName
,
name_str
.
Buffer
,
name_str
.
Length
);
pRtlFreeUnicodeString
(
&
name_str
);
U
(
io
).
Status
=
0xdeadbeef
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
fli
,
sizeof
(
FILE_LINK_INFORMATION
)
+
fli
->
FileNameLength
,
FileLinkInformation
);
todo_wine
ok
(
U
(
io
).
Status
==
0xdeadbeef
,
"io.Status expected 0xdeadbeef, got %x
\n
"
,
U
(
io
).
Status
);
todo_wine
ok
(
res
==
STATUS_FILE_IS_A_DIRECTORY
,
"res expected STATUS_FILE_IS_A_DIRECTORY, got %x
\n
"
,
res
);
fileDeleted
=
GetFileAttributesW
(
oldpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
fileDeleted
=
GetFileAttributesW
(
newpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
CloseHandle
(
handle
);
HeapFree
(
GetProcessHeap
(),
0
,
fli
);
delete_object
(
oldpath
);
delete_object
(
newpath
);
/* oldpath is a directory, newpath is a directory, ReplaceIfExists = TRUE, target file opened */
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
oldpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
DeleteFileW
(
oldpath
);
success
=
CreateDirectoryW
(
oldpath
,
NULL
);
ok
(
success
!=
0
,
"failed to create temp directory
\n
"
);
handle
=
CreateFileW
(
oldpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
OPEN_EXISTING
,
FILE_FLAG_BACKUP_SEMANTICS
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
newpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
DeleteFileW
(
newpath
);
success
=
CreateDirectoryW
(
newpath
,
NULL
);
ok
(
success
!=
0
,
"failed to create temp directory
\n
"
);
handle2
=
CreateFileW
(
newpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
OPEN_EXISTING
,
FILE_FLAG_BACKUP_SEMANTICS
,
0
);
ok
(
handle2
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
pRtlDosPathNameToNtPathName_U
(
newpath
,
&
name_str
,
NULL
,
NULL
);
fli
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_LINK_INFORMATION
)
+
name_str
.
Length
);
fli
->
ReplaceIfExists
=
TRUE
;
fli
->
RootDirectory
=
NULL
;
fli
->
FileNameLength
=
name_str
.
Length
;
memcpy
(
fli
->
FileName
,
name_str
.
Buffer
,
name_str
.
Length
);
pRtlFreeUnicodeString
(
&
name_str
);
U
(
io
).
Status
=
0xdeadbeef
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
fli
,
sizeof
(
FILE_LINK_INFORMATION
)
+
fli
->
FileNameLength
,
FileLinkInformation
);
todo_wine
ok
(
U
(
io
).
Status
==
0xdeadbeef
,
"io.Status expected 0xdeadbeef, got %x
\n
"
,
U
(
io
).
Status
);
todo_wine
ok
(
res
==
STATUS_FILE_IS_A_DIRECTORY
,
"res expected STATUS_FILE_IS_A_DIRECTORY, got %x
\n
"
,
res
);
fileDeleted
=
GetFileAttributesW
(
oldpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
fileDeleted
=
GetFileAttributesW
(
newpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
CloseHandle
(
handle
);
CloseHandle
(
handle2
);
HeapFree
(
GetProcessHeap
(),
0
,
fli
);
delete_object
(
oldpath
);
delete_object
(
newpath
);
/* oldpath is a file, newpath is a directory, ReplaceIfExists = FALSE */
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
oldpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
handle
=
CreateFileW
(
oldpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
newpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
DeleteFileW
(
newpath
);
success
=
CreateDirectoryW
(
newpath
,
NULL
);
ok
(
success
!=
0
,
"failed to create temp directory
\n
"
);
pRtlDosPathNameToNtPathName_U
(
newpath
,
&
name_str
,
NULL
,
NULL
);
fli
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_LINK_INFORMATION
)
+
name_str
.
Length
);
fli
->
ReplaceIfExists
=
FALSE
;
fli
->
RootDirectory
=
NULL
;
fli
->
FileNameLength
=
name_str
.
Length
;
memcpy
(
fli
->
FileName
,
name_str
.
Buffer
,
name_str
.
Length
);
pRtlFreeUnicodeString
(
&
name_str
);
U
(
io
).
Status
=
0xdeadbeef
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
fli
,
sizeof
(
FILE_LINK_INFORMATION
)
+
fli
->
FileNameLength
,
FileLinkInformation
);
todo_wine
ok
(
U
(
io
).
Status
==
0xdeadbeef
,
"io.Status expected 0xdeadbeef, got %x
\n
"
,
U
(
io
).
Status
);
todo_wine
ok
(
res
==
STATUS_OBJECT_NAME_COLLISION
,
"res expected STATUS_OBJECT_NAME_COLLISION, got %x
\n
"
,
res
);
fileDeleted
=
GetFileAttributesW
(
oldpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
fileDeleted
=
GetFileAttributesW
(
newpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
CloseHandle
(
handle
);
HeapFree
(
GetProcessHeap
(),
0
,
fli
);
delete_object
(
oldpath
);
delete_object
(
newpath
);
/* oldpath is a file, newpath is a directory, ReplaceIfExists = TRUE */
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
oldpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
handle
=
CreateFileW
(
oldpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
newpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
DeleteFileW
(
newpath
);
success
=
CreateDirectoryW
(
newpath
,
NULL
);
ok
(
success
!=
0
,
"failed to create temp directory
\n
"
);
pRtlDosPathNameToNtPathName_U
(
newpath
,
&
name_str
,
NULL
,
NULL
);
fli
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_LINK_INFORMATION
)
+
name_str
.
Length
);
fli
->
ReplaceIfExists
=
TRUE
;
fli
->
RootDirectory
=
NULL
;
fli
->
FileNameLength
=
name_str
.
Length
;
memcpy
(
fli
->
FileName
,
name_str
.
Buffer
,
name_str
.
Length
);
pRtlFreeUnicodeString
(
&
name_str
);
U
(
io
).
Status
=
0xdeadbeef
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
fli
,
sizeof
(
FILE_LINK_INFORMATION
)
+
fli
->
FileNameLength
,
FileLinkInformation
);
todo_wine
ok
(
U
(
io
).
Status
==
0xdeadbeef
,
"io.Status expected 0xdeadbeef, got %x
\n
"
,
U
(
io
).
Status
);
todo_wine
ok
(
res
==
STATUS_ACCESS_DENIED
,
"res expected STATUS_ACCESS_DENIED, got %x
\n
"
,
res
);
fileDeleted
=
GetFileAttributesW
(
oldpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
fileDeleted
=
GetFileAttributesW
(
newpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
CloseHandle
(
handle
);
HeapFree
(
GetProcessHeap
(),
0
,
fli
);
delete_object
(
oldpath
);
delete_object
(
newpath
);
/* oldpath is a file, newpath doesn't exist, test with RootDirectory != NULL */
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
oldpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
handle
=
CreateFileW
(
oldpath
,
GENERIC_WRITE
|
DELETE
,
0
,
NULL
,
CREATE_ALWAYS
,
0
,
0
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
res
=
GetTempFileNameW
(
tmp_path
,
fooW
,
0
,
newpath
);
ok
(
res
!=
0
,
"failed to create temp file
\n
"
);
DeleteFileW
(
newpath
);
for
(
filename
=
newpath
,
p
=
newpath
;
*
p
;
p
++
)
if
(
*
p
==
'\\'
)
filename
=
p
+
1
;
handle2
=
CreateFileW
(
tmp_path
,
0
,
0
,
NULL
,
OPEN_EXISTING
,
FILE_FLAG_BACKUP_SEMANTICS
,
0
);
ok
(
handle2
!=
INVALID_HANDLE_VALUE
,
"CreateFileW failed
\n
"
);
fli
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_LINK_INFORMATION
)
+
lstrlenW
(
filename
)
*
sizeof
(
WCHAR
)
);
fli
->
ReplaceIfExists
=
FALSE
;
fli
->
RootDirectory
=
handle2
;
fli
->
FileNameLength
=
lstrlenW
(
filename
)
*
sizeof
(
WCHAR
);
memcpy
(
fli
->
FileName
,
filename
,
fli
->
FileNameLength
);
U
(
io
).
Status
=
0xdeadbeef
;
res
=
pNtSetInformationFile
(
handle
,
&
io
,
fli
,
sizeof
(
FILE_LINK_INFORMATION
)
+
fli
->
FileNameLength
,
FileLinkInformation
);
todo_wine
ok
(
U
(
io
).
Status
==
STATUS_SUCCESS
,
"io.Status expected STATUS_SUCCESS, got %x
\n
"
,
U
(
io
).
Status
);
todo_wine
ok
(
res
==
STATUS_SUCCESS
,
"res expected STATUS_SUCCESS, got %x
\n
"
,
res
);
fileDeleted
=
GetFileAttributesW
(
oldpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
fileDeleted
=
GetFileAttributesW
(
newpath
)
==
INVALID_FILE_ATTRIBUTES
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
;
todo_wine
ok
(
!
fileDeleted
,
"file should exist
\n
"
);
fni
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FILE_NAME_INFORMATION
)
+
MAX_PATH
*
sizeof
(
WCHAR
)
);
res
=
pNtQueryInformationFile
(
handle
,
&
io
,
fni
,
sizeof
(
FILE_NAME_INFORMATION
)
+
MAX_PATH
*
sizeof
(
WCHAR
),
FileNameInformation
);
ok
(
res
==
STATUS_SUCCESS
,
"res expected STATUS_SUCCESS, got %x
\n
"
,
res
);
fni
->
FileName
[
fni
->
FileNameLength
/
sizeof
(
WCHAR
)
]
=
0
;
ok
(
!
lstrcmpW
(
fni
->
FileName
,
oldpath
+
2
),
"FileName expected %s, got %s
\n
"
,
wine_dbgstr_w
(
oldpath
+
2
),
wine_dbgstr_w
(
fni
->
FileName
)
);
HeapFree
(
GetProcessHeap
(),
0
,
fni
);
CloseHandle
(
handle
);
CloseHandle
(
handle2
);
HeapFree
(
GetProcessHeap
(),
0
,
fli
);
delete_object
(
oldpath
);
delete_object
(
newpath
);
}
static
void
test_file_both_information
(
void
)
{
IO_STATUS_BLOCK
io
;
...
...
@@ -3503,6 +4132,7 @@ START_TEST(file)
test_file_full_size_information
();
test_file_all_name_information
();
test_file_rename_information
();
test_file_link_information
();
test_file_disposition_information
();
test_query_volume_information_file
();
test_query_attribute_information_file
();
...
...
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