Crates.io | mktemp-rs |
lib.rs | mktemp-rs |
version | 0.2.0 |
source | src |
created_at | 2018-12-19 18:38:13.327496 |
updated_at | 2018-12-22 19:51:55.767804 |
description | A thin wrapper around libc's mkstemps and mkdtemp |
homepage | |
repository | https://github.com/owenthewizard/mktemp-rs |
max_upload_size | |
id | 102780 |
size | 24,702 |
A thin wrapper around libc
's mkstemps
and mkdtemp
.
Cargo.toml
:
name = "my-awesome-project"
version = "0.1.0"
authors = ["me"]
[dependencies]
+mktemp-rs = "0.1.0"
main.rs
:
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.
readme
tests the example in this readme.
temp_dir
tests various TempDir functions.
temp_file
tests various TempFile functions.
Obey rustfmt
and Rust 2018 conventions.
Pull requests are always welcome. See TODO.
This project adheres to Semantic Versioning.
Changes are documented in the Changelog.
See the tags on this repository for available releases.
mktemp-rs
is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See LICENSE-APACHE and LICENSE-MIT for details.