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
86fe1a0d
Commit
86fe1a0d
authored
Jun 29, 2006
by
Mikołaj Zalewski
Committed by
Alexandre Julliard
Jun 30, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shell32: Use SHFileOperationW to delete files.
parent
48374cf6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
38 deletions
+69
-38
shfldr_fs.c
dlls/shell32/shfldr_fs.c
+69
-38
No files found.
dlls/shell32/shfldr_fs.c
View file @
86fe1a0d
...
...
@@ -1155,6 +1155,36 @@ ISFHelper_fnAddFolder (ISFHelper * iface, HWND hwnd, LPCWSTR pwszName,
}
/****************************************************************************
* build_paths_list
*
* Builds a list of paths like the one used in SHFileOperation from a table of
* PIDLs relative to the given base folder
*/
WCHAR
*
build_paths_list
(
LPCWSTR
wszBasePath
,
int
cidl
,
LPCITEMIDLIST
*
pidls
)
{
WCHAR
*
wszPathsList
;
WCHAR
*
wszListPos
;
int
iPathLen
;
int
i
;
iPathLen
=
lstrlenW
(
wszBasePath
);
wszPathsList
=
HeapAlloc
(
GetProcessHeap
(),
0
,
MAX_PATH
*
sizeof
(
WCHAR
)
*
cidl
+
1
);
wszListPos
=
wszPathsList
;
for
(
i
=
0
;
i
<
cidl
;
i
++
)
{
if
(
!
_ILIsFolder
(
pidls
[
i
])
&&
!
_ILIsValue
(
pidls
[
i
]))
continue
;
lstrcpynW
(
wszListPos
,
wszBasePath
,
MAX_PATH
);
/* FIXME: abort if path too long */
_ILSimpleGetTextW
(
pidls
[
i
],
wszListPos
+
iPathLen
,
MAX_PATH
-
iPathLen
);
wszListPos
+=
lstrlenW
(
wszListPos
)
+
1
;
}
*
wszListPos
=
0
;
return
wszPathsList
;
}
/****************************************************************************
* ISFHelper_fnDeleteItems
*
* deletes items in folder
...
...
@@ -1164,59 +1194,60 @@ ISFHelper_fnDeleteItems (ISFHelper * iface, UINT cidl, LPCITEMIDLIST * apidl)
{
IGenericSFImpl
*
This
=
impl_from_ISFHelper
(
iface
);
UINT
i
;
SHFILEOPSTRUCTW
op
;
WCHAR
wszPath
[
MAX_PATH
];
int
iPathLen
;
BOOL
bConfirm
=
TRUE
;
WCHAR
*
wszPathsList
;
HRESULT
ret
;
WCHAR
*
wszCurrentPath
;
TRACE
(
"(%p)(%u %p)
\n
"
,
This
,
cidl
,
apidl
);
/* deleting multiple items so give a slightly different warning */
if
(
cidl
!=
1
)
{
WCHAR
tmp
[
8
];
static
const
WCHAR
format
[]
=
{
'%'
,
'd'
,
0
};
wnsprintfW
(
tmp
,
sizeof
(
tmp
)
/
sizeof
(
tmp
[
0
]),
format
,
cidl
);
if
(
!
SHELL_ConfirmDialogW
(
ASK_DELETE_MULTIPLE_ITEM
,
tmp
))
return
E_FAIL
;
bConfirm
=
FALSE
;
}
if
(
cidl
==
0
)
return
S_OK
;
if
(
This
->
sPathTarget
)
lstrcpynW
(
wszPath
,
This
->
sPathTarget
,
MAX_PATH
);
else
wszPath
[
0
]
=
'\0'
;
PathAddBackslashW
(
wszPath
);
iPathLen
=
lstrlenW
(
wszPath
);
for
(
i
=
0
;
i
<
cidl
;
i
++
)
{
_ILSimpleGetTextW
(
apidl
[
i
],
wszPath
+
iPathLen
,
MAX_PATH
-
iPathLen
);
wszPathsList
=
build_paths_list
(
wszPath
,
cidl
,
apidl
);
ZeroMemory
(
&
op
,
sizeof
(
op
));
op
.
hwnd
=
GetActiveWindow
();
op
.
wFunc
=
FO_DELETE
;
op
.
pFrom
=
wszPathsList
;
op
.
fFlags
=
0
;
if
(
SHFileOperationW
(
&
op
))
{
WARN
(
"SHFileOperation failed
\n
"
);
ret
=
E_FAIL
;
}
else
ret
=
S_OK
;
if
(
_ILIsFolder
(
apidl
[
i
]))
{
LPITEMIDLIST
pidl
;
/* we currently need to manually send the notifies */
wszCurrentPath
=
wszPathsList
;
for
(
i
=
0
;
i
<
cidl
;
i
++
)
{
LONG
wEventId
;
TRACE
(
"delete %s
\n
"
,
debugstr_w
(
wszPath
));
if
(
!
SHELL_DeleteDirectoryW
(
wszPath
,
bConfirm
))
{
TRACE
(
"delete %s failed, bConfirm=%d
\n
"
,
debugstr_w
(
wszPath
),
bConfirm
);
return
E_FAIL
;
}
pidl
=
ILCombine
(
This
->
pidlRoot
,
apidl
[
i
]);
SHChangeNotify
(
SHCNE_RMDIR
,
SHCNF_IDLIST
,
pidl
,
NULL
);
SHFree
(
pidl
);
}
else
if
(
_ILIsValue
(
apidl
[
i
]))
{
LPITEMIDLIST
pidl
;
if
(
_ILIsFolder
(
apidl
[
i
]))
wEventId
=
SHCNE_RMDIR
;
else
if
(
_ILIsValue
(
apidl
[
i
]))
wEventId
=
SHCNE_DELETE
;
else
continue
;
TRACE
(
"delete %s
\n
"
,
debugstr_w
(
wszPath
));
if
(
!
SHELL_DeleteFileW
(
wszPath
,
bConfirm
))
{
TRACE
(
"delete %s failed, bConfirm=%d
\n
"
,
debugstr_w
(
wszPath
),
bConfirm
);
return
E_FAIL
;
}
pidl
=
ILCombine
(
This
->
pidlRoot
,
apidl
[
i
]);
SHChangeNotify
(
SHCNE_DELETE
,
SHCNF_IDLIST
,
pidl
,
NULL
);
SHFree
(
pidl
);
/* check if file exists */
if
(
GetFileAttributesW
(
wszCurrentPath
)
==
INVALID_FILE_ATTRIBUTES
)
{
LPITEMIDLIST
pidl
=
ILCombine
(
This
->
pidlRoot
,
apidl
[
i
]);
SHChangeNotify
(
wEventId
,
SHCNF_IDLIST
,
pidl
,
NULL
);
SHFree
(
pidl
);
}
wszCurrentPath
+=
lstrlenW
(
wszCurrentPath
)
+
1
;
}
return
S_OK
;
HeapFree
(
GetProcessHeap
(),
0
,
wszPathsList
);
return
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