Reid Spencer | b89a223 | 2004-08-25 06:20:07 +0000 | [diff] [blame] | 1 | //===-- Path.cpp - Implement OS Path Concept --------------------*- C++ -*-===// |
Misha Brukman | f976c85 | 2005-04-21 22:55:34 +0000 | [diff] [blame] | 2 | // |
Reid Spencer | b89a223 | 2004-08-25 06:20:07 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Misha Brukman | f976c85 | 2005-04-21 22:55:34 +0000 | [diff] [blame] | 7 | // |
Reid Spencer | b89a223 | 2004-08-25 06:20:07 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This header file implements the operating system Path concept. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
Reid Spencer | 8e66595 | 2004-08-29 05:24:01 +0000 | [diff] [blame] | 13 | |
Reid Spencer | b89a223 | 2004-08-25 06:20:07 +0000 | [diff] [blame] | 14 | #include "llvm/System/Path.h" |
Reid Spencer | 79fc924 | 2004-12-13 18:41:28 +0000 | [diff] [blame] | 15 | #include "llvm/Config/config.h" |
Alkis Evlogimenos | 98bc8ed | 2004-11-14 22:37:42 +0000 | [diff] [blame] | 16 | #include <cassert> |
Duncan Sands | f52e32a | 2008-01-09 19:42:09 +0000 | [diff] [blame] | 17 | #include <cstring> |
Chris Lattner | c67dc45 | 2006-07-07 18:11:32 +0000 | [diff] [blame] | 18 | #include <ostream> |
| 19 | using namespace llvm; |
Reid Spencer | 8e66595 | 2004-08-29 05:24:01 +0000 | [diff] [blame] | 20 | using namespace sys; |
Reid Spencer | b89a223 | 2004-08-25 06:20:07 +0000 | [diff] [blame] | 21 | |
| 22 | //===----------------------------------------------------------------------===// |
| 23 | //=== WARNING: Implementation here must contain only TRULY operating system |
Misha Brukman | f976c85 | 2005-04-21 22:55:34 +0000 | [diff] [blame] | 24 | //=== independent code. |
Reid Spencer | b89a223 | 2004-08-25 06:20:07 +0000 | [diff] [blame] | 25 | //===----------------------------------------------------------------------===// |
| 26 | |
Bill Wendling | 40db5d4 | 2008-05-21 21:20:07 +0000 | [diff] [blame] | 27 | bool Path::operator==(const Path &that) const { |
| 28 | return path == that.path; |
| 29 | } |
| 30 | |
Bill Wendling | 40db5d4 | 2008-05-21 21:20:07 +0000 | [diff] [blame] | 31 | bool Path::operator<(const Path& that) const { |
| 32 | return path < that.path; |
| 33 | } |
| 34 | |
Reid Spencer | c29befb | 2004-12-15 01:50:13 +0000 | [diff] [blame] | 35 | Path |
| 36 | Path::GetLLVMConfigDir() { |
| 37 | Path result; |
Jeff Cohen | ab68df0 | 2004-12-15 04:08:15 +0000 | [diff] [blame] | 38 | #ifdef LLVM_ETCDIR |
Reid Spencer | dd04df0 | 2005-07-07 23:21:43 +0000 | [diff] [blame] | 39 | if (result.set(LLVM_ETCDIR)) |
Reid Spencer | c29befb | 2004-12-15 01:50:13 +0000 | [diff] [blame] | 40 | return result; |
Jeff Cohen | ab68df0 | 2004-12-15 04:08:15 +0000 | [diff] [blame] | 41 | #endif |
Reid Spencer | c29befb | 2004-12-15 01:50:13 +0000 | [diff] [blame] | 42 | return GetLLVMDefaultConfigDir(); |
| 43 | } |
| 44 | |
Misha Brukman | f976c85 | 2005-04-21 22:55:34 +0000 | [diff] [blame] | 45 | LLVMFileType |
Chris Lattner | 6fa6a32 | 2008-07-09 05:14:23 +0000 | [diff] [blame] | 46 | sys::IdentifyFileType(const char *magic, unsigned length) { |
Reid Spencer | f37ce99 | 2004-11-14 22:05:32 +0000 | [diff] [blame] | 47 | assert(magic && "Invalid magic number string"); |
| 48 | assert(length >=4 && "Invalid magic number length"); |
Torok Edwin | 4cdc44c | 2009-04-25 10:25:12 +0000 | [diff] [blame] | 49 | switch ((unsigned char)magic[0]) { |
Chris Lattner | 6fa6a32 | 2008-07-09 05:14:23 +0000 | [diff] [blame] | 50 | case 0xDE: // 0x0B17C0DE = BC wraper |
| 51 | if (magic[1] == (char)0xC0 && magic[2] == (char)0x17 && |
| 52 | magic[3] == (char)0x0B) |
| 53 | return Bitcode_FileType; |
| 54 | break; |
Chris Lattner | f283a5e | 2007-05-06 05:32:21 +0000 | [diff] [blame] | 55 | case 'B': |
| 56 | if (magic[1] == 'C' && magic[2] == (char)0xC0 && magic[3] == (char)0xDE) |
| 57 | return Bitcode_FileType; |
| 58 | break; |
Reid Spencer | 8bb5fd1 | 2007-04-04 06:30:26 +0000 | [diff] [blame] | 59 | case '!': |
| 60 | if (length >= 8) |
| 61 | if (memcmp(magic,"!<arch>\n",8) == 0) |
| 62 | return Archive_FileType; |
| 63 | break; |
Michael J. Spencer | 4a295d3 | 2010-08-31 06:36:46 +0000 | [diff] [blame] | 64 | |
Reid Spencer | 8bb5fd1 | 2007-04-04 06:30:26 +0000 | [diff] [blame] | 65 | case '\177': |
Chris Lattner | 24eac6c | 2007-05-03 18:15:56 +0000 | [diff] [blame] | 66 | if (magic[1] == 'E' && magic[2] == 'L' && magic[3] == 'F') { |
Reid Spencer | 947aa7d | 2007-04-11 02:02:09 +0000 | [diff] [blame] | 67 | if (length >= 18 && magic[17] == 0) |
| 68 | switch (magic[16]) { |
| 69 | default: break; |
| 70 | case 1: return ELF_Relocatable_FileType; |
| 71 | case 2: return ELF_Executable_FileType; |
| 72 | case 3: return ELF_SharedObject_FileType; |
| 73 | case 4: return ELF_Core_FileType; |
| 74 | } |
Chris Lattner | 24eac6c | 2007-05-03 18:15:56 +0000 | [diff] [blame] | 75 | } |
Reid Spencer | f37ce99 | 2004-11-14 22:05:32 +0000 | [diff] [blame] | 76 | break; |
| 77 | |
Chris Lattner | ade7592 | 2007-04-11 03:15:35 +0000 | [diff] [blame] | 78 | case 0xCA: |
Michael J. Spencer | 4a295d3 | 2010-08-31 06:36:46 +0000 | [diff] [blame] | 79 | if (magic[1] == char(0xFE) && magic[2] == char(0xBA) && |
Chris Lattner | ade7592 | 2007-04-11 03:15:35 +0000 | [diff] [blame] | 80 | magic[3] == char(0xBE)) { |
Michael J. Spencer | 4a295d3 | 2010-08-31 06:36:46 +0000 | [diff] [blame] | 81 | // This is complicated by an overlap with Java class files. |
Chris Lattner | 6521549 | 2008-06-26 05:17:18 +0000 | [diff] [blame] | 82 | // See the Mach-O section in /usr/share/file/magic for details. |
Michael J. Spencer | 4a295d3 | 2010-08-31 06:36:46 +0000 | [diff] [blame] | 83 | if (length >= 8 && magic[7] < 43) |
Chris Lattner | 6521549 | 2008-06-26 05:17:18 +0000 | [diff] [blame] | 84 | // FIXME: Universal Binary of any type. |
| 85 | return Mach_O_DynamicallyLinkedSharedLib_FileType; |
| 86 | } |
| 87 | break; |
| 88 | |
| 89 | case 0xFE: |
Bill Wendling | fc1fd54 | 2008-06-26 08:32:05 +0000 | [diff] [blame] | 90 | case 0xCE: { |
| 91 | uint16_t type = 0; |
Michael J. Spencer | 4a295d3 | 2010-08-31 06:36:46 +0000 | [diff] [blame] | 92 | if (magic[0] == char(0xFE) && magic[1] == char(0xED) && |
Chris Lattner | 6521549 | 2008-06-26 05:17:18 +0000 | [diff] [blame] | 93 | magic[2] == char(0xFA) && magic[3] == char(0xCE)) { |
| 94 | /* Native endian */ |
| 95 | if (length >= 16) type = magic[14] << 8 | magic[15]; |
Michael J. Spencer | 4a295d3 | 2010-08-31 06:36:46 +0000 | [diff] [blame] | 96 | } else if (magic[0] == char(0xCE) && magic[1] == char(0xFA) && |
Chris Lattner | 6521549 | 2008-06-26 05:17:18 +0000 | [diff] [blame] | 97 | magic[2] == char(0xED) && magic[3] == char(0xFE)) { |
| 98 | /* Reverse endian */ |
| 99 | if (length >= 14) type = magic[13] << 8 | magic[12]; |
Bill Wendling | fc1fd54 | 2008-06-26 08:32:05 +0000 | [diff] [blame] | 100 | } |
Chris Lattner | 6521549 | 2008-06-26 05:17:18 +0000 | [diff] [blame] | 101 | switch (type) { |
Michael J. Spencer | 4a295d3 | 2010-08-31 06:36:46 +0000 | [diff] [blame] | 102 | default: break; |
| 103 | case 1: return Mach_O_Object_FileType; |
Chris Lattner | 6521549 | 2008-06-26 05:17:18 +0000 | [diff] [blame] | 104 | case 2: return Mach_O_Executable_FileType; |
| 105 | case 3: return Mach_O_FixedVirtualMemorySharedLib_FileType; |
| 106 | case 4: return Mach_O_Core_FileType; |
Peter Collingbourne | b1a33c4 | 2010-11-17 00:43:43 +0000 | [diff] [blame^] | 107 | case 5: return Mach_O_PreloadExecutable_FileType; |
Chris Lattner | 6521549 | 2008-06-26 05:17:18 +0000 | [diff] [blame] | 108 | case 6: return Mach_O_DynamicallyLinkedSharedLib_FileType; |
| 109 | case 7: return Mach_O_DynamicLinker_FileType; |
| 110 | case 8: return Mach_O_Bundle_FileType; |
| 111 | case 9: return Mach_O_DynamicallyLinkedSharedLibStub_FileType; |
| 112 | case 10: break; // FIXME: MH_DSYM companion file with only debug. |
Chris Lattner | ade7592 | 2007-04-11 03:15:35 +0000 | [diff] [blame] | 113 | } |
Reid Spencer | 8bb5fd1 | 2007-04-04 06:30:26 +0000 | [diff] [blame] | 114 | break; |
Bill Wendling | fc1fd54 | 2008-06-26 08:32:05 +0000 | [diff] [blame] | 115 | } |
Reid Spencer | 8bb5fd1 | 2007-04-04 06:30:26 +0000 | [diff] [blame] | 116 | case 0xF0: // PowerPC Windows |
| 117 | case 0x83: // Alpha 32-bit |
| 118 | case 0x84: // Alpha 64-bit |
| 119 | case 0x66: // MPS R4000 Windows |
| 120 | case 0x50: // mc68K |
| 121 | case 0x4c: // 80386 Windows |
| 122 | if (magic[1] == 0x01) |
| 123 | return COFF_FileType; |
| 124 | |
| 125 | case 0x90: // PA-RISC Windows |
| 126 | case 0x68: // mc68K Windows |
| 127 | if (magic[1] == 0x02) |
| 128 | return COFF_FileType; |
Reid Spencer | f37ce99 | 2004-11-14 22:05:32 +0000 | [diff] [blame] | 129 | break; |
Michael J. Spencer | 7e7d01d | 2010-09-15 23:04:14 +0000 | [diff] [blame] | 130 | case 0x64: // x86-64 Windows. |
| 131 | if (magic[1] == char(0x86)) |
| 132 | return COFF_FileType; |
| 133 | break; |
Reid Spencer | f37ce99 | 2004-11-14 22:05:32 +0000 | [diff] [blame] | 134 | |
| 135 | default: |
| 136 | break; |
| 137 | } |
Reid Spencer | 8bb5fd1 | 2007-04-04 06:30:26 +0000 | [diff] [blame] | 138 | return Unknown_FileType; |
Reid Spencer | f37ce99 | 2004-11-14 22:05:32 +0000 | [diff] [blame] | 139 | } |
| 140 | |
Reid Spencer | ccb23a1 | 2004-12-13 03:00:39 +0000 | [diff] [blame] | 141 | bool |
| 142 | Path::isArchive() const { |
Dan Gohman | 130de9c | 2010-05-27 17:12:23 +0000 | [diff] [blame] | 143 | return hasMagicNumber("!<arch>\012"); |
Reid Spencer | ccb23a1 | 2004-12-13 03:00:39 +0000 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | bool |
| 147 | Path::isDynamicLibrary() const { |
Dan Gohman | 130de9c | 2010-05-27 17:12:23 +0000 | [diff] [blame] | 148 | std::string Magic; |
| 149 | if (getMagicNumber(Magic, 64)) |
| 150 | switch (IdentifyFileType(Magic.c_str(), |
| 151 | static_cast<unsigned>(Magic.length()))) { |
| 152 | default: return false; |
| 153 | case Mach_O_FixedVirtualMemorySharedLib_FileType: |
| 154 | case Mach_O_DynamicallyLinkedSharedLib_FileType: |
| 155 | case Mach_O_DynamicallyLinkedSharedLibStub_FileType: |
| 156 | case ELF_SharedObject_FileType: |
| 157 | case COFF_FileType: return true; |
| 158 | } |
| 159 | |
Reid Spencer | ccb23a1 | 2004-12-13 03:00:39 +0000 | [diff] [blame] | 160 | return false; |
| 161 | } |
| 162 | |
Michael J. Spencer | 8a26f81 | 2010-09-15 22:45:45 +0000 | [diff] [blame] | 163 | bool |
| 164 | Path::isObjectFile() const { |
| 165 | std::string Magic; |
| 166 | if (getMagicNumber(Magic, 64)) |
| 167 | if (IdentifyFileType(Magic.c_str(), |
| 168 | static_cast<unsigned>(Magic.length())) |
| 169 | != Unknown_FileType) { |
| 170 | // Everything in LLVMFileType is currently an object file. |
| 171 | return true; |
| 172 | } |
| 173 | |
| 174 | return false; |
| 175 | } |
| 176 | |
Reid Spencer | ccb23a1 | 2004-12-13 03:00:39 +0000 | [diff] [blame] | 177 | Path |
| 178 | Path::FindLibrary(std::string& name) { |
| 179 | std::vector<sys::Path> LibPaths; |
| 180 | GetSystemLibraryPaths(LibPaths); |
| 181 | for (unsigned i = 0; i < LibPaths.size(); ++i) { |
| 182 | sys::Path FullPath(LibPaths[i]); |
Reid Spencer | dd04df0 | 2005-07-07 23:21:43 +0000 | [diff] [blame] | 183 | FullPath.appendComponent("lib" + name + LTDL_SHLIB_EXT); |
Reid Spencer | ccb23a1 | 2004-12-13 03:00:39 +0000 | [diff] [blame] | 184 | if (FullPath.isDynamicLibrary()) |
| 185 | return FullPath; |
Reid Spencer | dd04df0 | 2005-07-07 23:21:43 +0000 | [diff] [blame] | 186 | FullPath.eraseSuffix(); |
Reid Spencer | ccb23a1 | 2004-12-13 03:00:39 +0000 | [diff] [blame] | 187 | FullPath.appendSuffix("a"); |
| 188 | if (FullPath.isArchive()) |
| 189 | return FullPath; |
| 190 | } |
| 191 | return sys::Path(); |
| 192 | } |
| 193 | |
Jeffrey Yasskin | 88cd358 | 2009-12-17 21:02:39 +0000 | [diff] [blame] | 194 | StringRef Path::GetDLLSuffix() { |
Mikhail Glushenkov | c8aef4b | 2010-11-02 20:32:59 +0000 | [diff] [blame] | 195 | return &(LTDL_SHLIB_EXT[1]); |
Reid Spencer | 79fc924 | 2004-12-13 18:41:28 +0000 | [diff] [blame] | 196 | } |
| 197 | |
Chris Lattner | f283a5e | 2007-05-06 05:32:21 +0000 | [diff] [blame] | 198 | bool |
Mikhail Glushenkov | bd6e032 | 2010-11-02 22:18:37 +0000 | [diff] [blame] | 199 | Path::appendSuffix(StringRef suffix) { |
| 200 | if (!suffix.empty()) { |
| 201 | std::string save(path); |
| 202 | path.append("."); |
| 203 | path.append(suffix); |
| 204 | if (!isValid()) { |
| 205 | path = save; |
| 206 | return false; |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | return true; |
| 211 | } |
| 212 | |
| 213 | bool |
Chris Lattner | f283a5e | 2007-05-06 05:32:21 +0000 | [diff] [blame] | 214 | Path::isBitcodeFile() const { |
| 215 | std::string actualMagic; |
| 216 | if (!getMagicNumber(actualMagic, 4)) |
| 217 | return false; |
Devang Patel | 54ce536 | 2008-07-22 18:00:36 +0000 | [diff] [blame] | 218 | LLVMFileType FT = |
| 219 | IdentifyFileType(actualMagic.c_str(), |
| 220 | static_cast<unsigned>(actualMagic.length())); |
| 221 | return FT == Bitcode_FileType; |
Chris Lattner | f283a5e | 2007-05-06 05:32:21 +0000 | [diff] [blame] | 222 | } |
| 223 | |
Jeffrey Yasskin | 88cd358 | 2009-12-17 21:02:39 +0000 | [diff] [blame] | 224 | bool Path::hasMagicNumber(StringRef Magic) const { |
Chris Lattner | f283a5e | 2007-05-06 05:32:21 +0000 | [diff] [blame] | 225 | std::string actualMagic; |
Evan Cheng | 34cd4a4 | 2008-05-05 18:30:58 +0000 | [diff] [blame] | 226 | if (getMagicNumber(actualMagic, static_cast<unsigned>(Magic.size()))) |
Chris Lattner | f283a5e | 2007-05-06 05:32:21 +0000 | [diff] [blame] | 227 | return Magic == actualMagic; |
| 228 | return false; |
| 229 | } |
| 230 | |
Chris Lattner | e1b332a | 2008-02-27 06:17:10 +0000 | [diff] [blame] | 231 | static void getPathList(const char*path, std::vector<Path>& Paths) { |
| 232 | const char* at = path; |
| 233 | const char* delim = strchr(at, PathSeparator); |
| 234 | Path tmpPath; |
| 235 | while (delim != 0) { |
| 236 | std::string tmp(at, size_t(delim-at)); |
| 237 | if (tmpPath.set(tmp)) |
| 238 | if (tmpPath.canRead()) |
| 239 | Paths.push_back(tmpPath); |
| 240 | at = delim + 1; |
| 241 | delim = strchr(at, PathSeparator); |
| 242 | } |
| 243 | |
| 244 | if (*at != 0) |
| 245 | if (tmpPath.set(std::string(at))) |
| 246 | if (tmpPath.canRead()) |
| 247 | Paths.push_back(tmpPath); |
| 248 | } |
| 249 | |
Jeffrey Yasskin | 88cd358 | 2009-12-17 21:02:39 +0000 | [diff] [blame] | 250 | static StringRef getDirnameCharSep(StringRef path, const char *Sep) { |
| 251 | assert(Sep[0] != '\0' && Sep[1] == '\0' && |
| 252 | "Sep must be a 1-character string literal."); |
Ted Kremenek | cf55c8e | 2008-04-07 21:53:57 +0000 | [diff] [blame] | 253 | if (path.empty()) |
| 254 | return "."; |
Michael J. Spencer | 4a295d3 | 2010-08-31 06:36:46 +0000 | [diff] [blame] | 255 | |
Ted Kremenek | cf55c8e | 2008-04-07 21:53:57 +0000 | [diff] [blame] | 256 | // If the path is all slashes, return a single slash. |
| 257 | // Otherwise, remove all trailing slashes. |
Michael J. Spencer | 4a295d3 | 2010-08-31 06:36:46 +0000 | [diff] [blame] | 258 | |
Evan Cheng | 34cd4a4 | 2008-05-05 18:30:58 +0000 | [diff] [blame] | 259 | signed pos = static_cast<signed>(path.size()) - 1; |
Michael J. Spencer | 4a295d3 | 2010-08-31 06:36:46 +0000 | [diff] [blame] | 260 | |
Jeffrey Yasskin | 88cd358 | 2009-12-17 21:02:39 +0000 | [diff] [blame] | 261 | while (pos >= 0 && path[pos] == Sep[0]) |
Ted Kremenek | cf55c8e | 2008-04-07 21:53:57 +0000 | [diff] [blame] | 262 | --pos; |
Michael J. Spencer | 4a295d3 | 2010-08-31 06:36:46 +0000 | [diff] [blame] | 263 | |
Ted Kremenek | cf55c8e | 2008-04-07 21:53:57 +0000 | [diff] [blame] | 264 | if (pos < 0) |
Jeffrey Yasskin | 88cd358 | 2009-12-17 21:02:39 +0000 | [diff] [blame] | 265 | return path[0] == Sep[0] ? Sep : "."; |
Michael J. Spencer | 4a295d3 | 2010-08-31 06:36:46 +0000 | [diff] [blame] | 266 | |
Ted Kremenek | cf55c8e | 2008-04-07 21:53:57 +0000 | [diff] [blame] | 267 | // Any slashes left? |
| 268 | signed i = 0; |
Michael J. Spencer | 4a295d3 | 2010-08-31 06:36:46 +0000 | [diff] [blame] | 269 | |
Jeffrey Yasskin | 88cd358 | 2009-12-17 21:02:39 +0000 | [diff] [blame] | 270 | while (i < pos && path[i] != Sep[0]) |
Ted Kremenek | cf55c8e | 2008-04-07 21:53:57 +0000 | [diff] [blame] | 271 | ++i; |
Michael J. Spencer | 4a295d3 | 2010-08-31 06:36:46 +0000 | [diff] [blame] | 272 | |
Ted Kremenek | cf55c8e | 2008-04-07 21:53:57 +0000 | [diff] [blame] | 273 | if (i == pos) // No slashes? Return "." |
| 274 | return "."; |
Michael J. Spencer | 4a295d3 | 2010-08-31 06:36:46 +0000 | [diff] [blame] | 275 | |
| 276 | // There is at least one slash left. Remove all trailing non-slashes. |
Jeffrey Yasskin | 88cd358 | 2009-12-17 21:02:39 +0000 | [diff] [blame] | 277 | while (pos >= 0 && path[pos] != Sep[0]) |
Ted Kremenek | cf55c8e | 2008-04-07 21:53:57 +0000 | [diff] [blame] | 278 | --pos; |
Michael J. Spencer | 4a295d3 | 2010-08-31 06:36:46 +0000 | [diff] [blame] | 279 | |
Ted Kremenek | cf55c8e | 2008-04-07 21:53:57 +0000 | [diff] [blame] | 280 | // Remove any trailing slashes. |
Jeffrey Yasskin | 88cd358 | 2009-12-17 21:02:39 +0000 | [diff] [blame] | 281 | while (pos >= 0 && path[pos] == Sep[0]) |
Ted Kremenek | cf55c8e | 2008-04-07 21:53:57 +0000 | [diff] [blame] | 282 | --pos; |
Michael J. Spencer | 4a295d3 | 2010-08-31 06:36:46 +0000 | [diff] [blame] | 283 | |
Ted Kremenek | cf55c8e | 2008-04-07 21:53:57 +0000 | [diff] [blame] | 284 | if (pos < 0) |
Jeffrey Yasskin | 88cd358 | 2009-12-17 21:02:39 +0000 | [diff] [blame] | 285 | return path[0] == Sep[0] ? Sep : "."; |
Michael J. Spencer | 4a295d3 | 2010-08-31 06:36:46 +0000 | [diff] [blame] | 286 | |
Ted Kremenek | cf55c8e | 2008-04-07 21:53:57 +0000 | [diff] [blame] | 287 | return path.substr(0, pos+1); |
| 288 | } |
| 289 | |
Reid Spencer | b89a223 | 2004-08-25 06:20:07 +0000 | [diff] [blame] | 290 | // Include the truly platform-specific parts of this class. |
Reid Spencer | dafe55f | 2004-12-24 06:29:17 +0000 | [diff] [blame] | 291 | #if defined(LLVM_ON_UNIX) |
Reid Spencer | bccc8ab | 2005-01-09 23:29:00 +0000 | [diff] [blame] | 292 | #include "Unix/Path.inc" |
Reid Spencer | dafe55f | 2004-12-24 06:29:17 +0000 | [diff] [blame] | 293 | #endif |
| 294 | #if defined(LLVM_ON_WIN32) |
Reid Spencer | bccc8ab | 2005-01-09 23:29:00 +0000 | [diff] [blame] | 295 | #include "Win32/Path.inc" |
Reid Spencer | dafe55f | 2004-12-24 06:29:17 +0000 | [diff] [blame] | 296 | #endif |
Reid Spencer | 23dd332 | 2006-07-26 16:55:39 +0000 | [diff] [blame] | 297 | |