| 76 | }; |
| 77 | |
| 78 | struct Directory { |
| 79 | std::string name; |
| 80 | TimePoint mtime; |
| 81 | std::map<std::string, std::unique_ptr<Entry>> entries; |
| 82 | |
| 83 | Directory(std::string name, TimePoint mtime) : name(std::move(name)), mtime(mtime) {} |
| 84 | Directory(Directory&& other) noexcept |
| 85 | : name(std::move(other.name)), |
| 86 | mtime(other.mtime), |
| 87 | entries(std::move(other.entries)) {} |
| 88 | |
| 89 | Directory& operator=(Directory&& other) noexcept { |
| 90 | name = std::move(other.name); |
| 91 | mtime = other.mtime; |
| 92 | entries = std::move(other.entries); |
| 93 | return *this; |
| 94 | } |
| 95 | |
| 96 | Entry* Find(const std::string& s) { |
| 97 | auto it = entries.find(s); |
| 98 | if (it != entries.end()) { |
| 99 | return it->second.get(); |
| 100 | } else { |
| 101 | return nullptr; |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | bool CreateEntry(const std::string& s, std::unique_ptr<Entry> entry) { |
| 106 | DCHECK(!s.empty()); |
| 107 | auto p = entries.emplace(s, std::move(entry)); |
| 108 | return p.second; |
| 109 | } |
| 110 | |
| 111 | void AssignEntry(const std::string& s, std::unique_ptr<Entry> entry); |
| 112 | |
| 113 | bool DeleteEntry(const std::string& s) { return entries.erase(s) > 0; } |
| 114 | |
| 115 | private: |
| 116 | ARROW_DISALLOW_COPY_AND_ASSIGN(Directory); |
| 117 | }; |
| 118 | |
| 119 | // A filesystem entry |
| 120 | using EntryBase = std::variant<std::nullptr_t, File, Directory>; |