commit 00c7030: [Minor] Normalise file names
Vsevolod Stakhov
vsevolod at rspamd.com
Sun Oct 23 21:21:07 UTC 2022
Author: Vsevolod Stakhov
Date: 2022-10-23 22:08:31 +0100
URL: https://github.com/rspamd/rspamd/commit/00c70303f6bcd0f1b778bf6647e1b049c5e27ea3
[Minor] Normalise file names
---
src/libutil/cxx/file_util.cxx | 10 ++++++++++
src/libutil/cxx/file_util.hxx | 2 +-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/libutil/cxx/file_util.cxx b/src/libutil/cxx/file_util.cxx
index d0860b77b..1993ff666 100644
--- a/src/libutil/cxx/file_util.cxx
+++ b/src/libutil/cxx/file_util.cxx
@@ -145,6 +145,16 @@ auto raii_file::update_stat() noexcept -> bool
return fstat(fd, &st) != -1;
}
+raii_file::raii_file(const char *fname, int fd, bool temp) : fd(fd), temp(temp)
+{
+ std::size_t nsz;
+
+ /* Normalize path */
+ this->fname = fname;
+ rspamd_normalize_path_inplace(this->fname.data(), this->fname.size(), &nsz);
+ this->fname.resize(nsz);
+}
+
raii_locked_file::~raii_locked_file() noexcept
{
diff --git a/src/libutil/cxx/file_util.hxx b/src/libutil/cxx/file_util.hxx
index 097ce03a7..9fbcda540 100644
--- a/src/libutil/cxx/file_util.hxx
+++ b/src/libutil/cxx/file_util.hxx
@@ -126,7 +126,7 @@ protected:
std::string fname;
struct stat st;
- explicit raii_file(const char *fname, int fd, bool temp) : fd(fd), temp(temp), fname(fname) {}
+ explicit raii_file(const char *fname, int fd, bool temp);
};
/**
* A simple RAII object to contain a file descriptor with an flock wrap
More information about the Commits
mailing list