summaryrefslogtreecommitdiff
path: root/src/devices/file.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/file.rs')
-rw-r--r--src/devices/file.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/devices/file.rs b/src/devices/file.rs
index 163c10d..d35acf9 100644
--- a/src/devices/file.rs
+++ b/src/devices/file.rs
@@ -53,10 +53,17 @@ impl FileDevice {
}
}
+ pub fn flush_entry(&mut self) {
+ if let Some((Entry::File(buffered_file), _)) = &mut self.entry {
+ buffered_file.flush();
+ }
+ }
+
pub fn close_entry(&mut self) {
self.open_buffer.clear();
self.move_buffer.clear();
self.name_buffer.clear();
+ self.flush_entry();
self.entry = None;
self.new_pointer = 0;
self.new_length = 0;
@@ -255,3 +262,9 @@ impl FileDevice {
}
}
}
+
+impl Drop for FileDevice {
+ fn drop(&mut self) {
+ self.close_entry();
+ }
+}