diff --git a/mediapipe/framework/formats/deleting_file.cc b/mediapipe/framework/formats/deleting_file.cc index b759a5f64..ce09d8746 100644 --- a/mediapipe/framework/formats/deleting_file.cc +++ b/mediapipe/framework/formats/deleting_file.cc @@ -17,10 +17,25 @@ #include +#include + #include "absl/log/absl_log.h" namespace mediapipe { +DeletingFile::DeletingFile(DeletingFile&& other) + : path_(std::move(other.path_)), + delete_on_destruction_(other.delete_on_destruction_) { + other.delete_on_destruction_ = false; +} + +DeletingFile& DeletingFile::operator=(DeletingFile&& other) { + path_ = std::move(other.path_); + delete_on_destruction_ = other.delete_on_destruction_; + other.delete_on_destruction_ = false; + return *this; +} + DeletingFile::DeletingFile(const std::string& path, bool delete_on_destruction) : path_(path), delete_on_destruction_(delete_on_destruction) {} diff --git a/mediapipe/framework/formats/deleting_file.h b/mediapipe/framework/formats/deleting_file.h index f38e3333b..695cba491 100644 --- a/mediapipe/framework/formats/deleting_file.h +++ b/mediapipe/framework/formats/deleting_file.h @@ -28,6 +28,11 @@ class DeletingFile { DeletingFile(const DeletingFile&) = delete; DeletingFile& operator=(const DeletingFile&) = delete; + // DeletingFile is movable. The moved-from object remains in valid but + // unspecified state and will not perform any operations on destruction. + DeletingFile(DeletingFile&& other); + DeletingFile& operator=(DeletingFile&& other); + // Provide the path to the file and whether the file should be deleted // when this object is destroyed. DeletingFile(const std::string& path, bool delete_on_destruction);