diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-06-11 22:53:00 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-06-11 22:53:00 +0000 |
commit | da70bfd82650d80ee43e9c6ff5f202da959ef09b (patch) | |
tree | 4b1bcc747cc94d9b87e9daa8b2c5e9755cff27c5 /llvm/lib/Support/Unix/Path.inc | |
parent | e8ad3839a19e0731b8c8ba716263ecbea0223c03 (diff) | |
download | llvm-da70bfd82650d80ee43e9c6ff5f202da959ef09b.zip llvm-da70bfd82650d80ee43e9c6ff5f202da959ef09b.tar.gz llvm-da70bfd82650d80ee43e9c6ff5f202da959ef09b.tar.bz2 |
Implement get_magic with generic tools and inline it.
llvm-svn: 210716
Diffstat (limited to 'llvm/lib/Support/Unix/Path.inc')
-rw-r--r-- | llvm/lib/Support/Unix/Path.inc | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc index ef291db..7ebf1b4 100644 --- a/llvm/lib/Support/Unix/Path.inc +++ b/llvm/lib/Support/Unix/Path.inc @@ -622,37 +622,6 @@ error_code detail::directory_iterator_increment(detail::DirIterState &it) { return error_code(); } -error_code get_magic(const Twine &path, uint32_t len, - SmallVectorImpl<char> &result) { - SmallString<128> PathStorage; - StringRef Path = path.toNullTerminatedStringRef(PathStorage); - result.set_size(0); - - // Open path. - std::FILE *file = std::fopen(Path.data(), "rb"); - if (!file) - return error_code(errno, generic_category()); - - // Reserve storage. - result.reserve(len); - - // Read magic! - size_t size = std::fread(result.data(), 1, len, file); - if (std::ferror(file) != 0) { - std::fclose(file); - return error_code(errno, generic_category()); - } else if (size != len) { - if (std::feof(file) != 0) { - std::fclose(file); - result.set_size(size); - return make_error_code(std::errc::value_too_large); - } - } - std::fclose(file); - result.set_size(size); - return error_code(); -} - error_code openFileForRead(const Twine &Name, int &ResultFD) { SmallString<128> Storage; StringRef P = Name.toNullTerminatedStringRef(Storage); |