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