1 //===-- Path.cpp - Implement OS Path Concept --------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This header file implements the operating system Path concept.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Support/Path.h"
15 #include "llvm/Config/config.h"
16 #include "llvm/Support/Endian.h"
17 #include "llvm/Support/FileSystem.h"
18 #include "llvm/Support/PathV1.h"
25 using support::ulittle32_t;
28 //===----------------------------------------------------------------------===//
29 //=== WARNING: Implementation here must contain only TRULY operating system
30 //=== independent code.
31 //===----------------------------------------------------------------------===//
33 bool Path::operator==(const Path &that) const {
34 return path == that.path;
37 bool Path::operator<(const Path& that) const {
38 return path < that.path;
42 Path::isArchive() const {
44 if (fs::identify_magic(str(), type))
46 return type == fs::file_magic::archive;
50 Path::isDynamicLibrary() const {
52 if (fs::identify_magic(str(), type))
55 default: return false;
56 case fs::file_magic::macho_fixed_virtual_memory_shared_lib:
57 case fs::file_magic::macho_dynamically_linked_shared_lib:
58 case fs::file_magic::macho_dynamically_linked_shared_lib_stub:
59 case fs::file_magic::elf_shared_object:
60 case fs::file_magic::pecoff_executable: return true;
65 Path::appendSuffix(StringRef suffix) {
66 if (!suffix.empty()) {
72 // Include the truly platform-specific parts of this class.
73 #if defined(LLVM_ON_UNIX)
74 #include "Unix/Path.inc"
76 #if defined(LLVM_ON_WIN32)
77 #include "Windows/Path.inc"