로딩중...
검색중...
일치하는것 없음
fsystem.hpp
이 파일의 문서화 페이지로 가기
1
2#pragma once
3
4#include "indep/common.hpp"
5#include "indep/helper/tmay.inl"
6#include "indep/macro.hpp"
7#include <filesystem>
8#include <regex>
9#ifdef BY_BUILD_PLATFORM_IS_WINDOWS
10# include <direct.h>
11# include <io.h>
12# define getcwd _getcwd
13#else
14# include <dirent.h>
15# include <unistd.h>
16#endif
17#include <vector>
18
19namespace by {
20
63 class _nout fsystem {
64 BY(ME(fsystem))
65
66 struct entry {
67#ifdef BY_BUILD_PLATFORM_IS_WINDOWS
69 intptr_t dir;
70#else
71 DIR* dir;
72#endif
73 std::filesystem::path path;
74 };
75
76 typedef std::vector<entry> entries;
77
83 class _nout iterator {
84 BY(ME(iterator))
85
86 public:
91 iterator() = default;
92 iterator(const std::filesystem::path& path);
93 iterator(const std::string& path);
94 iterator(const nchar* path);
95 ~iterator();
96
97 public:
98 const std::filesystem::path& operator*();
99 me& operator++(int);
100 operator nbool() const;
101 const std::filesystem::path* operator->() const;
102
103 public:
104 void rel();
105
112 nbool next();
113
114 const std::filesystem::path& get() const;
115 std::filesystem::path getDir() const;
116 nbool isEnd() const;
117
118 private:
119 void _addDir(const std::filesystem::path& dirPath);
120 void _popDir();
121 static nbool _isGlobPattern(const std::filesystem::path& p);
122 std::regex _convertToRegex(const std::filesystem::path& globPattern);
123
124 private:
125 entries _entries;
126 std::filesystem::path _nowPath;
127 tmay<std::regex> _pattern;
128 };
129
130 public:
137 static iterator find(const std::filesystem::path& path);
138 static iterator find(const std::string& path) BY_SIDE_FUNC(true, find(std::filesystem::path(path)), iterator());
139 static iterator find(const nchar* it) BY_SIDE_FUNC(it, find(std::filesystem::path(it)), iterator());
140
141 static std::filesystem::path getCurrentDir();
142 };
143} // namespace by
Cross-platform filesystem utilities for recursive file traversal
Definition fsystem.hpp:63
static iterator find(const std::filesystem::path &path)
Creates iterator for recursive filesystem traversal
Weak reference smart pointer with type-safe access
Definition tweak.hpp:16
#define BY_SIDE_FUNC(...)
Side function macros for safe pointer operations
Definition sideFunc.hpp:24
to Top