diff --git a/Log.cpp b/Log.cpp index 391f9fe..7520a46 100644 --- a/Log.cpp +++ b/Log.cpp @@ -297,6 +297,12 @@ std::ostream& operator<<(std::ostream& str, const PrintErrno&) { return str << strerror(errno) << " (" << errno << ')'; } +FileSize::operator std::string() const { + std::ostringstream str; + str << *this; + return str.str(); +} + std::ostream& operator<<(std::ostream& str, const FileSize& fs) { static const char PREFIX[] {' ', 'K', 'M', 'G', 'T', 'P', 'E'}; static const uint_fast8_t PREFIXCOUNT = 7; diff --git a/Log.h b/Log.h index b426a0e..54c518f 100644 --- a/Log.h +++ b/Log.h @@ -122,6 +122,7 @@ public: explicit FileSize(uint64_t fs) : fs(fs) {} FileSize(const FileSize&) = delete; FileSize& operator=(const FileSize&) = delete; + operator std::string() const; private: uint64_t fs; friend std::ostream& operator<<(std::ostream& str, const FileSize& fs);