Permalink
Browse files

Fix SunOS error code for a non-empty directory

According to `rmdir(2)` on SmartOS, error code returned when trying to
remove a directory which isn't empty is `EEXIST`, while on other
operating systems it's `ENOTEMPTY`.
  • Loading branch information...
1 parent 3d11bf5 commit 1c9d344f228fa43e936206c5c89f0aa7c83885ba @mmalecki mmalecki committed with Feb 6, 2013
Showing with 2 additions and 2 deletions.
  1. +2 −2 rimraf.js
View
@@ -69,11 +69,11 @@ function rimraf_ (p, cb) {
}
function rmdir (p, originalEr, cb) {
- // try to rmdir first, and only readdir on ENOTEMPTY
+ // try to rmdir first, and only readdir on ENOTEMPTY or EEXIST (SunOS)
// if we guessed wrong, and it's not a directory, then
// raise the original error.
fs.rmdir(p, function (er) {
- if (er && er.code === "ENOTEMPTY")
+ if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST"))
rmkids(p, cb)
else if (er && er.code === "ENOTDIR")
cb(originalEr)

0 comments on commit 1c9d344

Please sign in to comment.