1 //===- RealPath.h ---------------------------------------------------------===// 2 // 3 // The MCLinker Project 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 #ifndef MCLD_REAL_PATH_H 10 #define MCLD_REAL_PATH_H 11 #ifdef ENABLE_UNITTEST 12 #include <gtest.h> 13 #endif 14 #include "mcld/Support/Path.h" 15 #include <string> 16 17 namespace mcld { 18 namespace sys { 19 namespace fs { 20 21 /** \class RealPath 22 * \brief The canonicalized absolute pathname. 23 * 24 */ 25 class RealPath : public Path 26 { 27 public: 28 typedef Path::ValueType ValueType; 29 typedef Path::StringType StringType; 30 31 public: 32 RealPath(); 33 explicit RealPath(const ValueType* s ); 34 explicit RealPath(const StringType &s ); 35 explicit RealPath(const Path& pPath); 36 37 ~RealPath(); 38 39 RealPath& assign(const Path& pPath); 40 41 protected: 42 void initialize(); 43 }; 44 45 } // namespace of fs 46 } // namespace of sys 47 } // namespace of mcld 48 49 //-------------------------------------------------------------------------// 50 // STL compatible functions // 51 //-------------------------------------------------------------------------// 52 namespace std { 53 54 template<> 55 struct less<mcld::sys::fs::RealPath> : public binary_function< 56 mcld::sys::fs::RealPath, 57 mcld::sys::fs::RealPath, 58 bool> 59 { 60 bool operator() (const mcld::sys::fs::RealPath& pX, 61 const mcld::sys::fs::RealPath& pY) const { 62 if (pX.native().size() < pY.native().size()) 63 return true; 64 return (pX.native() < pY.native()); 65 } 66 }; 67 68 } // namespace of std 69 70 71 #endif 72 73