@@ -95,6 +95,7 @@ impl FileObject {
|
||||
/// Create a new file object (day 2) and write the file to the disk (day 4).
|
||||
pub fn create(path: &Path, data: Vec<u8>) -> Result<Self> {
|
||||
std::fs::write(path, &data)?;
|
||||
File::open(path)?.sync_all()?;
|
||||
Ok(FileObject(
|
||||
Some(File::options().read(true).write(false).open(path)?),
|
||||
data.len() as u64,
|
||||
|
||||
Reference in New Issue
Block a user