e7efd2fb955ceb5d68cde89e726f62733c3f1b75
[oota-llvm.git] / lib / System / Linux / Path.cpp
1 //===- llvm/System/Linux/Path.cpp - Linux 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 Linux specific implementation of the Path class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 //===----------------------------------------------------------------------===//
15 //=== WARNING: Implementation here must contain only Linux 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
22 namespace llvm {
23 using namespace sys;
24
25 bool 
26 Path::is_valid() const {
27   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
36 }
37
38 // vim: sw=2 smartindent smarttab tw=80 autoindent expandtab