diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-10-23 22:08:31 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-10-23 22:08:31 +0100 |
commit | 00c70303f6bcd0f1b778bf6647e1b049c5e27ea3 (patch) | |
tree | 26e378cd0338040d5ba34d6491531888a30574b1 /src/libutil | |
parent | 575aa943606aa2f946f407c663259d70d4a87ffb (diff) | |
download | rspamd-00c70303f6bcd0f1b778bf6647e1b049c5e27ea3.tar.gz rspamd-00c70303f6bcd0f1b778bf6647e1b049c5e27ea3.zip |
[Minor] Normalise file names
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/cxx/file_util.cxx | 10 | ||||
-rw-r--r-- | src/libutil/cxx/file_util.hxx | 2 |
2 files changed, 11 insertions, 1 deletions
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 |