21#ifndef HAVE_STRUCT_DIRENT_D_TYPE
46 std::optional<PathView> dir = {},
47 bool resolveSymlinks =
false);
55Path canonPath(PathView path,
bool resolveSymlinks =
false);
81Path tildePath(
Path const & path,
const std::optional<Path> & home = std::nullopt);
88void chmodPath(
const Path & path, mode_t mode);
96Path dirOf(
const PathView path);
102std::string_view baseNameOf(std::string_view path);
107std::string expandTilde(std::string_view path);
113bool isInDir(std::string_view path, std::string_view dir);
119bool isDirOrInDir(std::string_view path, std::string_view dir);
124struct stat stat(const
Path & path);
125struct stat lstat(const
Path & path);
131std::optional<struct stat> maybeStat(
const Path & path);
137std::optional<struct stat> maybeLstat(
const Path & path);
142bool pathExists(
const Path & path);
151bool pathAccessible(
const Path & path,
bool resolveSymlinks =
false);
159bool isLink(
const Path & path);
173 DirEntry(std::string name, ino_t ino,
unsigned char type)
174 : name(std::move(name)), ino(ino),
type(
type) { }
177typedef std::vector<DirEntry> DirEntries;
179DirEntries readDirectory(
const Path & path);
181unsigned char getFileType(
const Path & path);
186std::string readFile(
const Path & path);
187Generator<Bytes> readFileSource(
const Path & path);
192void writeFile(
const Path & path, std::string_view s, mode_t mode = 0666);
194void writeFile(
const Path & path, Source & source, mode_t mode = 0666);
196void writeFile(AutoCloseFD & fd, std::string_view s, mode_t mode = 0666);
197kj::Promise<Result<void>>
198writeFile(
const Path & path, AsyncInputStream & source, mode_t mode = 0666);
203void writeFileAndSync(
const Path & path, std::string_view s, mode_t mode = 0666);
208void syncParent(
const Path & path);
215void deletePath(
const Path & path);
216void deletePathUninterruptible(
const Path & path);
218void deletePath(
const Path & path, uint64_t & bytesFreed);
224Paths createDirs(
const Path & path);
225inline Paths createDirs(PathView path)
227 return createDirs(Path(path));
233void createSymlink(
const Path & target,
const Path & link);
238void replaceSymlink(
const Path & target,
const Path & link);
240void renameFile(
const Path & src,
const Path & dst);
249void moveFile(
const Path & src,
const Path & dst);
284 AutoDelete(
const Path & p,
bool recursive =
true);
287 void reset(
const Path & p,
bool recursive =
true);
288 operator Path()
const {
return path; }
289 operator PathView()
const {
return path; }
294 void operator()(DIR * dir)
const {
299typedef std::unique_ptr<DIR, DIRDeleter> AutoCloseDir;
304Path createTempSubdir(
const Path & parent,
const Path & prefix =
"nix",
305 bool includePid =
true,
bool useGlobalCounter =
true, mode_t mode = 0755);
313Path makeTempPath(
const Path & root,
const Path & suffix =
".tmp");
std::function< bool(const Path &path)> PathFilter
Definition file-system.hh:318
Definition file-system.hh:252
bool followSymlinks
Definition file-system.hh:261
bool deleteAfter
Definition file-system.hh:256
Definition file-system.hh:293
unsigned char type
Definition file-system.hh:172
Definition serialise.hh:18
Definition serialise.hh:66
std::string Path
Definition types.hh:28