https://github.com/owenthewizard/mktemp-rs
A thin wrapper around libc's mkstemps and mkdtemp
https://github.com/owenthewizard/mktemp-rs
mkstemp rust rust-library temp tempdir tempfile
Last synced: 6 months ago
JSON representation
A thin wrapper around libc's mkstemps and mkdtemp
- Host: GitHub
- URL: https://github.com/owenthewizard/mktemp-rs
- Owner: owenthewizard
- License: other
- Created: 2018-12-19T10:12:00.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-04-15T03:50:55.000Z (about 6 years ago)
- Last Synced: 2024-11-17T01:18:41.296Z (7 months ago)
- Topics: mkstemp, rust, rust-library, temp, tempdir, tempfile
- Language: Rust
- Size: 19.5 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE.md
Awesome Lists containing this project
README
# mktemp-rs
A thin wrapper around `libc`'s `mkstemps` and `mkdtemp`.
## Quick Start ([Documentation](https://docs.rs/mktemp-rs))
`Cargo.toml`:
```diff
name = "my-awesome-project"
version = "0.1.0"
authors = ["me"][dependencies]
+mktemp-rs = "0.1.0"
````main.rs`:
```rust
use std::fs;
use std::io::{Seek, SeekFrom, Read, Write};
use mktemp::TempFile;fn readme() {
let path;
{
let mut tf = TempFile::new("my-temp-file-", ".txt").expect("Failed to create tempfile");
let mut buf = [0u8; 12];
tf.write(b"Hello world!").expect("Failed to write to tempfile");
tf.seek(SeekFrom::Start(0)).expect("Failed to seek in tempfile");
tf.read(&mut buf).expect("Failed to read tempfile");
assert_eq!(&buf, b"Hello world!");
path = tf.path().to_string();
}
assert!(fs::metadata(&path).is_err());
}
````mktemp-rs` currently only support Unix platforms. As always, pull requests are welcome.
### Tests
[`readme`](tests/readme.rs) tests the example in this readme.
[`temp_dir`](tests/temp_dir.rs) tests various TempDir functions.
[`temp_file`](tests/temp_file.rs) tests various TempFile functions.
### Coding Style
Obey `rustfmt` and Rust 2018 conventions.
## Contributing
Pull requests are always welcome. See [TODO](TODO.md).
## Versioning
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
Changes are documented in the [Changelog](CHANGELOG.md).
See the [tags on this repository](https://github.com/owenthewizard/mktemp-rs/tags) for available releases.
## Authors
See [the list of contributors](https://github.com/owenthewizard/mktemp-rs/contributors).
## License
`mktemp-rs` is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See [LICENSE-APACHE](LICENSE-APACHE.md) and [LICENSE-MIT](LICENSE-MIT.md) for details.
## Acknowledgments
* [mkstemp](https://gitlab.com/worr/mkstemp) by William Orr for inspiration and code base.