1//===- RealPath.cpp -------------------------------------------------------===// 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#include "mcld/Support/RealPath.h" 10#include "mcld/Support/FileSystem.h" 11 12using namespace mcld::sys::fs; 13 14//========================== 15// RealPath 16RealPath::RealPath() 17 : Path() { 18} 19 20RealPath::RealPath(const RealPath::ValueType* s ) 21 : Path(s) { 22 initialize(); 23} 24 25RealPath::RealPath(const RealPath::StringType &s ) 26 : Path(s) { 27 initialize(); 28} 29 30RealPath::RealPath(const Path& pPath) 31 : Path(pPath) { 32 initialize(); 33} 34 35RealPath::~RealPath() 36{ 37} 38 39RealPath& RealPath::assign(const Path& pPath) 40{ 41 Path::m_PathName.assign(pPath.native()); 42 return (*this); 43} 44 45void RealPath::initialize() 46{ 47 if (isFromRoot()) { 48 detail::canonicalize(m_PathName); 49 } 50 else if (isFromPWD()) { 51 Path path_name; 52 detail::get_pwd(path_name); 53 path_name.native() += preferred_separator; 54 path_name.native() += m_PathName; 55 detail::canonicalize(path_name.native()); 56 m_PathName = path_name.native(); 57 } 58} 59 60