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 | 28f0ed5c9de4a68f34c0219d4ab83652c4647150 (patch) | |
tree | 999622dc7275347a61e4a674455c7beaf7ded075 /lib/Support/PathV2.cpp | |
parent | b6516aeef12a05aa47515f76e18fc426d85babbd (diff) |
Support/PathV2: Add identify_magic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123548 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/PathV2.cpp')
-rw-r--r-- | lib/Support/PathV2.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Support/PathV2.cpp b/lib/Support/PathV2.cpp index 2e818a5a89..3463876304 100644 --- a/lib/Support/PathV2.cpp +++ b/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) { |