2012-12-17 19:06:06 +00:00
|
|
|
//#define BOOST_NO_SCOPED_ENUMS
|
2012-09-08 21:37:25 +00:00
|
|
|
#include <fc/filesystem.hpp>
|
|
|
|
|
#include <fc/fwd_impl.hpp>
|
|
|
|
|
#include <fc/utility.hpp>
|
2012-12-17 19:06:06 +00:00
|
|
|
#include <boost/config.hpp>
|
2012-09-08 21:37:25 +00:00
|
|
|
#include <boost/filesystem.hpp>
|
2012-12-17 01:13:09 +00:00
|
|
|
#include <fc/value_cast.hpp>
|
2012-09-08 21:37:25 +00:00
|
|
|
|
|
|
|
|
namespace fc {
|
2012-12-17 01:13:09 +00:00
|
|
|
void pack( fc::value& v, const fc::path& s ) {
|
|
|
|
|
v = s.generic_string();
|
|
|
|
|
}
|
|
|
|
|
void unpack( const fc::value& v, fc::path& s ) {
|
|
|
|
|
s = path(fc::value_cast<fc::string>(v));
|
|
|
|
|
}
|
2012-09-08 21:37:25 +00:00
|
|
|
|
|
|
|
|
path::path(){}
|
|
|
|
|
path::~path(){};
|
|
|
|
|
path::path( const boost::filesystem::path& p )
|
|
|
|
|
:_p(p){}
|
|
|
|
|
|
2012-09-09 04:39:37 +00:00
|
|
|
path::path( const char* p )
|
|
|
|
|
:_p(p){}
|
2012-09-08 21:37:25 +00:00
|
|
|
path::path( const fc::string& p )
|
|
|
|
|
:_p(p.c_str()){}
|
|
|
|
|
|
|
|
|
|
path::path( const path& p )
|
|
|
|
|
:_p(p){}
|
|
|
|
|
|
|
|
|
|
path::path( path&& p )
|
|
|
|
|
:_p(std::move(p)){}
|
|
|
|
|
|
|
|
|
|
path& path::operator =( const path& p ) {
|
|
|
|
|
*_p = *p._p;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
path& path::operator =( path&& p ) {
|
|
|
|
|
*_p = fc::move( *p._p );
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-14 04:56:20 +00:00
|
|
|
bool operator ==( const fc::path& l, const fc::path& r ) { return *l._p == *r._p; }
|
|
|
|
|
bool operator !=( const fc::path& l, const fc::path& r ) { return *l._p != *r._p; }
|
|
|
|
|
|
2012-09-08 21:37:25 +00:00
|
|
|
path& path::operator /=( const fc::path& p ) {
|
|
|
|
|
*_p /= *p._p;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
path operator /( const fc::path& p, const fc::path& o ) {
|
|
|
|
|
path tmp;
|
|
|
|
|
tmp = *p._p / *o._p;
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
path::operator boost::filesystem::path& () {
|
2012-09-09 15:12:15 +00:00
|
|
|
return *_p;
|
2012-09-08 21:37:25 +00:00
|
|
|
}
|
|
|
|
|
path::operator const boost::filesystem::path& ()const {
|
2012-09-09 15:12:15 +00:00
|
|
|
return *_p;
|
2012-09-08 21:37:25 +00:00
|
|
|
}
|
2012-11-08 14:44:27 +00:00
|
|
|
fc::string path::generic_string()const {
|
|
|
|
|
return _p->generic_string();
|
|
|
|
|
}
|
2012-09-08 21:37:25 +00:00
|
|
|
|
|
|
|
|
fc::string path::string()const {
|
|
|
|
|
return _p->string().c_str();
|
|
|
|
|
}
|
2012-09-14 04:56:20 +00:00
|
|
|
fc::path path::filename()const {
|
|
|
|
|
return _p->filename();
|
|
|
|
|
}
|
2012-10-10 01:40:29 +00:00
|
|
|
fc::path path::extension()const {
|
|
|
|
|
return _p->extension();
|
|
|
|
|
}
|
|
|
|
|
fc::path path::stem()const {
|
|
|
|
|
return _p->stem();
|
|
|
|
|
}
|
|
|
|
|
fc::path path::parent_path()const {
|
|
|
|
|
return _p->parent_path();
|
|
|
|
|
}
|
2012-09-08 21:37:25 +00:00
|
|
|
|
2012-12-02 17:35:05 +00:00
|
|
|
directory_iterator::directory_iterator( const fc::path& p )
|
|
|
|
|
:_p(p){}
|
|
|
|
|
|
|
|
|
|
directory_iterator::directory_iterator(){}
|
|
|
|
|
directory_iterator::~directory_iterator(){}
|
|
|
|
|
|
|
|
|
|
fc::path directory_iterator::operator*()const { return boost::filesystem::path(*(*_p)); }
|
|
|
|
|
directory_iterator& directory_iterator::operator++(int) { (*_p)++; return *this; }
|
|
|
|
|
directory_iterator& directory_iterator::operator++() { (*_p)++; return *this; }
|
|
|
|
|
|
|
|
|
|
bool operator==( const directory_iterator& r, const directory_iterator& l) {
|
|
|
|
|
return *r._p == *l._p;
|
|
|
|
|
}
|
|
|
|
|
bool operator!=( const directory_iterator& r, const directory_iterator& l) {
|
|
|
|
|
return *r._p != *l._p;
|
|
|
|
|
}
|
2012-09-08 21:37:25 +00:00
|
|
|
|
|
|
|
|
bool exists( const path& p ) { return boost::filesystem::exists(p); }
|
|
|
|
|
void create_directories( const path& p ) { boost::filesystem::create_directories(p); }
|
2012-09-14 04:56:20 +00:00
|
|
|
bool is_directory( const path& p ) { return boost::filesystem::is_directory(p); }
|
2012-10-10 01:40:29 +00:00
|
|
|
bool is_regular_file( const path& p ) { return boost::filesystem::is_regular_file(p); }
|
2012-12-18 19:37:14 +00:00
|
|
|
size_t file_size( const path& p ) { return boost::filesystem::file_size(p); }
|
2012-12-17 19:06:06 +00:00
|
|
|
void copy( const path& f, const path& t ) { boost::filesystem::copy( boost::filesystem::path(f), boost::filesystem::path(t) ); }
|
2012-11-15 17:08:31 +00:00
|
|
|
bool remove( const path& f ) { return boost::filesystem::remove( f ); }
|
2012-11-15 17:37:56 +00:00
|
|
|
fc::path canonical( const fc::path& p ) { return boost::filesystem::canonical(p); }
|
2012-12-12 18:26:41 +00:00
|
|
|
fc::path absolute( const fc::path& p ) { return boost::filesystem::absolute(p); }
|
2012-11-26 19:16:49 +00:00
|
|
|
path unique_path() { return boost::filesystem::unique_path(); }
|
|
|
|
|
path temp_directory_path() { return boost::filesystem::temp_directory_path(); }
|
2012-09-08 21:37:25 +00:00
|
|
|
}
|