Subject: | MSDN says: Do not use GetLastError with SHFileOperation |
In DeleteEx, you end with:
unless ($Win32::FileOp::fileop->Call($opstruct)) {
return 1;
} else {
$! = Win32::GetLastError();
return undef;
}
}
First, I think that should be an empty return statement. Second, see
http://msdn.microsoft.com/en-us/library/bb762164(VS.85).aspx:
Returns zero if successful; otherwise nonzero. Applications normally
should simply check for zero or nonzero.
It is good practice to examine the value of the fAnyOperationsAborted
member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success
if the user cancels the operation. If you do not check
fAnyOperationsAborted as well as the return value, you cannot know that
the function accomplished the full task you asked of it and you might
proceed under incorrect assumptions.
Do not use GetLastError with the return values of this function.
To examine the nonzero values for troubleshooting purposes, they largely
map to those defined in Winerror.h. However, several of its possible
return values are based on pre-Win32 error codes, which in some cases
overlap the later Winerror.h values without matching their meaning.
Those particular values are detailed here, and for these specific values
only these meanings should be accepted over the Winerror.h codes.
However, these values are provided with these warnings: