Well the mac source code does this below which does some sanity checks on the size of the path, then resolves the squeak supplied string to the name understood by the flavor of os-x bsd unix. (Mind there is a bug lurking here, but I'll let people guess).
Also note the side effect of changing lastPath to 0x00 if the path being deleted is the same as the lastPath. Where lastPath is a cached value of the last directory used for performance reasons.
After all this we call rmdir() which "The rmdir utility removes the directory entry specified by each directory argument, provided it is empty."
sqInt dir_Delete(char *pathString, sqInt pathStringLength) { /* Delete the existing directory with the given path. */ char name[DOCUMENT_NAME_SIZE+1]; if (pathStringLength >= DOCUMENT_NAME_SIZE) return false; if (!ioFilenamefromStringofLengthresolveAliasesRetry (name,pathString, pathStringLength, false, true)) return false; if (strcmp(lastPath, name) == 0) lastPath[0] = 0x00; return rmdir(name) == 0; }
For windows it does
int dir_Delete(char *pathString, int pathLength) { /* Delete the existing directory with the given path. */ WCHAR win32Path[MAX_PATH]; int sz; /* convert the file name into a null-terminated C string */ sz = MultiByteToWideChar(CP_UTF8, 0, pathString, pathLength, NULL, 0); if(sz > MAX_PATH) return 0; MultiByteToWideChar(CP_UTF8, 0, pathString, pathLength, win32Path, sz); win32Path[sz] = 0; if(hasCaseSensitiveDuplicate(win32Path)) return false; return RemoveDirectoryW(win32Path) == 0 ? false : true; }
http://msdn2.microsoft.com/en-us/library/aa365488.aspx
Lastly wasn't there some google code of summer work, looking at passing back error messages from the VM in a more meaningful manner.
On Aug 28, 2007, at 10:20 AM, Michael Rueger wrote:
Hi all,
Grit just ran into an -interesting to say the least- problem with recursive deletion of directories on Windows. We are not able to provide a stripped down test case yet, but here some info:
- we extract a zip archive to provide an initial setup for Plopp data
- then the user can play around in demo mode (problem doesn't occur
in a full version as the deletion doesn't take place)
- upon quitting demo mode all data is erased via a recursive
directory delete
We have simple test up without running the UI to reproduce the problem.
The delete fails about 1 in 10 with a primitive failed in deleteDirectory.
There are no open files or anything obvious.
Now the interesting part... If we add a delay of 1 sec after catching the error and then simply retry the exception to delete the directory again, it works.
[Painter3DStorage storageDirectory recursiveDelete] on: Error do: [: exception | (Delay forMilliseconds: 1000) wait. exeption retry]
Any ideas?
Michael
-- ======================================================================== === John M. McIntosh johnmci@smalltalkconsulting.com Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com ======================================================================== ===