前言
本次笔记记录如下知识点
- filesystem库的使用
一、filesystem库的使用
1、filesystem库的介绍
#include <boost/filesystem.hpp>
using namespace boost::filesystem;
class path
{
public:
typedef char_or_wchar_t value_type;
typedef std::basic_string<value_type> string_type;
constexpr value_type preferred_separator;
path();
path(const path& p);
path(Source const& source);
path(Inputiterator begin, Inputiterator end);
path& opertor= (const path& p);
path& opertor= (Source const& source);
path& assign(Source const& source);
path& assign(Inputiterator begin, Inputiterator end);
path& opertor/= (const path& p);
path& opertor/= (Source const& source);
path& append(Source const& source);
path& append(Inputiterator begin, Inputiterator end);
path& opertor+= (const path& p);
path& opertor+= (const string_type& source);
path& opertor+= (Source const& source);
path& concat(Inputiterator begin, Inputiterator end);
void clear();
path& remove_filename();
path& replace_extension();
void swap(path& rhs);
const string_type& native() const;
const value_type* c_str() const;
const string string() const;
const wstring wstring() const;
int compare(const path& p) const;
int compare(const std::string& s) const;
int compare(const value_type* s) const;
path root_name() const;
path root_directory() const;
path root_path() const;
path relative_path() const;
path parent_path() const;
path filename() const;
path stem() const;
path extension() const;
bool empty() const;
bool has_root_name() const;
bool has_root_directory() const;
bool has_root_path() const;
bool has_relative_path() const;
bool has_parent_path() const;
bool has_filename() const;
bool has_stem() const;
bool has_extension() const;
bool is_absolute() const;
bool relative() const;
iterator begin() const;
iterator end() const;
};
2、路径表示
path p1("./a_dir");
path p2("/usr/local/lib");
|