summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/PathV2.cpp
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2011-01-15 20:39:36 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2011-01-15 20:39:36 +0000
commit94b2ab3556a6b4f0f78720f494bdb4cff243c419 (patch)
tree082fa028191516fa1a8154daa6afaa4a8758f589 /llvm/lib/Support/PathV2.cpp
parentfff2517edcec21184fb86d3b48bed11885032587 (diff)
downloadbcm5719-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.cpp10
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) {
OpenPOWER on IntegriCloud