Vendor dependencies
Let's see how I like this workflow.
This commit is contained in:
parent
34d1830413
commit
9c435dc440
7500 changed files with 1665121 additions and 99 deletions
62
vendor/tempdir/README.md
vendored
Normal file
62
vendor/tempdir/README.md
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
tempdir
|
||||
=======
|
||||
|
||||
A Rust library for creating a temporary directory and deleting its entire
|
||||
contents when the directory is dropped.
|
||||
|
||||
[](https://travis-ci.org/rust-lang-nursery/tempdir)
|
||||
[](https://ci.appveyor.com/project/rust-lang-libs/tempdir/branch/master)
|
||||
|
||||
[Documentation](https://doc.rust-lang.org/tempdir)
|
||||
|
||||
## Deprecation Note
|
||||
|
||||
The `tempdir` crate is being merged into [`tempfile`](https://github.com/Stebalien/tempfile). Please see [this issue](https://github.com/Stebalien/tempfile/issues/43) to track progress and direct new issues and pull requests to `tempfile`.
|
||||
|
||||
## Usage
|
||||
|
||||
Add this to your `Cargo.toml`:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
tempdir = "0.3"
|
||||
```
|
||||
|
||||
and this to your crate root:
|
||||
|
||||
```rust
|
||||
extern crate tempdir;
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
This sample method does the following:
|
||||
|
||||
1. Create a temporary directory in the default location with the given prefix.
|
||||
2. Determine a file path in the directory and print it out.
|
||||
3. Create a file inside the temp folder.
|
||||
4. Write to the file and sync it to disk.
|
||||
5. Close the directory, deleting the contents in the process.
|
||||
|
||||
```rust
|
||||
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(())
|
||||
}
|
||||
```
|
||||
|
||||
**Note:** Closing the directory is actually optional, as it would be done on
|
||||
drop. The benefit of closing here is that it allows possible errors to be
|
||||
handled.
|
||||
Loading…
Add table
Add a link
Reference in a new issue