Skip to content

Commit

Permalink
add move ctor and const ref metadata getter
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaboud committed Oct 12, 2021
1 parent 3f2a9ad commit e36cdd0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/impl/autotierfs/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ File::File(const File &other)
, db_(other.db_)
, metadata_(other.metadata_) {}

File::File(File &&other)
: size_(std::move(other.size_))
, tier_ptr_(std::move(other.tier_ptr_))
, times_{ std::move(other.times_[0]), std::move(other.times_[1]) }
, atime_(std::move(other.atime_))
, ctime_(std::move(other.ctime_))
, relative_path_(std::move(other.relative_path_))
, db_(std::move(other.db_))
, metadata_(std::move(other.metadata_)) {}

File::~File() {}

void File::update_db() {
Expand Down Expand Up @@ -138,3 +148,8 @@ void File::change_path(const fs::path &new_path) {
metadata_.update(new_path.string(), db_, &old_path);
relative_path_ = new_path;
}


const Metadata &File::metadata(void) const {
return metadata_;
}
12 changes: 12 additions & 0 deletions src/incl/file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ class File {
* @param other
*/
File(const File &other);
/**
* @brief Move cnstruct a new File object
*
* @param other
*/
File(File &&other);
/**
* @brief Destroy the File object
* Calls metadata.update(relative_path_.c_str(), db_)
Expand Down Expand Up @@ -143,6 +149,12 @@ class File {
* @param new_path
*/
void change_path(const fs::path &new_path);
/**
* @brief Return const reference to metadata_
*
* @return const Metadata&
*/
const Metadata &metadata(void) const;
private:
ffd::Bytes size_; ///< Size of file on disk
Tier *tier_ptr_; ///< Pointer to Tier object representing the tier containing this file.
Expand Down

0 comments on commit e36cdd0

Please sign in to comment.