summaryrefslogtreecommitdiffstats
path: root/llvm/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
commita0d9b6b69322b27fae1c646271b5d4cc44a7bce5 (patch)
treeb9800e9a52d1c9eb5727d2db575463f25071a81c /llvm/lib/Support/Unix
parentec7cd269680336be3eb0a99e1752bba05eb07d38 (diff)
downloadbcm5719-llvm-a0d9b6b69322b27fae1c646271b5d4cc44a7bce5.tar.gz
bcm5719-llvm-a0d9b6b69322b27fae1c646271b5d4cc44a7bce5.zip
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. llvm-svn: 186511
Diffstat (limited to 'llvm/lib/Support/Unix')
-rw-r--r--llvm/lib/Support/Unix/Path.inc9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
index 0c1623acdc7..84f8d374931 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/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
OpenPOWER on IntegriCloud