Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fc::path Class Reference

wraps boost::filesystem::path to provide platform independent path manipulation. More...

#include <filesystem.hpp>

Public Member Functions

 path ()
 
 ~path ()
 
 path (const boost::filesystem::path &)
 
 path (const std::string &p)
 
 path (const std::wstring &p)
 Constructor to build path using unicode native characters.
 
 path (const char *)
 
 path (const path &p)
 
 path (path &&p)
 
pathoperator= (const path &)
 
pathoperator= (path &&)
 
pathoperator/= (const fc::path &)
 
 operator boost::filesystem::path & ()
 
 operator const boost::filesystem::path & () const
 
void replace_extension (const fc::path &e)
 
fc::path stem () const
 
fc::path extension () const
 
fc::path filename () const
 
fc::path parent_path () const
 
std::string string () const
 
std::string generic_string () const
 
std::string preferred_string () const
 
std::wstring wstring () const
 
std::wstring generic_wstring () const
 
std::wstring preferred_wstring () const
 
std::string to_native_ansi_path () const
 
std::string windows_string () const
 replaces '/' with '\' in the result of generic_string()
 
bool is_relative () const
 
bool is_absolute () const
 
bool empty () const
 

Static Public Attributes

static char separator_char = static_cast<char>(boost::filesystem::path("/").make_preferred().native()[0])
 

Friends

path operator/ (const fc::path &p, const fc::path &o)
 
bool operator== (const fc::path &p, const fc::path &r)
 
bool operator!= (const fc::path &p, const fc::path &r)
 
bool operator< (const fc::path &p, const fc::path &r)
 

Detailed Description

Most calls are simply a passthrough to boost::filesystem::path, however exceptions are wrapped in an fc::error_report and the additional helper method fc::path::windows_string(), can be used to calculate paths intended for systems different than the host.

Note
Serializes to a fc::value() as the result of generic_string()

Definition at line 28 of file filesystem.hpp.

Constructor & Destructor Documentation

◆ path() [1/7]

fc::path::path ( )

Definition at line 53 of file filesystem.cpp.

53{}

◆ ~path()

fc::path::~path ( )

Definition at line 54 of file filesystem.cpp.

54{};

◆ path() [2/7]

fc::path::path ( const boost::filesystem::path & p)

Definition at line 55 of file filesystem.cpp.

56 :_p(p){}
const mie::Vuint & p
Definition bn.cpp:27

◆ path() [3/7]

fc::path::path ( const std::string & p)

Definition at line 60 of file filesystem.cpp.

61 :_p(p.c_str()){}

◆ path() [4/7]

fc::path::path ( const std::wstring & p)

Definition at line 63 of file filesystem.cpp.

64 :_p(p) {}

◆ path() [5/7]

fc::path::path ( const char * p)

Definition at line 58 of file filesystem.cpp.

59 :_p(p){}

◆ path() [6/7]

fc::path::path ( const path & p)

Definition at line 66 of file filesystem.cpp.

67 :_p(p){}

◆ path() [7/7]

fc::path::path ( path && p)

Definition at line 69 of file filesystem.cpp.

70 :_p(std::move(p)){}

Member Function Documentation

◆ empty()

bool fc::path::empty ( ) const

Definition at line 175 of file filesystem.cpp.

175{ return _p->empty(); }

◆ extension()

fc::path fc::path::extension ( ) const

Definition at line 163 of file filesystem.cpp.

163 {
164 return _p->extension();
165 }

◆ filename()

fc::path fc::path::filename ( ) const

Definition at line 157 of file filesystem.cpp.

157 {
158 return _p->filename();
159 }
Here is the caller graph for this function:

◆ generic_string()

fc::string fc::path::generic_string ( ) const

Definition at line 101 of file filesystem.cpp.

101 {
102 return _p->generic_string();
103 }
Here is the caller graph for this function:

◆ generic_wstring()

std::wstring fc::path::generic_wstring ( ) const

Definition at line 115 of file filesystem.cpp.

116 {
117 return _p->generic_wstring();
118 }
Here is the caller graph for this function:

◆ is_absolute()

bool fc::path::is_absolute ( ) const

Definition at line 173 of file filesystem.cpp.

173{ return _p->is_absolute(); }

◆ is_relative()

bool fc::path::is_relative ( ) const

Definition at line 172 of file filesystem.cpp.

172{ return _p->is_relative(); }

◆ operator boost::filesystem::path &()

fc::path::operator boost::filesystem::path & ( )

Definition at line 95 of file filesystem.cpp.

95 {
96 return *_p;
97 }

◆ operator const boost::filesystem::path &()

fc::path::operator const boost::filesystem::path & ( ) const

Definition at line 98 of file filesystem.cpp.

98 {
99 return *_p;
100 }

◆ operator/=()

path & fc::path::operator/= ( const fc::path & p)

Definition at line 85 of file filesystem.cpp.

85 {
86 *_p /= *p._p;
87 return *this;
88 }

◆ operator=() [1/2]

path & fc::path::operator= ( const path & p)

Definition at line 72 of file filesystem.cpp.

72 {
73 *_p = *p._p;
74 return *this;
75 }

◆ operator=() [2/2]

path & fc::path::operator= ( path && p)

Definition at line 76 of file filesystem.cpp.

76 {
77 *_p = fc::move( *p._p );
78 return *this;
79 }

◆ parent_path()

fc::path fc::path::parent_path ( ) const

Definition at line 169 of file filesystem.cpp.

169 {
170 return _p->parent_path();
171 }
Here is the caller graph for this function:

◆ preferred_string()

fc::string fc::path::preferred_string ( ) const

On windows, returns a path where all path separators are '\' suitable for displaying to users. On other platforms, it does the same as generic_string()

Definition at line 105 of file filesystem.cpp.

106 {
107 return boost::filesystem::path(*_p).make_preferred().string();
108 }

◆ preferred_wstring()

std::wstring fc::path::preferred_wstring ( ) const

Definition at line 120 of file filesystem.cpp.

121 {
122 return boost::filesystem::path(*_p).make_preferred().wstring();
123 }

◆ replace_extension()

void fc::path::replace_extension ( const fc::path & e)

Definition at line 160 of file filesystem.cpp.

160 {
161 _p->replace_extension(e);
162 }
Here is the caller graph for this function:

◆ stem()

fc::path fc::path::stem ( ) const

Definition at line 166 of file filesystem.cpp.

166 {
167 return _p->stem();
168 }

◆ string()

fc::string fc::path::string ( ) const

Definition at line 154 of file filesystem.cpp.

154 {
155 return _p->string();
156 }
Here is the caller graph for this function:

◆ to_native_ansi_path()

std::string fc::path::to_native_ansi_path ( ) const

Retrieves native string path representation and next converts it into ANSI UTF-8 representation. It is needed since not all parts of fc library accept unicode paths (fc::file_mapping).

Definition at line 125 of file filesystem.cpp.

126 {
127 std::wstring path = generic_wstring();
128
129#ifdef WIN32
130 const size_t maxPath = 32*1024;
131 std::vector<wchar_t> short_path;
132 short_path.resize(maxPath + 1);
133
134 wchar_t* buffer = short_path.data();
135 DWORD res = GetShortPathNameW(path.c_str(), buffer, maxPath);
136 if(res != 0)
137 path = buffer;
138#endif
139 std::string filePath;
140 fc::encodeUtf8(path, &filePath);
141 return filePath;
142 }
std::wstring generic_wstring() const
void encodeUtf8(const std::wstring &input, std::string *storage)
Definition utf8.cpp:78
Here is the call graph for this function:

◆ windows_string()

fc::string fc::path::windows_string ( ) const
Note
not part of boost::filesystem::path
Todo
use iterators instead of indexes for faster performance

Definition at line 148 of file filesystem.cpp.

148 {
149 std::string result = _p->generic_string();
150 std::replace(result.begin(), result.end(), '/', '\\');
151 return result;
152 }

◆ wstring()

std::wstring fc::path::wstring ( ) const

Definition at line 110 of file filesystem.cpp.

111 {
112 return _p->wstring();
113 }

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const fc::path & p,
const fc::path & r )
friend

Definition at line 83 of file filesystem.cpp.

83{ return *l._p != *r._p; }
const mie::Vuint & r
Definition bn.cpp:28
int l

◆ operator/

path operator/ ( const fc::path & p,
const fc::path & o )
friend

Definition at line 89 of file filesystem.cpp.

89 {
90 path tmp;
91 tmp = *p._p / *o._p;
92 return tmp;
93 }

◆ operator<

bool operator< ( const fc::path & p,
const fc::path & r )
friend

Definition at line 81 of file filesystem.cpp.

81{ return *l._p < *r._p; }

◆ operator==

bool operator== ( const fc::path & p,
const fc::path & r )
friend

Definition at line 82 of file filesystem.cpp.

82{ return *l._p == *r._p; }

Member Data Documentation

◆ separator_char

char fc::path::separator_char = static_cast<char>(boost::filesystem::path("/").make_preferred().native()[0])
static

Definition at line 85 of file filesystem.hpp.


The documentation for this class was generated from the following files: