Help verfy Windows XP Home Bug ?
-
I am having classical code to delete file to the recycle bin: bool DeleteToRecycleBin(const char *pszFilePath) { //double-zero terminated string char szFile[1024]; strncpy(szFile, pszFilePath, sizeof(szFile)-1); szFile[strlen(szFile)+1] = '\0'; SHFILEOPSTRUCT fileop; ZeroMemory(&fileop, sizeof(SHFILEOPSTRUCT)); fileop.wFunc = FO_DELETE; fileop.pFrom = szFile; fileop.pTo = NULL; fileop.fFlags = FOF_ALLOWUNDO | FOF_SILENT | FOF_NOERRORUI | FOF_NOCONFIRMATION; if(SHFileOperation(&fileop) != 0) { //failed to delete to recycle return false; } return (0 != _access(szFile, 0)); //return true; } I found this very spooky problem when calling this function on the following file ararngement: 1. inside some test directory create directory "VC6-ch04-Documents and Views_files" 2. inside test directory create file "VC6-ch04-Documents and Views.htm" 3. when trying to delete the file, as a bonus, function also deletes the directory !!!! (grrr, I've lost some important data this way). I also repeated this problem using delete feature from Total Commander file manager on the same OS plaform. I didn't test if this bug is "available" on other versions. Can anyone verify this bug (OS: windows XP Home, SP1, Compiler: VC++ 6.0) ? Also, if this is the bug, where can I report it officialy ? Miroslav Rajcic
-
I am having classical code to delete file to the recycle bin: bool DeleteToRecycleBin(const char *pszFilePath) { //double-zero terminated string char szFile[1024]; strncpy(szFile, pszFilePath, sizeof(szFile)-1); szFile[strlen(szFile)+1] = '\0'; SHFILEOPSTRUCT fileop; ZeroMemory(&fileop, sizeof(SHFILEOPSTRUCT)); fileop.wFunc = FO_DELETE; fileop.pFrom = szFile; fileop.pTo = NULL; fileop.fFlags = FOF_ALLOWUNDO | FOF_SILENT | FOF_NOERRORUI | FOF_NOCONFIRMATION; if(SHFileOperation(&fileop) != 0) { //failed to delete to recycle return false; } return (0 != _access(szFile, 0)); //return true; } I found this very spooky problem when calling this function on the following file ararngement: 1. inside some test directory create directory "VC6-ch04-Documents and Views_files" 2. inside test directory create file "VC6-ch04-Documents and Views.htm" 3. when trying to delete the file, as a bonus, function also deletes the directory !!!! (grrr, I've lost some important data this way). I also repeated this problem using delete feature from Total Commander file manager on the same OS plaform. I didn't test if this bug is "available" on other versions. Can anyone verify this bug (OS: windows XP Home, SP1, Compiler: VC++ 6.0) ? Also, if this is the bug, where can I report it officialy ? Miroslav Rajcic
Don't be so quick to blame the OS.
FOF_NO_CONNECTED_ELEMENTS
--Mike-- Latest blog entry: *drool* (Alyson) [May 10] Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber "You have Erica on the brain" - Jon Sagara to me -
Don't be so quick to blame the OS.
FOF_NO_CONNECTED_ELEMENTS
--Mike-- Latest blog entry: *drool* (Alyson) [May 10] Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber "You have Erica on the brain" - Jon Sagara to meThanks for your help, problem is soleved now However, I still consider this an awfull practice. MSDN coming with Visual C++ 6.0 never mentions theis flag. That means that all older programs will live in ilusion thet they have implemented single file deletion (example might be already mentioned Total Commander). They might be surprised a lot just like me. I managed to compile the code only by manually definig this flag (value found by google). Anyway, enough ranting, thanks. Miroslav Rajcic