diff options
author | Marius Bakke <mbakke@fastmail.com> | 2019-11-28 00:38:25 +0100 |
---|---|---|
committer | Marius Bakke <mbakke@fastmail.com> | 2019-11-28 00:38:25 +0100 |
commit | 0897ad7fac04fc9d814e83eed46e88c7bf9740bc (patch) | |
tree | 9bccfdb52de4c468778ceaabe337c0539c302a30 /nix/libutil/util.cc | |
parent | 6d460e80d1b06fc094374e7ba5c2503f2a897f11 (diff) | |
parent | 9943d238e9f07dccae973b641eb7738637ce95fb (diff) | |
download | patches-0897ad7fac04fc9d814e83eed46e88c7bf9740bc.tar patches-0897ad7fac04fc9d814e83eed46e88c7bf9740bc.tar.gz |
Merge branch 'master' into staging
Diffstat (limited to 'nix/libutil/util.cc')
-rw-r--r-- | nix/libutil/util.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/nix/libutil/util.cc b/nix/libutil/util.cc index 9a83876013..8093b4c8b4 100644 --- a/nix/libutil/util.cc +++ b/nix/libutil/util.cc @@ -306,7 +306,18 @@ static void _deletePath(const Path & path, unsigned long long & bytesFreed) printMsg(lvlVomit, format("%1%") % path); +#ifdef HAVE_STATX +# define st_mode stx_mode +# define st_size stx_size +# define st_nlink stx_nlink + struct statx st; + if (statx(AT_FDCWD, path.c_str(), + AT_SYMLINK_NOFOLLOW, + STATX_SIZE | STATX_NLINK | STATX_MODE, &st) == -1) + throw SysError(format("getting status of `%1%'") % path); +#else struct stat st = lstat(path); +#endif if (!S_ISDIR(st.st_mode) && st.st_nlink == 1) bytesFreed += st.st_size; @@ -321,6 +332,9 @@ static void _deletePath(const Path & path, unsigned long long & bytesFreed) for (auto & i : readDirectory(path)) _deletePath(path + "/" + i.name, bytesFreed); } +#undef st_mode +#undef st_size +#undef st_nlink if (remove(path.c_str()) == -1) throw SysError(format("cannot unlink `%1%'") % path); |