LLVM API Documentation

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

Interix/Path.cpp

Go to the documentation of this file.
00001 //===- Interix/Path.cpp - Interix 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 Interix specific implementation of the Path class.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 //===----------------------------------------------------------------------===//
00015 //=== WARNING: Implementation here must contain only Interix 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[MAXPATHLEN];
00039   strcpy(pathname,"/tmp/llvm_XXXXXX");
00040   if (0 == mkdtemp(pathname))
00041     ThrowErrno(std::string(pathname) + ": Can't create temporary directory");
00042   Path result;
00043   result.setDirectory(pathname);
00044   assert(result.isValid() && "mkdtemp didn't create a valid pathname!");
00045   return result;
00046 }
00047 
00048 std::string
00049 Path::GetDLLSuffix() {
00050   return "dll";
00051 }
00052 
00053 }
00054 
00055 // vim: sw=2 smartindent smarttab tw=80 autoindent expandtab