浏览该文件的文档.
17 #define WIN32_LEAN_AND_MEAN
18 #include "filesystem.hpp"
21 namespace fs = ghc::filesystem;
40 return p->entry.is_directory();
45 return p->entry.is_regular_file();
50 return p->entry.is_symlink();
55 return p->entry.path().string();
64 fs::directory_iterator
it;
97 result.
p->it = ++
p->it;
103 p->current.p->entry = *
p->it;
109 p->current.p->entry = *
p->it;
115 return it1.
p->it == it2.
p->it;
120 return it1.
p->it!=it2.
p->it;
145 p->path = fs::current_path(ec);
178 return p->path.string();
191 bool Dir::exists(
const std::string &path,
bool acceptsAbsPath)
const
195 bool exist = fs::exists(fs::path(result),ec);
207 fs::path pth =
path();
209 return fs::is_empty(pth);
219 return fs::path(
path).is_relative();
222 std::string
Dir::filePath(
const std::string &path,
bool acceptsAbsPath)
const
231 result = (
p->path /
path).
string();
237 bool Dir::mkdir(
const std::string &path,
bool acceptsAbsPath)
const
247 return fs::create_directory(result,ec);
251 bool Dir::rmdir(
const std::string &path,
bool acceptsAbsPath)
const
256 bool Dir::remove(
const std::string &path,
bool acceptsAbsPath)
const
260 return fs::remove(result,ec);
263 bool Dir::rename(
const std::string &orgName,
const std::string &newName,
bool acceptsAbsPath)
const
266 std::string fn1 =
filePath(orgName,acceptsAbsPath);
267 std::string fn2 =
filePath(newName,acceptsAbsPath);
268 fs::rename(fn1,fn2,ec);
272 bool Dir::copy(
const std::string &srcName,
const std::string &dstName,
bool acceptsAbsPath)
const
274 const auto copyOptions = fs::copy_options::overwrite_existing;
276 std::string sn =
filePath(srcName,acceptsAbsPath);
277 std::string dn =
filePath(dstName,acceptsAbsPath);
278 fs::copy(sn,dn,copyOptions,ec);
285 std::string result = fs::current_path(ec).string();
293 fs::current_path(
path,ec);
300 std::string result = fs::path(
path).lexically_normal().string();
308 std::string result = fs::absolute(
p->path,ec).string();
static std::string currentDirPath()
std::unique_ptr< Private > p
bool copy(const std::string &src, const std::string &dest, bool acceptsAbsPath=true) const
std::string replace(const std::string &str, const Ex &re, const std::string &replacement)
Searching in a given input string for parts that match regular expression re and replaces those parts...
std::string filePath(const std::string &path, bool acceptsAbsPath=true) const
bool remove(const std::string &path, bool acceptsAbsPath=true) const
Class representing a directory in the file system
bool is_regular_file() const
std::unique_ptr< Private > p
const value_type * operator->() const
DirIterator begin(DirIterator it) noexcept
DirIterator end(const DirIterator &) noexcept
static bool isRelativePath(const std::string &path)
bool operator!=(const DirIterator &it1, const DirIterator &it2)
bool rename(const std::string &orgName, const std::string &newName, bool acceptsAbsPath=true) const
fs::directory_entry entry
std::string absPath() const
const value_type & operator*() const
static bool setCurrent(const std::string &path)
DirIterator & operator=(const DirIterator &it)
bool is_directory() const
bool operator==(const DirIterator &it1, const DirIterator &it2)
bool isEmpty(const std::string subdir) const
Dir & operator=(const Dir &d)
static void correctPath(std::string &s)
fs::directory_iterator it
Minimal replacement for QFileInfo.
void setPath(const std::string &path)
DirIterator iterator() const
bool rmdir(const std::string &path, bool acceptsAbsPath=true) const
bool mkdir(const std::string &path, bool acceptsAbsPath=true) const
static std::string cleanDirPath(const std::string &path)
std::unique_ptr< Private > p
Private(const std::string &path)