From 5470d5d8d70c0082a127433c03339f9c3cd20ce2 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 29 Apr 2021 13:03:00 +0200 Subject: [PATCH] ProjectExplorer: Allow partial remote ABI detection The "Mac static library" case from 2011 (c9f7d779a6) is still local-only. Change-Id: I5b437722bc1946458f54f3bdaf3e087f9264842a Reviewed-by: Christian Kandeler --- src/plugins/projectexplorer/abi.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/plugins/projectexplorer/abi.cpp b/src/plugins/projectexplorer/abi.cpp index f60d584d564..09639f86a72 100644 --- a/src/plugins/projectexplorer/abi.cpp +++ b/src/plugins/projectexplorer/abi.cpp @@ -1157,20 +1157,19 @@ Abis Abi::abisOfBinary(const Utils::FilePath &path) if (path.isEmpty()) return tmp; - QFile f(path.toString()); - if (!f.exists()) - return tmp; - - if (!f.open(QFile::ReadOnly)) - return tmp; - - QByteArray data = f.read(1024); + QByteArray data = path.fileContents(1024); if (data.size() >= 67 && getUint8(data, 0) == '!' && getUint8(data, 1) == '<' && getUint8(data, 2) == 'a' && getUint8(data, 3) == 'r' && getUint8(data, 4) == 'c' && getUint8(data, 5) == 'h' && getUint8(data, 6) == '>' && getUint8(data, 7) == 0x0a) { // We got an ar file: possibly a static lib for ELF, PE or Mach-O + // FIXME: Implement remote + QTC_ASSERT(!path.needsDevice(), return tmp); + QFile f(path.toString()); + if (!f.open(QFile::ReadOnly)) + return tmp; + data = data.mid(8); // Cut of ar file magic quint64 offset = 8; @@ -1203,7 +1202,6 @@ Abis Abi::abisOfBinary(const Utils::FilePath &path) } else { tmp = abiOf(data); } - f.close(); // Remove duplicates: Abis result;