21#ifndef HAVE_STRUCT_DIRENT_D_TYPE
45Path absPath(Path path,
46 std::optional<PathView> dir = {},
47 bool resolveSymlinks =
false);
55Path canonPath(PathView path,
bool resolveSymlinks =
false);
71Path realPath(Path
const & path);
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);
157Path readLink(
const Path & path);
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,
bool sync =
false);
194void writeFile(
const Path & path, Source & source, mode_t mode = 0666,
bool sync =
false);
195kj::Promise<Result<void>>
196writeFile(
const Path & path, AsyncInputStream & source, mode_t mode = 0666,
bool sync =
false);
201void syncParent(
const Path & path);
208void deletePath(
const Path & path);
209void deletePathUninterruptible(
const Path & path);
211void deletePath(
const Path & path, uint64_t & bytesFreed);
217Paths createDirs(
const Path & path);
218inline Paths createDirs(PathView path)
220 return createDirs(Path(path));
226void createSymlink(
const Path & target,
const Path & link);
231void replaceSymlink(
const Path & target,
const Path & link);
233void renameFile(
const Path & src,
const Path & dst);
242void moveFile(
const Path & src,
const Path & dst);
280 void reset(
const Path & p,
bool recursive =
true);
281 operator Path()
const {
return path; }
282 operator PathView()
const {
return path; }
287 void operator()(DIR * dir)
const {
292typedef std::unique_ptr<DIR, DIRDeleter> AutoCloseDir;
297Path createTempSubdir(
const Path & parent,
const Path & prefix =
"nix",
298 bool includePid =
true,
bool useGlobalCounter =
true, mode_t mode = 0755);
306Path makeTempPath(
const Path & root,
const Path & suffix =
".tmp");
Definition file-system.hh:271
std::function< bool(const Path &path) PathFilter)
Definition file-system.hh:311
Definition file-system.hh:245
bool followSymlinks
Definition file-system.hh:254
bool deleteAfter
Definition file-system.hh:249
Definition file-system.hh:286
Definition file-system.hh:166
unsigned char type
Definition file-system.hh:172
std::string Path
Definition types.hh:28