summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-01-21 14:30:05 +0200
committerpedropintosilva <65948705+pedropintosilva@users.noreply.github.com>2022-01-26 10:23:36 +0100
commit0969f25685c03f6d1db3b33057c2fcb9deb234a1 (patch)
tree76d197c7567c1f4829381e028cf48e2a3c486272 /common
parentCopy cool-api.html into code: getCustomPreview() (diff)
downloadonline-0969f25685c03f6d1db3b33057c2fcb9deb234a1.tar.gz
online-0969f25685c03f6d1db3b33057c2fcb9deb234a1.zip
make sure modifiedTimeUs calculates with enough precision
otherwise, on some platforms, the calculation might occur with 32-bits, but we really need 64 bits for microseconds. Also tweak the return type to make sure we use 64 bits. Signed-off-by: Noel Grandin <noel.grandin@collabora.co.uk> Change-Id: Ie8b8a49938c7ac2cfe7c5fc1dd6629e6ea347115
Diffstat (limited to 'common')
-rw-r--r--common/FileUtil.hpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/common/FileUtil.hpp b/common/FileUtil.hpp
index 44d7b60c59..6271ac6e08 100644
--- a/common/FileUtil.hpp
+++ b/common/FileUtil.hpp
@@ -169,9 +169,10 @@ namespace FileUtil
}
/// Returns the modified unix-time in microseconds since epoch.
- std::size_t modifiedTimeUs() const
+ int64_t modifiedTimeUs() const
{
- return (modifiedTime().tv_sec * 1000 * 1000) + (modifiedTime().tv_nsec / 1000);
+ // cast to make sure the calculation happens with enough bits
+ return (static_cast<int64_t>(modifiedTime().tv_sec) * 1000 * 1000) + (modifiedTime().tv_nsec / 1000);
}
/// Returns the modified unix-time in milliseconds since epoch.