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
2ba9ee01
Commit
2ba9ee01
authored
Jun 21, 2014
by
Zhenbo Li
Committed by
Alexandre Julliard
Jun 25, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shell32: Fix SHFileOperation when deleting a nonexistent directory.
parent
d0803ef1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
38 deletions
+34
-38
shlfileop.c
dlls/shell32/shlfileop.c
+34
-34
shlfileop.c
dlls/shell32/tests/shlfileop.c
+0
-4
No files found.
dlls/shell32/shlfileop.c
View file @
2ba9ee01
...
...
@@ -347,36 +347,36 @@ HRESULT WINAPI SHIsFileAvailableOffline(LPCWSTR path, LPDWORD status)
* Asks for confirmation when bShowUI is true and deletes the directory and
* all its subdirectories and files if necessary.
*/
static
BOOL
SHELL_DeleteDirectoryW
(
HWND
hwnd
,
LPCWSTR
pszDir
,
BOOL
bShowUI
)
static
DWORD
SHELL_DeleteDirectoryW
(
HWND
hwnd
,
LPCWSTR
pszDir
,
BOOL
bShowUI
)
{
BOOL
ret
=
TRUE
;
HANDLE
hFind
;
WIN32_FIND_DATAW
wfd
;
WCHAR
szTemp
[
MAX_PATH
];
/* Make sure the directory exists before eventually prompting the user */
PathCombineW
(
szTemp
,
pszDir
,
wWildcardFile
);
hFind
=
FindFirstFileW
(
szTemp
,
&
wfd
);
if
(
hFind
==
INVALID_HANDLE_VALUE
)
return
FALSE
;
DWORD
ret
=
0
;
HANDLE
hFind
;
WIN32_FIND_DATAW
wfd
;
WCHAR
szTemp
[
MAX_PATH
];
PathCombineW
(
szTemp
,
pszDir
,
wWildcardFile
);
hFind
=
FindFirstFileW
(
szTemp
,
&
wfd
);
if
(
hFind
!=
INVALID_HANDLE_VALUE
)
{
if
(
!
bShowUI
||
SHELL_ConfirmDialogW
(
hwnd
,
ASK_DELETE_FOLDER
,
pszDir
,
NULL
))
{
do
{
if
(
IsDotDir
(
wfd
.
cFileName
))
continue
;
PathCombineW
(
szTemp
,
pszDir
,
wfd
.
cFileName
);
if
(
FILE_ATTRIBUTE_DIRECTORY
&
wfd
.
dwFileAttributes
)
ret
=
SHELL_DeleteDirectoryW
(
hwnd
,
szTemp
,
FALSE
);
else
ret
=
SHNotifyDeleteFileW
(
szTemp
);
}
while
(
!
ret
&&
FindNextFileW
(
hFind
,
&
wfd
));
}
FindClose
(
hFind
);
}
if
(
ret
==
ERROR_SUCCESS
)
ret
=
SHNotifyRemoveDirectoryW
(
pszDir
);
if
(
!
bShowUI
||
(
ret
=
SHELL_ConfirmDialogW
(
hwnd
,
ASK_DELETE_FOLDER
,
pszDir
,
NULL
)))
{
do
{
if
(
IsDotDir
(
wfd
.
cFileName
))
continue
;
PathCombineW
(
szTemp
,
pszDir
,
wfd
.
cFileName
);
if
(
FILE_ATTRIBUTE_DIRECTORY
&
wfd
.
dwFileAttributes
)
ret
=
SHELL_DeleteDirectoryW
(
hwnd
,
szTemp
,
FALSE
);
else
ret
=
(
SHNotifyDeleteFileW
(
szTemp
)
==
ERROR_SUCCESS
);
}
while
(
ret
&&
FindNextFileW
(
hFind
,
&
wfd
));
}
FindClose
(
hFind
);
if
(
ret
)
ret
=
(
SHNotifyRemoveDirectoryW
(
pszDir
)
==
ERROR_SUCCESS
);
return
ret
;
return
ret
==
ERROR_PATH_NOT_FOUND
?
0x7C
:
/* DE_INVALIDFILES (legacy Windows error) */
ret
;
}
/**************************************************************************
...
...
@@ -1331,8 +1331,7 @@ static BOOL confirm_delete_list(HWND hWnd, DWORD fFlags, BOOL fTrash, const FILE
static
DWORD
delete_files
(
LPSHFILEOPSTRUCTW
lpFileOp
,
const
FILE_LIST
*
flFrom
)
{
const
FILE_ENTRY
*
fileEntry
;
DWORD
i
;
BOOL
bPathExists
;
DWORD
i
,
ret
;
BOOL
bTrash
;
if
(
!
flFrom
->
dwNumFiles
)
...
...
@@ -1378,12 +1377,13 @@ static DWORD delete_files(LPSHFILEOPSTRUCTW lpFileOp, const FILE_LIST *flFrom)
/* delete the file or directory */
if
(
IsAttribFile
(
fileEntry
->
attributes
))
bPathExists
=
DeleteFileW
(
fileEntry
->
szFullPath
);
ret
=
DeleteFileW
(
fileEntry
->
szFullPath
)
?
ERROR_SUCCESS
:
GetLastError
();
else
bPathExists
=
SHELL_DeleteDirectoryW
(
lpFileOp
->
hwnd
,
fileEntry
->
szFullPath
,
FALSE
);
ret
=
SHELL_DeleteDirectoryW
(
lpFileOp
->
hwnd
,
fileEntry
->
szFullPath
,
FALSE
);
if
(
!
bPathExists
)
return
ERROR_PATH_NOT_FOUND
;
if
(
ret
)
return
ret
;
}
return
ERROR_SUCCESS
;
...
...
dlls/shell32/tests/shlfileop.c
View file @
2ba9ee01
...
...
@@ -622,7 +622,6 @@ static void test_delete(void)
shfo
.
pFrom
=
"nonexistent.txt
\0
"
;
shfo
.
wFunc
=
FO_DELETE
;
ret
=
SHFileOperationA
(
&
shfo
);
todo_wine
ok
(
ret
==
1026
||
ret
==
ERROR_FILE_NOT_FOUND
||
/* Vista */
broken
(
ret
==
ERROR_SUCCESS
),
/* NT4 */
...
...
@@ -651,7 +650,6 @@ static void test_delete(void)
shfo
.
pFrom
=
"test1.txt
\0
nonexistent.txt
\0
test2.txt
\0
"
;
shfo
.
wFunc
=
FO_DELETE
;
ret
=
SHFileOperationA
(
&
shfo
);
todo_wine
ok
(
ret
==
1026
||
ret
==
ERROR_FILE_NOT_FOUND
||
/* Vista */
broken
(
ret
==
ERROR_SUCCESS
),
/* NT4 */
...
...
@@ -664,14 +662,12 @@ static void test_delete(void)
init_shfo_tests
();
shfo
.
pFrom
=
"testdir2
\\
nonexistent.txt
\0
"
;
ret
=
SHFileOperationA
(
&
shfo
);
todo_wine
ok
(
ret
==
ERROR_FILE_NOT_FOUND
||
/* Vista */
broken
(
ret
==
0x402
)
||
/* XP */
broken
(
ret
==
ERROR_SUCCESS
),
/* NT4 */
"Expected 0x402 or ERROR_FILE_NOT_FOUND, got %x
\n
"
,
ret
);
shfo
.
pFrom
=
"nonexistent
\\
one.txt
\0
"
;
ret
=
SHFileOperationA
(
&
shfo
);
todo_wine
ok
(
ret
==
DE_INVALIDFILES
||
/* Vista or later */
broken
(
ret
==
0x402
),
/* XP */
"Expected 0x402 or DE_INVALIDFILES, got %x
\n
"
,
ret
);
...
...
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