summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Stat.hpp5
-rw-r--r--unittest/test_Stat.cpp4
2 files changed, 5 insertions, 4 deletions
diff --git a/src/Stat.hpp b/src/Stat.hpp
index 42fe563f..5452872a 100644
--- a/src/Stat.hpp
+++ b/src/Stat.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2019-2022 Joel Rosdahl and other contributors
+// Copyright (C) 2019-2023 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
@@ -20,6 +20,7 @@
#include <core/wincompat.hpp>
#include <util/TimePoint.hpp>
+#include <util/file.hpp>
#include <sys/stat.h>
#include <sys/types.h>
@@ -250,7 +251,7 @@ inline uint64_t
Stat::size_on_disk() const
{
#ifdef _WIN32
- return (size() + 1023) & ~1023;
+ return util::likely_size_on_disk(size());
#else
return m_stat.st_blocks * 512;
#endif
diff --git a/unittest/test_Stat.cpp b/unittest/test_Stat.cpp
index 58830819..ffdb6809 100644
--- a/unittest/test_Stat.cpp
+++ b/unittest/test_Stat.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2019-2022 Joel Rosdahl and other contributors
+// Copyright (C) 2019-2023 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
@@ -265,7 +265,7 @@ TEST_CASE("Return values when file exists")
CHECK(stat.mtime().sec() == last_write_time.tv_sec);
CHECK(stat.mtime().nsec_decimal_part() == last_write_time.tv_nsec);
- CHECK(stat.size_on_disk() == ((stat.size() + 1023) & ~1023));
+ CHECK(stat.size_on_disk() == ((stat.size() + 4095) & ~4095));
CHECK(stat.file_attributes() == info.dwFileAttributes);
CHECK(stat.reparse_tag() == 0);