blob: 3b95665f16ad3a61195edc5d236b80ee43d69906 [file] [log] [blame]
Reid Spencerf634f462004-08-30 21:46:55 +00001//===- Cygwin/Path.cpp - Cygwin 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 Cygwin specific implementation of the Path class.
11//
12//===----------------------------------------------------------------------===//
13
14//===----------------------------------------------------------------------===//
15//=== WARNING: Implementation here must contain only Cygwin 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
22namespace llvm {
23using namespace sys;
24
25bool
Reid Spencer07adb282004-11-05 22:15:36 +000026Path::isValid() const {
Reid Spencerf634f462004-08-30 21:46:55 +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
36Path
37Path::GetTemporaryDirectory() {
Reid Spencer15fd4392004-09-01 20:29:35 +000038 char* pathname = tempnam(0,"llvm_");
39 if (0 == pathname)
40 ThrowErrno(std::string("Can't create temporary directory name"));
Reid Spencerf634f462004-08-30 21:46:55 +000041 Path result;
Reid Spencer07adb282004-11-05 22:15:36 +000042 result.setDirectory(pathname);
Reid Spencer15fd4392004-09-01 20:29:35 +000043 free(pathname);
Reid Spencer07adb282004-11-05 22:15:36 +000044 assert(result.isValid() && "tempnam didn't create a valid pathname!");
Reid Spencer15fd4392004-09-01 20:29:35 +000045 if (0 != mkdir(result.c_str(), S_IRWXU))
46 ThrowErrno(result.get() + ": Can't create temporary directory");
Reid Spencerf634f462004-08-30 21:46:55 +000047 return result;
48}
49
Reid Spencercbad7012004-09-11 04:59:30 +000050std::string
51Path::GetDLLSuffix() {
52 return "dll.a";
53}
54
Reid Spencerf634f462004-08-30 21:46:55 +000055}
56
57// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab