37# define S_ISLNK(m) false
48bool isAbsolute(PathView
path);
57Path absPath(PathView
path,
58 std::optional<PathView>
dir = {},
59 bool resolveSymlinks =
false);
61inline Path absPath(
const Path &
path,
62 std::optional<PathView>
dir = {},
63 bool resolveSymlinks =
false)
65 return absPath(PathView{
path},
dir, resolveSymlinks);
68std::filesystem::path absPath(
const std::filesystem::path &
path,
69 bool resolveSymlinks =
false);
82Path canonPath(PathView
path,
bool resolveSymlinks =
false);
93Path dirOf(
const PathView
path);
102std::string_view baseNameOf(std::string_view
path);
108bool isInDir(std::string_view
path, std::string_view
dir);
114bool isDirOrInDir(std::string_view
path, std::string_view
dir);
119struct stat stat(const Path &
path);
120struct stat lstat(const Path &
path);
146 return std::filesystem::exists(std::filesystem::symlink_status(path));
166std::filesystem::path makeParentCanonical(
const std::filesystem::path &
path);
174bool pathAccessible(
const std::filesystem::path &
path);
194std::string
readFile(
const std::filesystem::path & path);
200void writeFile(
const Path & path, std::string_view
s, mode_t mode = 0666,
bool sync =
false);
201static inline void writeFile(
const std::filesystem::path & path, std::string_view
s, mode_t mode = 0666,
bool sync =
false)
203 return writeFile(path.string(),
s, mode, sync);
206void writeFile(
const Path &
path, Source & source, mode_t mode = 0666,
bool sync =
false);
207static inline void writeFile(
const std::filesystem::path &
path, Source & source, mode_t mode = 0666,
bool sync =
false)
215void syncParent(
const Path & path);
220void recursiveSync(
const Path & path);
227void deletePath(
const std::filesystem::path & path);
229void deletePath(
const std::filesystem::path & path, uint64_t & bytesFreed);
237void createDirs(
const Path & path);
238inline void createDirs(PathView path)
240 return createDirs(
Path(path));
246void createDir(
const Path &
path, mode_t mode = 0755);
262 const std::filesystem::path & path,
264 time_t modificationTime,
265 std::optional<bool> isSymlink = std::nullopt);
270void setWriteTime(
const std::filesystem::path & path,
const struct stat & st);
276void createSymlink(
const Path & target,
const Path & link);
281void replaceSymlink(
const std::filesystem::path & target,
const std::filesystem::path & link);
283inline void replaceSymlink(
const Path & target,
const Path & link)
285 return replaceSymlink(std::filesystem::path{target}, std::filesystem::path{link});
295void moveFile(
const Path & src,
const Path & dst);
303void copyFile(
const std::filesystem::path &
from,
const std::filesystem::path &
to,
bool andDelete);
310 std::filesystem::path _path;
315 AutoDelete(
const std::filesystem::path &
p,
bool recursive =
true);
320 void reset(
const std::filesystem::path &
p,
bool recursive =
true);
322 const std::filesystem::path & path()
const {
return _path; }
325 operator const std::filesystem::path & ()
const {
return _path; }
326 operator PathViewNG ()
const {
return _path; }
332 void operator()(DIR *
dir)
const {
337typedef std::unique_ptr<DIR, DIRDeleter> AutoCloseDir;
343Path createTempDir(
const Path & tmpRoot =
"",
const Path & prefix =
"nix",
344 bool includePid =
true,
bool useGlobalCounter =
true, mode_t mode = 0755);
349std::pair<AutoCloseFD, Path> createTempFile(
const Path & prefix =
"nix");
354Path defaultTempDir();
360bool isExecutableFileAmbient(
const std::filesystem::path & exe);
This file defines two main structs/classes used in nix error handling.
int Descriptor
Definition file-descriptor.hh:20
std::function< bool(const Path &path)> PathFilter
Definition file-system.hh:365
Descriptor openDirectory(const std::filesystem::path &path)
bool symlink_exists(const std::filesystem::path &path)
Definition file-system.hh:145
std::optional< PathView > dir
Definition lexer.l:3856
std::optional< SourceAccessor::Stat > maybeLstat() const
return s
Definition lexer.l:459
bool includePid
Definition lexer.l:4142
return writeFile(path.string(), s, mode, sync)
std::shared_ptr< T > p
Definition lexer.l:1269
std::string std::string_view from
Definition lexer.l:2591
std::string readFile() const
std::string path
Definition lexer.l:1399
std::string std::string_view std::string_view to
Definition lexer.l:2592
std::string readLink() const
Definition file-system.hh:331
Definition file-path.hh:26
Definition serialise.hh:20
std::string Path
Definition types.hh:22