LLVM API Documentation

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

AIX/Path.cpp

Go to the documentation of this file.
00001 //===- llvm/System/AIX/Path.cpp - AIX 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 AIX-specific implementation of the Path class.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 // Include the generic unix implementation
00015 #include "../Unix/Path.cpp"
00016 #include <sys/stat.h>
00017 
00018 namespace llvm {
00019 using namespace sys;
00020 
00021 //===----------------------------------------------------------------------===//
00022 //=== WARNING: Implementation here must contain only AIX specific code 
00023 //===          and must not be generic UNIX code (see ../Unix/Path.cpp)
00024 //===----------------------------------------------------------------------===//
00025 
00026 bool 
00027 Path::isValid() const {
00028   if (path.empty()) 
00029     return false;
00030   if (path.length() >= MAXPATHLEN)
00031     return false;
00032   return true;
00033 }
00034 
00035 Path
00036 Path::GetTemporaryDirectory() {
00037   char pathname[MAXPATHLEN];
00038   strcpy(pathname, "/tmp/llvm_XXXXXX");
00039   // AIX does not have a mkdtemp(), so we emulate it as follows:
00040   // mktemp() returns a valid name for a _file_, not a directory, but does not
00041   // create it.  We assume that it is a valid name for a directory.
00042   char *TmpName = mktemp(pathname);
00043   if (!mkdir(TmpName, S_IRWXU))
00044     ThrowErrno(std::string(TmpName) + ": Can't create temporary directory");
00045   Path result;
00046   result.setDirectory(TmpName);
00047   assert(result.isValid() && "mkdtemp didn't create a valid pathname!");
00048   return result;
00049 }
00050 
00051 std::string
00052 Path::GetDLLSuffix() {
00053   return "so";
00054 }
00055 
00056 }
00057 
00058 // vim: sw=2 smartindent smarttab tw=80 autoindent expandtab