LLVM API Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Cygwin/Path.cpp

Go to the documentation of this file.
00001 //===- Cygwin/Path.cpp - Cygwin Path Implementation -------------*- C++ -*-===//
00002 // 
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file was developed by Reid Spencer and is distributed under the 
00006 // University of Illinois Open Source License. See LICENSE.TXT for details.
00007 // 
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file provides the Cygwin specific implementation of the Path class.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 //===----------------------------------------------------------------------===//
00015 //=== WARNING: Implementation here must contain only Cygwin specific code 
00016 //===          and must not be generic UNIX code (see ../Unix/Path.cpp)
00017 //===----------------------------------------------------------------------===//
00018 
00019 // Include the generic Unix implementation
00020 #include "../Unix/Path.cpp"
00021 
00022 namespace llvm {
00023 using namespace sys;
00024 
00025 bool 
00026 Path::isValid() const {
00027   if (path.empty()) 
00028     return false;
00029   char pathname[MAXPATHLEN];
00030   if (0 == realpath(path.c_str(), pathname))
00031     if (errno != EACCES && errno != EIO && errno != ENOENT && errno != ENOTDIR)
00032       return false;
00033   return true;
00034 }
00035 
00036 Path
00037 Path::GetTemporaryDirectory() {
00038   char* pathname = tempnam(0,"llvm_");
00039   if (0 == pathname)
00040     ThrowErrno(std::string("Can't create temporary directory name"));
00041   Path result;
00042   result.setDirectory(pathname);
00043   free(pathname);
00044   assert(result.isValid() && "tempnam didn't create a valid pathname!");
00045   if (0 != mkdir(result.c_str(), S_IRWXU))
00046     ThrowErrno(result.get() + ": Can't create temporary directory");
00047   return result;
00048 }
00049 
00050 std::string
00051 Path::GetDLLSuffix() {
00052   return "dll.a";
00053 }
00054 
00055 }
00056 
00057 // vim: sw=2 smartindent smarttab tw=80 autoindent expandtab