#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
#include <cctype>
-#include <cstdio>
#include <cstring>
-#include <fcntl.h>
#if !defined(_MSC_VER) && !defined(__MINGW32__)
#include <unistd.h>
#endif
using namespace llvm;
+using namespace llvm::support::endian;
namespace {
using llvm::StringRef;
// * empty (in this case we return an empty string)
// * either C: or {//,\\}net.
// * {/,\}
- // * {.,..}
// * {file,directory}name
if (path.empty())
if (is_separator(path[0]))
return path.substr(0, 1);
- if (path.startswith(".."))
- return path.substr(0, 2);
-
- if (path[0] == '.')
- return path.substr(0, 1);
-
// * {file,directory}name
size_t end = path.find_first_of(separators);
return path.substr(0, end);
if (Magic.size() < MinSize)
return file_magic::coff_import_library;
- int BigObjVersion = *reinterpret_cast<const support::ulittle16_t*>(
+ int BigObjVersion = read16le(
Magic.data() + offsetof(COFF::BigObjHeader, Version));
if (BigObjVersion < COFF::BigObjHeader::MinBigObjectVersion)
return file_magic::coff_import_library;
case 8: return file_magic::macho_bundle;
case 9: return file_magic::macho_dynamically_linked_shared_lib_stub;
case 10: return file_magic::macho_dsym_companion;
+ case 11: return file_magic::macho_kext_bundle;
}
break;
}
case 'M': // Possible MS-DOS stub on Windows PE file
if (Magic[1] == 'Z') {
- uint32_t off =
- *reinterpret_cast<const support::ulittle32_t*>(Magic.data() + 0x3c);
+ uint32_t off = read32le(Magic.data() + 0x3c);
// PE/COFF file, either EXE or DLL.
if (off < Magic.size() &&
memcmp(Magic.data()+off, COFF::PEMagic, sizeof(COFF::PEMagic)) == 0)