Reid Spencer | 8e66595 | 2004-08-29 05:24:01 +0000 | [diff] [blame] | 1 | //===- llvm/System/Darwin/Path.cpp - Linux Path Implementation --*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by Reid Spencer and is distributed under the |
| 6 | // University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file provides the Darwin specific implementation of the Path class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | //=== WARNING: Implementation here must contain only Darwin specific code |
| 16 | //=== and must not be generic UNIX code (see ../Unix/Path.cpp) |
| 17 | //===----------------------------------------------------------------------===// |
| 18 | |
| 19 | // Include the generic unix implementation |
| 20 | #include "../Unix/Path.cpp" |
| 21 | |
| 22 | namespace llvm { |
| 23 | using namespace sys; |
| 24 | |
| 25 | bool |
| 26 | Path::is_valid() const { |
| 27 | if (path.empty()) |
| 28 | return false; |
| 29 | if (path.length() >= MAXPATHLEN) |
| 30 | return false; |
| 31 | return true; |
| 32 | } |
| 33 | |
Reid Spencer | f634f46 | 2004-08-30 21:46:55 +0000 | [diff] [blame] | 34 | Path |
| 35 | Path::GetTemporaryDirectory() { |
| 36 | char pathname[MAXPATHLEN]; |
| 37 | strcpy(pathname,"/tmp/llvm_XXXXXX"); |
| 38 | if (0 == mkdtemp(pathname)) |
| 39 | ThrowErrno(std::string(pathname) + ": Can't create temporary directory"); |
| 40 | Path result; |
| 41 | result.set_directory(pathname); |
| 42 | assert(result.is_valid() && "mkdtemp didn't create a valid pathname!"); |
| 43 | return result; |
| 44 | } |
| 45 | |
Reid Spencer | cbad701 | 2004-09-11 04:59:30 +0000 | [diff] [blame] | 46 | std::string |
| 47 | Path::GetDLLSuffix() { |
Reid Spencer | f51c8ea | 2004-09-11 07:35:01 +0000 | [diff] [blame^] | 48 | return "dylib"; |
Reid Spencer | cbad701 | 2004-09-11 04:59:30 +0000 | [diff] [blame] | 49 | } |
| 50 | |
Reid Spencer | 8e66595 | 2004-08-29 05:24:01 +0000 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | // vim: sw=2 smartindent smarttab tw=80 autoindent expandtab |