Skip to content

Commit

Permalink
windows: use remove_all for _deletePath
Browse files Browse the repository at this point in the history
  • Loading branch information
puffnfresh committed Jan 14, 2025
1 parent 2cb0ddf commit 9c7d313
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/libutil/file-system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,9 @@ void recursiveSync(const Path & path)
}


#ifndef _WIN32
static void _deletePath(Descriptor parentfd, const fs::path & path, uint64_t & bytesFreed)
{
#ifndef _WIN32
checkInterrupt();

std::string name(baseNameOf(path.native()));
Expand Down Expand Up @@ -442,14 +442,12 @@ static void _deletePath(Descriptor parentfd, const fs::path & path, uint64_t & b
if (errno == ENOENT) return;
throw SysError("cannot unlink %1%", path);
}
#else
// TODO implement
throw UnimplementedError("_deletePath");
#endif
}
#endif

static void _deletePath(const fs::path & path, uint64_t & bytesFreed)
{
#ifndef _WIN32
Path dir = dirOf(path.string());
if (dir == "")
dir = "/";
Expand All @@ -461,6 +459,14 @@ static void _deletePath(const fs::path & path, uint64_t & bytesFreed)
}

_deletePath(dirfd.get(), path, bytesFreed);
#else
for (auto const &entry : fs::recursive_directory_iterator(path)) {
if (entry.is_symlink() || !entry.is_regular_file())
continue;
bytesFreed += entry.file_size();
}
fs::remove_all(path);
#endif
}


Expand Down

0 comments on commit 9c7d313

Please sign in to comment.