Reid Spencer | 8e66595 | 2004-08-29 05:24:01 +0000 | [diff] [blame] | 1 | //===- llvm/System/AIX/Path.cpp - AIX 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 | // |
Misha Brukman | 9c02f5c | 2004-10-18 17:39:45 +0000 | [diff] [blame] | 10 | // This file provides the AIX-specific implementation of the Path class. |
Reid Spencer | 8e66595 | 2004-08-29 05:24:01 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Reid Spencer | 8e66595 | 2004-08-29 05:24:01 +0000 | [diff] [blame] | 14 | // Include the generic unix implementation |
| 15 | #include "../Unix/Path.cpp" |
Misha Brukman | 9c02f5c | 2004-10-18 17:39:45 +0000 | [diff] [blame] | 16 | #include <sys/stat.h> |
Reid Spencer | 8e66595 | 2004-08-29 05:24:01 +0000 | [diff] [blame] | 17 | |
| 18 | namespace llvm { |
| 19 | using namespace sys; |
| 20 | |
Reid Spencer | bd4dd5c | 2004-08-29 19:25:54 +0000 | [diff] [blame] | 21 | //===----------------------------------------------------------------------===// |
| 22 | //=== WARNING: Implementation here must contain only AIX specific code |
| 23 | //=== and must not be generic UNIX code (see ../Unix/Path.cpp) |
| 24 | //===----------------------------------------------------------------------===// |
| 25 | |
Reid Spencer | 8e66595 | 2004-08-29 05:24:01 +0000 | [diff] [blame] | 26 | bool |
| 27 | Path::is_valid() const { |
| 28 | if (path.empty()) |
| 29 | return false; |
| 30 | if (path.length() >= MAXPATHLEN) |
| 31 | return false; |
| 32 | return true; |
| 33 | } |
| 34 | |
Reid Spencer | f634f46 | 2004-08-30 21:46:55 +0000 | [diff] [blame] | 35 | Path |
| 36 | Path::GetTemporaryDirectory() { |
| 37 | char pathname[MAXPATHLEN]; |
Misha Brukman | 9c02f5c | 2004-10-18 17:39:45 +0000 | [diff] [blame] | 38 | strcpy(pathname, "/tmp/llvm_XXXXXX"); |
| 39 | // AIX does not have a mkdtemp(), so we emulate it as follows: |
| 40 | // mktemp() returns a valid name for a _file_, not a directory, but does not |
| 41 | // create it. We assume that it is a valid name for a directory. |
| 42 | char *TmpName = mktemp(pathname); |
| 43 | if (!mkdir(TmpName, S_IRWXU)) |
| 44 | ThrowErrno(std::string(TmpName) + ": Can't create temporary directory"); |
Reid Spencer | f634f46 | 2004-08-30 21:46:55 +0000 | [diff] [blame] | 45 | Path result; |
Misha Brukman | 9c02f5c | 2004-10-18 17:39:45 +0000 | [diff] [blame] | 46 | result.set_directory(TmpName); |
Reid Spencer | f634f46 | 2004-08-30 21:46:55 +0000 | [diff] [blame] | 47 | assert(result.is_valid() && "mkdtemp didn't create a valid pathname!"); |
| 48 | return result; |
| 49 | } |
| 50 | |
Reid Spencer | cbad701 | 2004-09-11 04:59:30 +0000 | [diff] [blame] | 51 | std::string |
| 52 | Path::GetDLLSuffix() { |
| 53 | return "so"; |
| 54 | } |
| 55 | |
Reid Spencer | 8e66595 | 2004-08-29 05:24:01 +0000 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | // vim: sw=2 smartindent smarttab tw=80 autoindent expandtab |