Crates.io | chwd |
lib.rs | chwd |
version | 0.2.0 |
source | src |
created_at | 2020-07-07 18:34:09.991706 |
updated_at | 2020-07-07 20:45:00.074713 |
description | Temporarily change current working directory, switching back when finished. |
homepage | |
repository | https://github.com/GrumpyMetalGuy/chwd |
max_upload_size | |
id | 262362 |
size | 20,587 |
Rust library to temporarily change your cwd, then switch it back when you're done.
Call ChangeWorkingDirectory's change function to change the current working directory, assigning the result to a local temporary variable. Once this variable goes out of scope, the current working directory will change back to the directory that was in use at the time of object creation.
fn main()
{
{
let _dir_change = ChangeWorkingDirectory::change(&env::temp_dir())?;
// Do something in the temp dir
}
// _dir_change has gone out of scope, you will be back where you started.
}
Although this is a fairly simple library, if you can think of anything that could be done to improve it, please open an issue or submit a PR!
This project is licensed under