mirror of
https://github.com/NixOS/nix
synced 2025-06-26 20:01:15 +02:00
* Doh! Path sizes need to be computed recursively of course.
(NIX-70)
This commit is contained in:
parent
a76efaeb3f
commit
c6a97e3b74
3 changed files with 28 additions and 6 deletions
|
@ -238,6 +238,29 @@ void writeFile(const Path & path, const string & s)
|
|||
}
|
||||
|
||||
|
||||
unsigned long long computePathSize(const Path & path)
|
||||
{
|
||||
unsigned long long size = 0;
|
||||
|
||||
checkInterrupt();
|
||||
|
||||
struct stat st;
|
||||
if (lstat(path.c_str(), &st))
|
||||
throw SysError(format("getting attributes of path `%1%'") % path);
|
||||
|
||||
size += st.st_size;
|
||||
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
Strings names = readDirectory(path);
|
||||
|
||||
for (Strings::iterator i = names.begin(); i != names.end(); ++i)
|
||||
size += computePathSize(path + "/" + *i);
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
static void _deletePath(const Path & path, unsigned long long & bytesFreed)
|
||||
{
|
||||
checkInterrupt();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue