]> granicus.if.org Git - llvm/commitdiff
Make FileOutputBuffer fail early if you pass a directory.
authorRui Ueyama <ruiu@google.com>
Mon, 13 Mar 2017 22:19:05 +0000 (22:19 +0000)
committerRui Ueyama <ruiu@google.com>
Mon, 13 Mar 2017 22:19:05 +0000 (22:19 +0000)
Previously, it created a temporary directory and then failed when
FileOutputBuffer tried to rename that file to the destination file
(which is actually a directory name).

Differential Revision: https://reviews.llvm.org/D30912

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297679 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/FileOutputBuffer.cpp

index 57e5a8d7871cd1887638bcb7d09ca7b5a09ba67e..731740d012d90887cce11f5ec2f914efb349c166 100644 (file)
@@ -57,6 +57,8 @@ FileOutputBuffer::create(StringRef FilePath, size_t Size, unsigned Flags) {
         // FIXME: In posix, you use the access() call to check this.
       }
       break;
+    case sys::fs::file_type::directory_file:
+      return errc::is_a_directory;
     default:
       if (EC)
         return EC;