1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[split-file] Fix sys::fs::remove() on Solaris after D83834

where stdio.h ::remove() may set errno to EEXIST instead of ENOTEMPTY.

POSIX.1-2017 allows EEXIST for unlink() (which is called by remove()):

> [EEXIST] or [ENOTEMPTY]
> The flag parameter has the AT_REMOVEDIR bit set and the path argument names a directory that is not an empty directory, or there are hard links to the directory other than dot or a single entry in dot-dot.

Reviewed By: ro

Differential Revision: https://reviews.llvm.org/D85690
This commit is contained in:
Fangrui Song 2020-08-10 15:02:10 -07:00
parent 9857b3e63f
commit 367b809d42

View File

@ -166,7 +166,8 @@ int main(int argc, const char **argv) {
status.type() != sys::fs::file_type::regular_file)
fatal(output, "output cannot be a special file");
if (std::error_code ec = sys::fs::remove(output, /*IgnoreNonExisting=*/true))
if (ec.value() != static_cast<int>(std::errc::directory_not_empty))
if (ec.value() != static_cast<int>(std::errc::directory_not_empty) &&
ec.value() != static_cast<int>(std::errc::file_exists))
fatal(output, ec.message());
return handle(**bufferOrErr, input);
}