17#define WIN32_LEAN_AND_MEAN
18#include "filesystem.hpp"
23namespace fs = ghc::filesystem;
39 p->entry = de.
p->entry;
46 p = std::make_unique<Private>();
47 p->entry = de.
p->entry;
67 return p->entry.is_directory();
72 return p->entry.is_regular_file();
77 return p->entry.is_symlink();
82 return p->entry.path().string();
91 fs::directory_iterator
it;
108 p->current = it.
p->current;
117 p->current = it.
p->current;
124 std::exchange(
p->it,it.p->it);
125 std::exchange(
p->ec,it.p->ec);
126 std::exchange(
p->current,it.p->current);
131 std::exchange(
p->it,it.p->it);
132 std::exchange(
p->ec,it.p->ec);
133 std::exchange(
p->current,it.p->current);
144 result.
p->it = ++
p->it;
150 p->current.p->entry = *
p->it;
156 p->current.p->entry = *
p->it;
162 return it1.
p->it == it2.
p->it;
167 return it1.
p->it!=it2.
p->it;
192 p->path = fs::current_path(ec);
211 std::exchange(
p->path,d.p->path);
216 std::exchange(
p->path,d.p->path);
236 return p->path.string();
246 std::replace( s.begin(), s.end(),
'\\',
'/' );
253 bool exist = fs::exists(fs::path(result),ec);
265 fs::path pth =
path();
267 return fs::is_empty(pth);
277 return fs::path(
path).is_relative();
289 result = (
p->path /
path).
string();
305 return fs::create_directory(result,ec);
318 return fs::remove(result,ec);
321bool Dir::rename(
const std::string &orgName,
const std::string &newName,
bool acceptsAbsPath)
const
324 std::string fn1 =
filePath(orgName,acceptsAbsPath);
325 std::string fn2 =
filePath(newName,acceptsAbsPath);
326 fs::rename(fn1,fn2,ec);
330bool Dir::copy(
const std::string &srcName,
const std::string &dstName,
bool acceptsAbsPath)
const
332 const auto copyOptions = fs::copy_options::overwrite_existing;
334 std::string sn =
filePath(srcName,acceptsAbsPath);
335 std::string dn =
filePath(dstName,acceptsAbsPath);
336 fs::copy(sn,dn,copyOptions,ec);
343 std::string result = fs::current_path(ec).string();
351 fs::current_path(
path,ec);
358 std::string result = fs::path(
path).lexically_normal().string();
366 std::string result = fs::absolute(
p->path,ec).string();
DirEntry(const DirEntry &)
bool is_directory() const
bool is_regular_file() const
std::unique_ptr< Private > p
DirEntry & operator=(const DirEntry &)
static std::string currentDirPath()
bool isEmpty(const std::string subdir) const
Dir & operator=(const Dir &d)
std::string absPath() const
bool mkdir(const std::string &path, bool acceptsAbsPath=true) const
void setPath(const std::string &path)
static bool isRelativePath(const std::string &path)
bool remove(const std::string &path, bool acceptsAbsPath=true) const
bool copy(const std::string &src, const std::string &dest, bool acceptsAbsPath=true) const
std::string filePath(const std::string &path, bool acceptsAbsPath=true) const
DirIterator iterator() const
bool rmdir(const std::string &path, bool acceptsAbsPath=true) const
bool rename(const std::string &orgName, const std::string &newName, bool acceptsAbsPath=true) const
static std::string cleanDirPath(const std::string &path)
static bool setCurrent(const std::string &path)
std::unique_ptr< Private > p
DirIterator(const DirIterator &it)
const value_type & operator*() const
const value_type * operator->() const
std::unique_ptr< Private > p
DirIterator & operator=(const DirIterator &it)
Minimal replacement for QFileInfo.
static void correctPath(std::string &s)
bool operator==(const DirIterator &it1, const DirIterator &it2)
DirIterator begin(DirIterator it) noexcept
bool operator!=(const DirIterator &it1, const DirIterator &it2)
DirIterator end(const DirIterator &) noexcept
fs::directory_entry entry
Private(const std::string &path)
fs::directory_iterator it