summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoel Rosdahl <joel@rosdahl.net>2022-11-10 09:03:08 +0100
committerJoel Rosdahl <joel@rosdahl.net>2022-11-27 21:33:51 +0100
commiteaa5b40a880eaceb72567d82981cda27624d72ae (patch)
tree3ffd131c8d43499da2842613ab9c40645519460d /src
parent0437820b47abe55e49f5fdb2ed189c4a1f23a611 (diff)
downloadccache-eaa5b40a880eaceb72567d82981cda27624d72ae.tar.gz
enhance: Remember path in Stat
Diffstat (limited to 'src')
-rw-r--r--src/Stat.cpp1
-rw-r--r--src/Stat.hpp10
2 files changed, 11 insertions, 0 deletions
diff --git a/src/Stat.cpp b/src/Stat.cpp
index 356bd920..87b20203 100644
--- a/src/Stat.cpp
+++ b/src/Stat.cpp
@@ -207,6 +207,7 @@ Stat::Stat(StatFunction stat_function,
const std::string& path,
Stat::OnError on_error)
{
+ m_path = path;
int result = stat_function(path.c_str(), &m_stat);
if (result == 0) {
m_errno = 0;
diff --git a/src/Stat.hpp b/src/Stat.hpp
index 5c81a5ba..42fe563f 100644
--- a/src/Stat.hpp
+++ b/src/Stat.hpp
@@ -116,6 +116,9 @@ public:
// otherwise false.
operator bool() const;
+ // Return the path that this stat result refers to.
+ const std::string& path() const;
+
// Return whether this object refers to the same device and i-node as `other`
// does.
bool same_inode_as(const Stat& other) const;
@@ -148,6 +151,7 @@ protected:
Stat(StatFunction stat_function, const std::string& path, OnError on_error);
private:
+ std::string m_path;
stat_t m_stat;
int m_errno;
@@ -170,6 +174,12 @@ Stat::same_inode_as(const Stat& other) const
return m_errno == 0 && device() == other.device() && inode() == other.inode();
}
+inline const std::string&
+Stat::path() const
+{
+ return m_path;
+}
+
inline int
Stat::error_number() const
{