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