Skip to content
This repository was archived by the owner on Aug 20, 2021. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,20 @@ This sample method does the following:
5. Close the directory, deleting the contents in the process.

```rust
fn write_temp_folder_with_files() -> Result<(), io::Error> {
if let Ok(dir) = TempDir::new("my_directory_prefix") {
let file_path = dir.path().join("foo.txt");
println!("{:?}", file_path);

let mut f = File::create(file_path)?;
f.write_all(b"Hello, world!")?;
f.sync_all()?;
dir.close()?;
}
use std::io::{self, Write};
use std::fs::File;
use tempdir::TempDir;

fn write_temp_folder_with_files() -> io::Result<()> {
let dir = TempDir::new("my_directory_prefix")?;
let file_path = dir.path().join("foo.txt");
println!("{:?}", file_path);

let mut f = File::create(file_path)?;
f.write_all(b"Hello, world!")?;
f.sync_all()?;
dir.close()?;

Ok(())
}
```
Expand Down