mirror of
https://github.com/reactos/reactos.git
synced 2025-04-26 16:40:27 +00:00
[ADVPACK] Handle ADN_DEL_IF_EMPTY in DelNodeW and DelNodeRunDLL32 (#5821)
- Handling ADN_DEL_IF_EMPTY is critical to avoid data loss. - SetFileAttributesW failing is not fatal, the delete might still succeed. NOTE: Not in Wine yet.
This commit is contained in:
parent
f283a3f9ae
commit
6eb8a1d0c7
1 changed files with 26 additions and 2 deletions
|
@ -341,9 +341,17 @@ static HRESULT DELNODE_recurse_dirtree(LPWSTR fname, DWORD flags)
|
||||||
HANDLE hFindFile;
|
HANDLE hFindFile;
|
||||||
WIN32_FIND_DATAW w32fd;
|
WIN32_FIND_DATAW w32fd;
|
||||||
BOOL done = TRUE;
|
BOOL done = TRUE;
|
||||||
int fname_len = lstrlenW(fname);
|
int fname_len;
|
||||||
|
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
if (flags & ADN_DEL_IF_EMPTY)
|
||||||
|
{
|
||||||
|
goto deleteinitialdirectory;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Generate a path with wildcard suitable for iterating */
|
/* Generate a path with wildcard suitable for iterating */
|
||||||
|
fname_len = lstrlenW(fname);
|
||||||
if (fname_len && fname[fname_len-1] != '\\') fname[fname_len++] = '\\';
|
if (fname_len && fname[fname_len-1] != '\\') fname[fname_len++] = '\\';
|
||||||
lstrcpyW(fname + fname_len, asterisk);
|
lstrcpyW(fname + fname_len, asterisk);
|
||||||
|
|
||||||
|
@ -371,8 +379,14 @@ static HRESULT DELNODE_recurse_dirtree(LPWSTR fname, DWORD flags)
|
||||||
|
|
||||||
if (done)
|
if (done)
|
||||||
{
|
{
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
deleteinitialdirectory:
|
||||||
TRACE("%s: directory\n", debugstr_w(fname));
|
TRACE("%s: directory\n", debugstr_w(fname));
|
||||||
|
SetFileAttributesW(fname, FILE_ATTRIBUTE_NORMAL);
|
||||||
|
if (RemoveDirectoryW(fname))
|
||||||
|
#else
|
||||||
if (SetFileAttributesW(fname, FILE_ATTRIBUTE_NORMAL) && RemoveDirectoryW(fname))
|
if (SetFileAttributesW(fname, FILE_ATTRIBUTE_NORMAL) && RemoveDirectoryW(fname))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
ret = S_OK;
|
ret = S_OK;
|
||||||
}
|
}
|
||||||
|
@ -381,7 +395,12 @@ static HRESULT DELNODE_recurse_dirtree(LPWSTR fname, DWORD flags)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TRACE("%s: file\n", debugstr_w(fname));
|
TRACE("%s: file\n", debugstr_w(fname));
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
SetFileAttributesW(fname, FILE_ATTRIBUTE_NORMAL);
|
||||||
|
if (DeleteFileW(fname))
|
||||||
|
#else
|
||||||
if (SetFileAttributesW(fname, FILE_ATTRIBUTE_NORMAL) && DeleteFileW(fname))
|
if (SetFileAttributesW(fname, FILE_ATTRIBUTE_NORMAL) && DeleteFileW(fname))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
ret = S_OK;
|
ret = S_OK;
|
||||||
}
|
}
|
||||||
|
@ -435,9 +454,14 @@ HRESULT WINAPI DelNodeW(LPCWSTR pszFileOrDirName, DWORD dwFlags)
|
||||||
HRESULT ret = E_FAIL;
|
HRESULT ret = E_FAIL;
|
||||||
|
|
||||||
TRACE("(%s, %d)\n", debugstr_w(pszFileOrDirName), dwFlags);
|
TRACE("(%s, %d)\n", debugstr_w(pszFileOrDirName), dwFlags);
|
||||||
|
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
if (dwFlags & ~ADN_DEL_IF_EMPTY)
|
||||||
|
FIXME("Flags %#x ignored!\n", dwFlags & ~ADN_DEL_IF_EMPTY);
|
||||||
|
#else
|
||||||
if (dwFlags)
|
if (dwFlags)
|
||||||
FIXME("Flags ignored!\n");
|
FIXME("Flags ignored!\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (pszFileOrDirName && *pszFileOrDirName)
|
if (pszFileOrDirName && *pszFileOrDirName)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue