blob: 5238c1f329b8585cbcca346ec1b942add8a73da6 [file] [log] [blame]
Reid Spencerb89a2232004-08-25 06:20:07 +00001//===- llvm/System/Linux/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 Linux specific implementation of the Path class.
11//
12//===----------------------------------------------------------------------===//
13
14//===----------------------------------------------------------------------===//
15//=== WARNING: Implementation here must contain only Linux specific code
Reid Spencer8e665952004-08-29 05:24:01 +000016//=== and must not be generic UNIX code (see ../Unix/Path.cpp)
Reid Spencerb89a2232004-08-25 06:20:07 +000017//===----------------------------------------------------------------------===//
18
Reid Spencer8e665952004-08-29 05:24:01 +000019// Include the generic Unix implementation
Reid Spencerb89a2232004-08-25 06:20:07 +000020#include "../Unix/Path.cpp"
Reid Spencer8e665952004-08-29 05:24:01 +000021
22namespace llvm {
23using namespace sys;
24
25bool
Reid Spencer07adb282004-11-05 22:15:36 +000026Path::isValid() const {
Reid Spencer8e665952004-08-29 05:24:01 +000027 if (path.empty())
28 return false;
29 char pathname[MAXPATHLEN];
30 if (0 == realpath(path.c_str(), pathname))
31 if (errno != EACCES && errno != EIO && errno != ENOENT && errno != ENOTDIR)
32 return false;
33 return true;
34}
35
Reid Spencerf634f462004-08-30 21:46:55 +000036Path
37Path::GetTemporaryDirectory() {
38 char pathname[MAXPATHLEN];
39 strcpy(pathname,"/tmp/llvm_XXXXXX");
40 if (0 == mkdtemp(pathname))
41 ThrowErrno(std::string(pathname) + ": Can't create temporary directory");
42 Path result;
Reid Spencer07adb282004-11-05 22:15:36 +000043 result.setDirectory(pathname);
44 assert(result.isValid() && "mkdtemp didn't create a valid pathname!");
Reid Spencerf634f462004-08-30 21:46:55 +000045 return result;
46}
47
Reid Spencercbad7012004-09-11 04:59:30 +000048std::string
49Path::GetDLLSuffix() {
50 return "so";
51}
52
Reid Spencer8e665952004-08-29 05:24:01 +000053}
54
55// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab