diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2011-01-15 20:39:36 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2011-01-15 20:39:36 +0000 |
commit | 94b2ab3556a6b4f0f78720f494bdb4cff243c419 (patch) | |
tree | 082fa028191516fa1a8154daa6afaa4a8758f589 /llvm/lib/Support/PathV2.cpp | |
parent | fff2517edcec21184fb86d3b48bed11885032587 (diff) | |
download | bcm5719-llvm-94b2ab3556a6b4f0f78720f494bdb4cff243c419.tar.gz bcm5719-llvm-94b2ab3556a6b4f0f78720f494bdb4cff243c419.zip |
Support/PathV2: Add identify_magic.
llvm-svn: 123548
Diffstat (limited to 'llvm/lib/Support/PathV2.cpp')
-rw-r--r-- | llvm/lib/Support/PathV2.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Support/PathV2.cpp b/llvm/lib/Support/PathV2.cpp index 2e818a5a89d..34638763046 100644 --- a/llvm/lib/Support/PathV2.cpp +++ b/llvm/lib/Support/PathV2.cpp @@ -703,6 +703,16 @@ error_code has_magic(const Twine &path, const Twine &magic, bool &result) { return success; } +error_code identify_magic(const Twine &path, LLVMFileType &result) { + SmallString<32> Magic; + error_code ec = get_magic(path, Magic.capacity(), Magic); + if (ec && ec != errc::value_too_large) + return ec; + + result = IdentifyFileType(Magic.data(), Magic.size()); + return success; +} + namespace { error_code remove_all_r(StringRef path, file_type ft, uint32_t &count) { if (ft == file_type::directory_file) { |