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_SUPPORT_REALPATH_H_ 10 #define MCLD_SUPPORT_REALPATH_H_ 11 #include "mcld/Support/Path.h" 12 13 #include <string> 14 15 namespace mcld { 16 namespace sys { 17 namespace fs { 18 19 /** \class RealPath 20 * \brief The canonicalized absolute pathname. 21 * 22 */ 23 class RealPath : public Path { 24 public: 25 typedef Path::ValueType ValueType; 26 typedef Path::StringType StringType; 27 28 public: 29 RealPath(); 30 explicit RealPath(const ValueType* s); 31 explicit RealPath(const StringType& s); 32 explicit RealPath(const Path& pPath); 33 34 ~RealPath(); 35 36 RealPath& assign(const Path& pPath); 37 38 protected: 39 void initialize(); 40 }; 41 42 } // namespace fs 43 } // namespace sys 44 } // namespace mcld 45 46 //----------------------------------------------------------------------------// 47 // STL compatible functions // 48 //----------------------------------------------------------------------------// 49 namespace std { 50 51 template <> 52 struct less<mcld::sys::fs::RealPath> 53 : public binary_function<mcld::sys::fs::RealPath, 54 mcld::sys::fs::RealPath, 55 bool> { 56 bool operator()(const mcld::sys::fs::RealPath& pX, 57 const mcld::sys::fs::RealPath& pY) const { 58 if (pX.native().size() < pY.native().size()) 59 return true; 60 return (pX.native() < pY.native()); 61 } 62 }; 63 64 } // namespace std 65 66 #endif // MCLD_SUPPORT_REALPATH_H_ 67