diff options
author | Christopher Faylor <me@cgf.cx> | 2001-09-17 18:10:02 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2001-09-17 18:10:02 +0000 |
commit | 8238a68bb202ebf40dfa479a798d2a23ac92b40c (patch) | |
tree | ecd83800cc69cab510a7bc30ae6623fc941a6df4 /winsup/cygwin/dir.cc | |
parent | 3e985c99c07bfdea2fb4cabe2662f64fe54c4a7b (diff) | |
download | cygnal-8238a68bb202ebf40dfa479a798d2a23ac92b40c.tar.gz cygnal-8238a68bb202ebf40dfa479a798d2a23ac92b40c.tar.bz2 cygnal-8238a68bb202ebf40dfa479a798d2a23ac92b40c.zip |
* syscalls.cc (rmdir): Set cwd to some other location if attempting to rmdir
current working directory.
Diffstat (limited to 'winsup/cygwin/dir.cc')
-rw-r--r-- | winsup/cygwin/dir.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc index ab2bfab64..7b9b2d6b6 100644 --- a/winsup/cygwin/dir.cc +++ b/winsup/cygwin/dir.cc @@ -401,8 +401,29 @@ rmdir (const char *dir) } else { + /* This kludge detects if we are attempting to remove the current working + directory. If so, we will move elsewhere to potentially allow the + rmdir to succeed. This means that cygwin's concept of the current working + directory != Windows concept but, hey, whaddaregonnado? + Note that this will not cause something like the following to work: + $ cd foo + $ rmdir . + since the shell will have foo "open" in the above case and so Windows will + not allow the deletion. + FIXME: A potential workaround for this is for cygwin apps to *never* call + SetCurrentDirectory. */ + if (strcasematch (real_dir, cygheap->cwd.win32) + && !strcasematch ("c:\\", cygheap->cwd.win32)) + { + DWORD err = GetLastError (); + if (!SetCurrentDirectory ("c:\\")) + SetLastError (err); + else + return rmdir (dir); + } if (GetLastError() == ERROR_ACCESS_DENIED) { + /* On 9X ERROR_ACCESS_DENIED is returned if you try to remove a non-empty directory. */ if (wincap.access_denied_on_delete ()) |