6 #ifndef TURI_FILEIO_FILE_OWNERSHIP_HANDLE_HPP 7 #define TURI_FILEIO_FILE_OWNERSHIP_HANDLE_HPP 11 #include <core/storage/fileio/fs_utils.hpp> 28 m_file = other.m_file;
29 other.m_file = std::string();
30 m_delete_on_destruction = other.m_delete_on_destruction;
31 m_recursive_deletion = other.m_recursive_deletion;
36 m_file = other.m_file;
37 other.m_file = std::string();
38 m_delete_on_destruction = other.m_delete_on_destruction;
39 m_recursive_deletion = other.m_recursive_deletion;
45 bool delete_on_destruction =
true,
46 bool recursive_deletion =
false) {
48 this->m_delete_on_destruction = delete_on_destruction;
49 this->m_recursive_deletion = recursive_deletion;
52 void delete_on_destruction() {
53 m_delete_on_destruction =
true;
56 void do_not_delete_on_destruction() {
57 m_delete_on_destruction =
false;
62 if (m_delete_on_destruction) {
64 if (!m_file.empty()) {
65 if (m_recursive_deletion) {
80 bool m_delete_on_destruction =
false;
81 bool m_recursive_deletion =
false;
file_ownership_handle(file_ownership_handle &&other)
move constructor
bool delete_path_recursive(const std::string &path)
bool delete_path_impl(const std::string &path, file_status status=file_status::FS_UNAVAILABLE)
file_ownership_handle(const std::string &file, bool delete_on_destruction=true, bool recursive_deletion=false)
construct from one file
~file_ownership_handle()
Destructor deletes the owned file if delete_on_destruction is true.
file_ownership_handle & operator=(file_ownership_handle &&other)
move assignment