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
This commit is contained in:
Rafael Espindola
2013-07-17 14:58:25 +00:00
parent 86f4f6526b
commit b0aa9e9718
4 changed files with 41 additions and 17 deletions
+9
View File
@@ -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