Lines Matching refs:path

91 Result<void> WalkDir(const std::string& path, Fn fn) {  in WalkDir()  argument
94 auto it = fs::directory_iterator(path, ec); in WalkDir()
101 return Error() << "Can't open " << path in WalkDir()
108 Result<std::vector<std::string>> ReadDir(const std::string& path, FilterFn fn) { in ReadDir() argument
112 auto status = WalkDir(path, [&](const fs::directory_entry& entry) { in ReadDir()
114 ret.push_back(entry.path()); in ReadDir()
123 inline bool IsEmptyDirectory(const std::string& path) { in IsEmptyDirectory() argument
124 auto res = ReadDir(path, [](auto _) { return true; }); in IsEmptyDirectory()
128 inline Result<void> createDirIfNeeded(const std::string& path, mode_t mode) { in createDirIfNeeded() argument
131 if (stat(path.c_str(), &stat_data) != 0) { in createDirIfNeeded()
133 if (mkdir(path.c_str(), mode) != 0) { in createDirIfNeeded()
134 return ErrnoError() << "Could not mkdir " << path; in createDirIfNeeded()
137 return ErrnoError() << "Could not stat " << path; in createDirIfNeeded()
141 return Error() << path << " exists and is not a directory."; in createDirIfNeeded()
147 if (chmod(path.c_str(), mode) != 0) { in createDirIfNeeded()
148 return ErrnoError() << "Could not chmod " << path; in createDirIfNeeded()
154 inline Result<void> DeleteDirContent(const std::string& path) { in DeleteDirContent() argument
155 auto files = ReadDir(path, [](auto _) { return true; }); in DeleteDirContent()
157 return Error() << "Failed to delete " << path << " : " << files.error(); in DeleteDirContent()
167 inline Result<void> DeleteDir(const std::string& path) { in DeleteDir() argument
170 fs::remove_all(path, ec); in DeleteDir()
172 return Error() << "Failed to delete path " << path << " : " << ec.message(); in DeleteDir()
177 inline Result<ino_t> get_path_inode(const std::string& path) { in get_path_inode() argument
180 if (stat(path.c_str(), &buf) != 0) { in get_path_inode()
181 return ErrnoError() << "Failed to stat " << path; in get_path_inode()
187 inline Result<bool> PathExists(const std::string& path) { in PathExists() argument
191 if (!fs::exists(fs::path(path), ec)) { in PathExists()
193 return Error() << "Failed to access " << path << " : " << ec.message(); in PathExists()
208 inline Result<void> WaitForFile(const std::string& path, in WaitForFile() argument
214 if (stat(path.c_str(), &sb) != -1) { in WaitForFile()
216 LOG(INFO) << "wait for '" << path << "' took " << t; in WaitForFile()
223 return ErrnoError() << "wait for '" << path << "' timed out and took " << t; in WaitForFile()
226 inline Result<std::vector<std::string>> GetSubdirs(const std::string& path) { in GetSubdirs() argument
237 return ReadDir(path, filter_fn); in GetSubdirs()