LLVM  mainline
Path.inc
Go to the documentation of this file.
00001 //===- llvm/Support/Unix/Path.inc - Unix Path Implementation ----*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file implements the Unix specific implementation of the Path API.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 //===----------------------------------------------------------------------===//
00015 //=== WARNING: Implementation here must contain only generic UNIX code that
00016 //===          is guaranteed to work on *all* UNIX variants.
00017 //===----------------------------------------------------------------------===//
00018 
00019 #include "Unix.h"
00020 #include <limits.h>
00021 #include <stdio.h>
00022 #if HAVE_SYS_STAT_H
00023 #include <sys/stat.h>
00024 #endif
00025 #if HAVE_FCNTL_H
00026 #include <fcntl.h>
00027 #endif
00028 #ifdef HAVE_SYS_MMAN_H
00029 #include <sys/mman.h>
00030 #endif
00031 #if HAVE_DIRENT_H
00032 # include <dirent.h>
00033 # define NAMLEN(dirent) strlen((dirent)->d_name)
00034 #else
00035 # define dirent direct
00036 # define NAMLEN(dirent) (dirent)->d_namlen
00037 # if HAVE_SYS_NDIR_H
00038 #  include <sys/ndir.h>
00039 # endif
00040 # if HAVE_SYS_DIR_H
00041 #  include <sys/dir.h>
00042 # endif
00043 # if HAVE_NDIR_H
00044 #  include <ndir.h>
00045 # endif
00046 #endif
00047 
00048 #ifdef __APPLE__
00049 #include <mach-o/dyld.h>
00050 #endif
00051 
00052 // Both stdio.h and cstdio are included via different pathes and
00053 // stdcxx's cstdio doesn't include stdio.h, so it doesn't #undef the macros
00054 // either.
00055 #undef ferror
00056 #undef feof
00057 
00058 // For GNU Hurd
00059 #if defined(__GNU__) && !defined(PATH_MAX)
00060 # define PATH_MAX 4096
00061 #endif
00062 
00063 using namespace llvm;
00064 
00065 namespace llvm {
00066 namespace sys  {
00067 namespace fs {
00068 #if defined(__FreeBSD__) || defined (__NetBSD__) || defined(__Bitrig__) || \
00069     defined(__OpenBSD__) || defined(__minix) || defined(__FreeBSD_kernel__) || \
00070     defined(__linux__) || defined(__CYGWIN__) || defined(__DragonFly__)
00071 static int
00072 test_dir(char ret[PATH_MAX], const char *dir, const char *bin)
00073 {  
00074   struct stat sb;
00075   char fullpath[PATH_MAX];
00076 
00077   snprintf(fullpath, PATH_MAX, "%s/%s", dir, bin);
00078   if (!realpath(fullpath, ret))
00079     return 1;
00080   if (stat(fullpath, &sb) != 0)
00081     return 1;
00082 
00083   return 0;
00084 }
00085 
00086 static char *
00087 getprogpath(char ret[PATH_MAX], const char *bin)
00088 {
00089   char *pv, *s, *t;
00090 
00091   /* First approach: absolute path. */
00092   if (bin[0] == '/') {
00093     if (test_dir(ret, "/", bin) == 0)
00094       return ret;
00095     return nullptr;
00096   }
00097 
00098   /* Second approach: relative path. */
00099   if (strchr(bin, '/')) {
00100     char cwd[PATH_MAX];
00101     if (!getcwd(cwd, PATH_MAX))
00102       return nullptr;
00103     if (test_dir(ret, cwd, bin) == 0)
00104       return ret;
00105     return nullptr;
00106   }
00107 
00108   /* Third approach: $PATH */
00109   if ((pv = getenv("PATH")) == nullptr)
00110     return nullptr;
00111   s = pv = strdup(pv);
00112   if (!pv)
00113     return nullptr;
00114   while ((t = strsep(&s, ":")) != nullptr) {
00115     if (test_dir(ret, t, bin) == 0) {
00116       free(pv);
00117       return ret;
00118     }
00119   }
00120   free(pv);
00121   return nullptr;
00122 }
00123 #endif // __FreeBSD__ || __NetBSD__ || __FreeBSD_kernel__
00124 
00125 /// GetMainExecutable - Return the path to the main executable, given the
00126 /// value of argv[0] from program startup.
00127 std::string getMainExecutable(const char *argv0, void *MainAddr) {
00128 #if defined(__APPLE__)
00129   // On OS X the executable path is saved to the stack by dyld. Reading it
00130   // from there is much faster than calling dladdr, especially for large
00131   // binaries with symbols.
00132   char exe_path[MAXPATHLEN];
00133   uint32_t size = sizeof(exe_path);
00134   if (_NSGetExecutablePath(exe_path, &size) == 0) {
00135     char link_path[MAXPATHLEN];
00136     if (realpath(exe_path, link_path))
00137       return link_path;
00138   }
00139 #elif defined(__FreeBSD__) || defined (__NetBSD__) || defined(__Bitrig__) || \
00140       defined(__OpenBSD__) || defined(__minix) || defined(__DragonFly__) || \
00141       defined(__FreeBSD_kernel__)
00142   char exe_path[PATH_MAX];
00143 
00144   if (getprogpath(exe_path, argv0) != NULL)
00145     return exe_path;
00146 #elif defined(__linux__) || defined(__CYGWIN__)
00147   char exe_path[MAXPATHLEN];
00148   StringRef aPath("/proc/self/exe");
00149   if (sys::fs::exists(aPath)) {
00150       // /proc is not always mounted under Linux (chroot for example).
00151       ssize_t len = readlink(aPath.str().c_str(), exe_path, sizeof(exe_path));
00152       if (len >= 0)
00153           return std::string(exe_path, len);
00154   } else {
00155       // Fall back to the classical detection.
00156       if (getprogpath(exe_path, argv0))
00157         return exe_path;
00158   }
00159 #elif defined(HAVE_DLFCN_H)
00160   // Use dladdr to get executable path if available.
00161   Dl_info DLInfo;
00162   int err = dladdr(MainAddr, &DLInfo);
00163   if (err == 0)
00164     return "";
00165 
00166   // If the filename is a symlink, we need to resolve and return the location of
00167   // the actual executable.
00168   char link_path[MAXPATHLEN];
00169   if (realpath(DLInfo.dli_fname, link_path))
00170     return link_path;
00171 #else
00172 #error GetMainExecutable is not implemented on this host yet.
00173 #endif
00174   return "";
00175 }
00176 
00177 TimeValue file_status::getLastModificationTime() const {
00178   TimeValue Ret;
00179   Ret.fromEpochTime(fs_st_mtime);
00180   return Ret;
00181 }
00182 
00183 UniqueID file_status::getUniqueID() const {
00184   return UniqueID(fs_st_dev, fs_st_ino);
00185 }
00186 
00187 std::error_code current_path(SmallVectorImpl<char> &result) {
00188   result.clear();
00189 
00190   const char *pwd = ::getenv("PWD");
00191   llvm::sys::fs::file_status PWDStatus, DotStatus;
00192   if (pwd && llvm::sys::path::is_absolute(pwd) &&
00193       !llvm::sys::fs::status(pwd, PWDStatus) &&
00194       !llvm::sys::fs::status(".", DotStatus) &&
00195       PWDStatus.getUniqueID() == DotStatus.getUniqueID()) {
00196     result.append(pwd, pwd + strlen(pwd));
00197     return std::error_code();
00198   }
00199 
00200 #ifdef MAXPATHLEN
00201   result.reserve(MAXPATHLEN);
00202 #else
00203 // For GNU Hurd
00204   result.reserve(1024);
00205 #endif
00206 
00207   while (true) {
00208     if (::getcwd(result.data(), result.capacity()) == nullptr) {
00209       // See if there was a real error.
00210       if (errno != ENOMEM)
00211         return std::error_code(errno, std::generic_category());
00212       // Otherwise there just wasn't enough space.
00213       result.reserve(result.capacity() * 2);
00214     } else
00215       break;
00216   }
00217 
00218   result.set_size(strlen(result.data()));
00219   return std::error_code();
00220 }
00221 
00222 std::error_code create_directory(const Twine &path, bool IgnoreExisting,
00223                                  perms Perms) {
00224   SmallString<128> path_storage;
00225   StringRef p = path.toNullTerminatedStringRef(path_storage);
00226 
00227   if (::mkdir(p.begin(), Perms) == -1) {
00228     if (errno != EEXIST || !IgnoreExisting)
00229       return std::error_code(errno, std::generic_category());
00230   }
00231 
00232   return std::error_code();
00233 }
00234 
00235 // Note that we are using symbolic link because hard links are not supported by
00236 // all filesystems (SMB doesn't).
00237 std::error_code create_link(const Twine &to, const Twine &from) {
00238   // Get arguments.
00239   SmallString<128> from_storage;
00240   SmallString<128> to_storage;
00241   StringRef f = from.toNullTerminatedStringRef(from_storage);
00242   StringRef t = to.toNullTerminatedStringRef(to_storage);
00243 
00244   if (::symlink(t.begin(), f.begin()) == -1)
00245     return std::error_code(errno, std::generic_category());
00246 
00247   return std::error_code();
00248 }
00249 
00250 std::error_code remove(const Twine &path, bool IgnoreNonExisting) {
00251   SmallString<128> path_storage;
00252   StringRef p = path.toNullTerminatedStringRef(path_storage);
00253 
00254   struct stat buf;
00255   if (lstat(p.begin(), &buf) != 0) {
00256     if (errno != ENOENT || !IgnoreNonExisting)
00257       return std::error_code(errno, std::generic_category());
00258     return std::error_code();
00259   }
00260 
00261   // Note: this check catches strange situations. In all cases, LLVM should
00262   // only be involved in the creation and deletion of regular files.  This
00263   // check ensures that what we're trying to erase is a regular file. It
00264   // effectively prevents LLVM from erasing things like /dev/null, any block
00265   // special file, or other things that aren't "regular" files.
00266   if (!S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode) && !S_ISLNK(buf.st_mode))
00267     return make_error_code(errc::operation_not_permitted);
00268 
00269   if (::remove(p.begin()) == -1) {
00270     if (errno != ENOENT || !IgnoreNonExisting)
00271       return std::error_code(errno, std::generic_category());
00272   }
00273 
00274   return std::error_code();
00275 }
00276 
00277 std::error_code rename(const Twine &from, const Twine &to) {
00278   // Get arguments.
00279   SmallString<128> from_storage;
00280   SmallString<128> to_storage;
00281   StringRef f = from.toNullTerminatedStringRef(from_storage);
00282   StringRef t = to.toNullTerminatedStringRef(to_storage);
00283 
00284   if (::rename(f.begin(), t.begin()) == -1)
00285     return std::error_code(errno, std::generic_category());
00286 
00287   return std::error_code();
00288 }
00289 
00290 std::error_code resize_file(int FD, uint64_t Size) {
00291   if (::ftruncate(FD, Size) == -1)
00292     return std::error_code(errno, std::generic_category());
00293 
00294   return std::error_code();
00295 }
00296 
00297 static int convertAccessMode(AccessMode Mode) {
00298   switch (Mode) {
00299   case AccessMode::Exist:
00300     return F_OK;
00301   case AccessMode::Write:
00302     return W_OK;
00303   case AccessMode::Execute:
00304     return R_OK | X_OK; // scripts also need R_OK.
00305   }
00306   llvm_unreachable("invalid enum");
00307 }
00308 
00309 std::error_code access(const Twine &Path, AccessMode Mode) {
00310   SmallString<128> PathStorage;
00311   StringRef P = Path.toNullTerminatedStringRef(PathStorage);
00312 
00313   if (::access(P.begin(), convertAccessMode(Mode)) == -1)
00314     return std::error_code(errno, std::generic_category());
00315 
00316   if (Mode == AccessMode::Execute) {
00317     // Don't say that directories are executable.
00318     struct stat buf;
00319     if (0 != stat(P.begin(), &buf))
00320       return errc::permission_denied;
00321     if (!S_ISREG(buf.st_mode))
00322       return errc::permission_denied;
00323   }
00324 
00325   return std::error_code();
00326 }
00327 
00328 bool can_execute(const Twine &Path) {
00329   return !access(Path, AccessMode::Execute);
00330 }
00331 
00332 bool equivalent(file_status A, file_status B) {
00333   assert(status_known(A) && status_known(B));
00334   return A.fs_st_dev == B.fs_st_dev &&
00335          A.fs_st_ino == B.fs_st_ino;
00336 }
00337 
00338 std::error_code equivalent(const Twine &A, const Twine &B, bool &result) {
00339   file_status fsA, fsB;
00340   if (std::error_code ec = status(A, fsA))
00341     return ec;
00342   if (std::error_code ec = status(B, fsB))
00343     return ec;
00344   result = equivalent(fsA, fsB);
00345   return std::error_code();
00346 }
00347 
00348 static std::error_code fillStatus(int StatRet, const struct stat &Status,
00349                              file_status &Result) {
00350   if (StatRet != 0) {
00351     std::error_code ec(errno, std::generic_category());
00352     if (ec == errc::no_such_file_or_directory)
00353       Result = file_status(file_type::file_not_found);
00354     else
00355       Result = file_status(file_type::status_error);
00356     return ec;
00357   }
00358 
00359   file_type Type = file_type::type_unknown;
00360 
00361   if (S_ISDIR(Status.st_mode))
00362     Type = file_type::directory_file;
00363   else if (S_ISREG(Status.st_mode))
00364     Type = file_type::regular_file;
00365   else if (S_ISBLK(Status.st_mode))
00366     Type = file_type::block_file;
00367   else if (S_ISCHR(Status.st_mode))
00368     Type = file_type::character_file;
00369   else if (S_ISFIFO(Status.st_mode))
00370     Type = file_type::fifo_file;
00371   else if (S_ISSOCK(Status.st_mode))
00372     Type = file_type::socket_file;
00373 
00374   perms Perms = static_cast<perms>(Status.st_mode);
00375   Result =
00376       file_status(Type, Perms, Status.st_dev, Status.st_ino, Status.st_mtime,
00377                   Status.st_uid, Status.st_gid, Status.st_size);
00378 
00379   return std::error_code();
00380 }
00381 
00382 std::error_code status(const Twine &Path, file_status &Result) {
00383   SmallString<128> PathStorage;
00384   StringRef P = Path.toNullTerminatedStringRef(PathStorage);
00385 
00386   struct stat Status;
00387   int StatRet = ::stat(P.begin(), &Status);
00388   return fillStatus(StatRet, Status, Result);
00389 }
00390 
00391 std::error_code status(int FD, file_status &Result) {
00392   struct stat Status;
00393   int StatRet = ::fstat(FD, &Status);
00394   return fillStatus(StatRet, Status, Result);
00395 }
00396 
00397 std::error_code setLastModificationAndAccessTime(int FD, TimeValue Time) {
00398 #if defined(HAVE_FUTIMENS)
00399   timespec Times[2];
00400   Times[0].tv_sec = Time.toEpochTime();
00401   Times[0].tv_nsec = 0;
00402   Times[1] = Times[0];
00403   if (::futimens(FD, Times))
00404     return std::error_code(errno, std::generic_category());
00405   return std::error_code();
00406 #elif defined(HAVE_FUTIMES)
00407   timeval Times[2];
00408   Times[0].tv_sec = Time.toEpochTime();
00409   Times[0].tv_usec = 0;
00410   Times[1] = Times[0];
00411   if (::futimes(FD, Times))
00412     return std::error_code(errno, std::generic_category());
00413   return std::error_code();
00414 #else
00415 #warning Missing futimes() and futimens()
00416   return make_error_code(errc::function_not_supported);
00417 #endif
00418 }
00419 
00420 std::error_code mapped_file_region::init(int FD, uint64_t Offset,
00421                                          mapmode Mode) {
00422   assert(Size != 0);
00423 
00424   int flags = (Mode == readwrite) ? MAP_SHARED : MAP_PRIVATE;
00425   int prot = (Mode == readonly) ? PROT_READ : (PROT_READ | PROT_WRITE);
00426   Mapping = ::mmap(nullptr, Size, prot, flags, FD, Offset);
00427   if (Mapping == MAP_FAILED)
00428     return std::error_code(errno, std::generic_category());
00429   return std::error_code();
00430 }
00431 
00432 mapped_file_region::mapped_file_region(int fd, mapmode mode, uint64_t length,
00433                                        uint64_t offset, std::error_code &ec)
00434     : Size(length), Mapping() {
00435   // Make sure that the requested size fits within SIZE_T.
00436   if (length > std::numeric_limits<size_t>::max()) {
00437     ec = make_error_code(errc::invalid_argument);
00438     return;
00439   }
00440 
00441   ec = init(fd, offset, mode);
00442   if (ec)
00443     Mapping = nullptr;
00444 }
00445 
00446 mapped_file_region::~mapped_file_region() {
00447   if (Mapping)
00448     ::munmap(Mapping, Size);
00449 }
00450 
00451 uint64_t mapped_file_region::size() const {
00452   assert(Mapping && "Mapping failed but used anyway!");
00453   return Size;
00454 }
00455 
00456 char *mapped_file_region::data() const {
00457   assert(Mapping && "Mapping failed but used anyway!");
00458   return reinterpret_cast<char*>(Mapping);
00459 }
00460 
00461 const char *mapped_file_region::const_data() const {
00462   assert(Mapping && "Mapping failed but used anyway!");
00463   return reinterpret_cast<const char*>(Mapping);
00464 }
00465 
00466 int mapped_file_region::alignment() {
00467   return Process::getPageSize();
00468 }
00469 
00470 std::error_code detail::directory_iterator_construct(detail::DirIterState &it,
00471                                                 StringRef path){
00472   SmallString<128> path_null(path);
00473   DIR *directory = ::opendir(path_null.c_str());
00474   if (!directory)
00475     return std::error_code(errno, std::generic_category());
00476 
00477   it.IterationHandle = reinterpret_cast<intptr_t>(directory);
00478   // Add something for replace_filename to replace.
00479   path::append(path_null, ".");
00480   it.CurrentEntry = directory_entry(path_null.str());
00481   return directory_iterator_increment(it);
00482 }
00483 
00484 std::error_code detail::directory_iterator_destruct(detail::DirIterState &it) {
00485   if (it.IterationHandle)
00486     ::closedir(reinterpret_cast<DIR *>(it.IterationHandle));
00487   it.IterationHandle = 0;
00488   it.CurrentEntry = directory_entry();
00489   return std::error_code();
00490 }
00491 
00492 std::error_code detail::directory_iterator_increment(detail::DirIterState &it) {
00493   errno = 0;
00494   dirent *cur_dir = ::readdir(reinterpret_cast<DIR *>(it.IterationHandle));
00495   if (cur_dir == nullptr && errno != 0) {
00496     return std::error_code(errno, std::generic_category());
00497   } else if (cur_dir != nullptr) {
00498     StringRef name(cur_dir->d_name, NAMLEN(cur_dir));
00499     if ((name.size() == 1 && name[0] == '.') ||
00500         (name.size() == 2 && name[0] == '.' && name[1] == '.'))
00501       return directory_iterator_increment(it);
00502     it.CurrentEntry.replace_filename(name);
00503   } else
00504     return directory_iterator_destruct(it);
00505 
00506   return std::error_code();
00507 }
00508 
00509 std::error_code openFileForRead(const Twine &Name, int &ResultFD) {
00510   SmallString<128> Storage;
00511   StringRef P = Name.toNullTerminatedStringRef(Storage);
00512   while ((ResultFD = open(P.begin(), O_RDONLY)) < 0) {
00513     if (errno != EINTR)
00514       return std::error_code(errno, std::generic_category());
00515   }
00516   return std::error_code();
00517 }
00518 
00519 std::error_code openFileForWrite(const Twine &Name, int &ResultFD,
00520                             sys::fs::OpenFlags Flags, unsigned Mode) {
00521   // Verify that we don't have both "append" and "excl".
00522   assert((!(Flags & sys::fs::F_Excl) || !(Flags & sys::fs::F_Append)) &&
00523          "Cannot specify both 'excl' and 'append' file creation flags!");
00524 
00525   int OpenFlags = O_CREAT;
00526 
00527   if (Flags & F_RW)
00528     OpenFlags |= O_RDWR;
00529   else
00530     OpenFlags |= O_WRONLY;
00531 
00532   if (Flags & F_Append)
00533     OpenFlags |= O_APPEND;
00534   else
00535     OpenFlags |= O_TRUNC;
00536 
00537   if (Flags & F_Excl)
00538     OpenFlags |= O_EXCL;
00539 
00540   SmallString<128> Storage;
00541   StringRef P = Name.toNullTerminatedStringRef(Storage);
00542   while ((ResultFD = open(P.begin(), OpenFlags, Mode)) < 0) {
00543     if (errno != EINTR)
00544       return std::error_code(errno, std::generic_category());
00545   }
00546   return std::error_code();
00547 }
00548 
00549 } // end namespace fs
00550 
00551 namespace path {
00552 
00553 bool home_directory(SmallVectorImpl<char> &result) {
00554   if (char *RequestedDir = getenv("HOME")) {
00555     result.clear();
00556     result.append(RequestedDir, RequestedDir + strlen(RequestedDir));
00557     return true;
00558   }
00559 
00560   return false;
00561 }
00562 
00563 static bool getDarwinConfDir(bool TempDir, SmallVectorImpl<char> &Result) {
00564   #if defined(_CS_DARWIN_USER_TEMP_DIR) && defined(_CS_DARWIN_USER_CACHE_DIR)
00565   // On Darwin, use DARWIN_USER_TEMP_DIR or DARWIN_USER_CACHE_DIR.
00566   // macros defined in <unistd.h> on darwin >= 9
00567   int ConfName = TempDir ? _CS_DARWIN_USER_TEMP_DIR
00568                          : _CS_DARWIN_USER_CACHE_DIR;
00569   size_t ConfLen = confstr(ConfName, nullptr, 0);
00570   if (ConfLen > 0) {
00571     do {
00572       Result.resize(ConfLen);
00573       ConfLen = confstr(ConfName, Result.data(), Result.size());
00574     } while (ConfLen > 0 && ConfLen != Result.size());
00575 
00576     if (ConfLen > 0) {
00577       assert(Result.back() == 0);
00578       Result.pop_back();
00579       return true;
00580     }
00581 
00582     Result.clear();
00583   }
00584   #endif
00585   return false;
00586 }
00587 
00588 static bool getUserCacheDir(SmallVectorImpl<char> &Result) {
00589   // First try using XDS_CACHE_HOME env variable,
00590   // as specified in XDG Base Directory Specification at
00591   // http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
00592   if (const char *XdsCacheDir = std::getenv("XDS_CACHE_HOME")) {
00593     Result.clear();
00594     Result.append(XdsCacheDir, XdsCacheDir + strlen(XdsCacheDir));
00595     return true;
00596   }
00597 
00598   // Try Darwin configuration query
00599   if (getDarwinConfDir(false, Result))
00600     return true;
00601 
00602   // Use "$HOME/.cache" if $HOME is available
00603   if (home_directory(Result)) {
00604     append(Result, ".cache");
00605     return true;
00606   }
00607 
00608   return false;
00609 }
00610 
00611 static const char *getEnvTempDir() {
00612   // Check whether the temporary directory is specified by an environment
00613   // variable.
00614   const char *EnvironmentVariables[] = {"TMPDIR", "TMP", "TEMP", "TEMPDIR"};
00615   for (const char *Env : EnvironmentVariables) {
00616     if (const char *Dir = std::getenv(Env))
00617       return Dir;
00618   }
00619 
00620   return nullptr;
00621 }
00622 
00623 static const char *getDefaultTempDir(bool ErasedOnReboot) {
00624 #ifdef P_tmpdir
00625   if ((bool)P_tmpdir)
00626     return P_tmpdir;
00627 #endif
00628 
00629   if (ErasedOnReboot)
00630     return "/tmp";
00631   return "/var/tmp";
00632 }
00633 
00634 void system_temp_directory(bool ErasedOnReboot, SmallVectorImpl<char> &Result) {
00635   Result.clear();
00636 
00637   if (ErasedOnReboot) {
00638     // There is no env variable for the cache directory.
00639     if (const char *RequestedDir = getEnvTempDir()) {
00640       Result.append(RequestedDir, RequestedDir + strlen(RequestedDir));
00641       return;
00642     }
00643   }
00644 
00645   if (getDarwinConfDir(ErasedOnReboot, Result))
00646     return;
00647 
00648   const char *RequestedDir = getDefaultTempDir(ErasedOnReboot);
00649   Result.append(RequestedDir, RequestedDir + strlen(RequestedDir));
00650 }
00651 
00652 } // end namespace path
00653 
00654 } // end namespace sys
00655 } // end namespace llvm