Created
August 30, 2015 16:03
-
-
Save octplane/cc39bb26c0c6d445e317 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::Write; | |
use std::fs::OpenOptions; | |
use std::path::{ Path}; | |
use std::thread; | |
fn main() { | |
let dst = Path::new("./test.txt"); | |
let mut file = OpenOptions::new().write(true).create(true).open(dst).unwrap(); | |
file.write_all(b"create").unwrap(); | |
file.flush().unwrap(); | |
drop(file); | |
thread::sleep_ms(1000); // Wait a while after create above before observing. | |
let mut file2 = OpenOptions::new().write(true).append(true).open(dst).unwrap(); | |
file2.write_all(b"foo").unwrap(); | |
file2.flush().unwrap(); | |
drop(file2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment