aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2022-05-20 16:30:08 +0200
committerSven Gothel <[email protected]>2022-05-20 16:30:08 +0200
commite701f65bc5f04c65713e212b2f60ca07dea79bc0 (patch)
tree392fb09f9c2389f567fe3728347bfa0abb35c72d
parenta2f8e16eadc2100cfada6a814cdfa1cf69870169 (diff)
Add default ctor to file_stats and dir_item; file_stats::to_string() uses decimal string for file size in bytes
-rw-r--r--include/jau/file_util.hpp6
-rw-r--r--src/file_util.cpp8
2 files changed, 13 insertions, 1 deletions
diff --git a/include/jau/file_util.hpp b/include/jau/file_util.hpp
index 14fa773..6fca78a 100644
--- a/include/jau/file_util.hpp
+++ b/include/jau/file_util.hpp
@@ -98,6 +98,9 @@ namespace jau {
std::string element_;
public:
+ dir_item() noexcept
+ : parent_dir_(), element_() {}
+
dir_item(std::string parent_dir__, std::string element__) noexcept
: parent_dir_(parent_dir__), element_(element__) {}
@@ -139,6 +142,9 @@ namespace jau {
int errno_res_;
public:
+ /** Instantiate an empty file_stats with fmode_bits::NOT_EXISTING set. */
+ file_stats() noexcept;
+
/**
* Instantiates a file_stats for the given `path`
* using either `::lstat()` (default) or `::stat()`.
diff --git a/src/file_util.cpp b/src/file_util.cpp
index 50db0da..6c513b9 100644
--- a/src/file_util.cpp
+++ b/src/file_util.cpp
@@ -96,6 +96,12 @@ std::string dir_item::path() const noexcept {
}
}
+file_stats::file_stats() noexcept
+: item_(), mode_(fmode_bits::NOT_EXISTING),
+ uid_(0), gid_(0), size_(0), atime_(), mtime_(), ctime_(),
+ errno_res_(0)
+{}
+
file_stats::file_stats(const dir_item& item, const bool use_lstat) noexcept
: item_(item), mode_(fmode_bits::NONE),
uid_(0), gid_(0), size_(0), atime_(), mtime_(), ctime_(),
@@ -149,7 +155,7 @@ std::string file_stats::to_string(const bool use_space) const noexcept {
std::string res( "file_stats['"+item_.path()+"', "+jau::fs::to_string(mode_) );
if( 0 == errno_res_ ) {
res.append( ", uid " ).append( std::to_string(uid_) ).append( ", gid " ).append( std::to_string(gid_) )
- .append( ", size " ).append( std::to_string( size_ ) )
+ .append( ", size " ).append( jau::to_decstring( size_ ) )
.append( ", atime " ).append( atime_.to_iso8601_string(use_space) )
.append( ", mtime " ).append( mtime_.to_iso8601_string(use_space) )
.append( ", ctime " ).append( ctime_.to_iso8601_string(use_space) );