summaryrefslogtreecommitdiff
path: root/lib/Support/Unix
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-07-17 14:58:25 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-07-17 14:58:25 +0000
commitb0aa9e9718181952d5a636c72ff32c8d4352685b (patch)
tree6c6fa65ca4b3dbd4b94de38d3332f22104cd078f /lib/Support/Unix
parent86f4f6526b18765cdb78bee593e1354bc9f55085 (diff)
downloadllvm-b0aa9e9718181952d5a636c72ff32c8d4352685b.tar.gz
llvm-b0aa9e9718181952d5a636c72ff32c8d4352685b.tar.bz2
llvm-b0aa9e9718181952d5a636c72ff32c8d4352685b.tar.xz
Split openFileForRead into Windows and Unix versions.
This has some advantages: * Lets us use native, utf16 windows functions. * Easy to produce good errors on windows about trying to use a directory when we want a file. * Simplifies the unix version a bit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186511 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Unix')
-rw-r--r--lib/Support/Unix/Path.inc9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Support/Unix/Path.inc b/lib/Support/Unix/Path.inc
index 0c1623acdc..84f8d37493 100644
--- a/lib/Support/Unix/Path.inc
+++ b/lib/Support/Unix/Path.inc
@@ -815,6 +815,15 @@ error_code unmap_file_pages(void *base, size_t size) {
return error_code::success();
}
+error_code openFileForRead(const Twine &Name, int &ResultFD) {
+ SmallString<128> Storage;
+ StringRef P = Name.toNullTerminatedStringRef(Storage);
+ while ((ResultFD = open(P.begin(), O_RDONLY)) < 0) {
+ if (errno != EINTR)
+ return error_code(errno, system_category());
+ }
+ return error_code::success();
+}
} // end namespace fs
} // end namespace sys