5 releases
0.1.4 | Mar 17, 2023 |
---|---|
0.1.3 | Mar 16, 2023 |
0.1.2 | Mar 15, 2023 |
0.1.1 | Mar 15, 2023 |
0.1.0 | Mar 15, 2023 |
#965 in Filesystem
49 downloads per month
11KB
188 lines
with_dir
Blazingly fast utility library for temporarily changing the current working directory.
This library provides the following features:
- Convenient scoped changing of directories
- Global Reentrant mutex to prevent concurrent instances of WithDir from conflicting.
The mutex allows this to be safely used across multhreaded tests, where each test will be entering different directories as no two WithDir instances can exist on different threads. However nested instances on the same thread can exist.
use with_dir::WithDir;
use std::path::Path;
let path = Path::new("src");
// enter that directory
WithDir::new(path).map(|_| {
// Current working directory is now src
}).unwrap();
// cwd is reset
Contributing
Contributions welcome.
FAQ
Is it good?
yes.
License
See LICENSE
lib.rs
:
Library provides the struct WithDir which uses RAII to enable scoped change of working directory. See docs for WithDir for simple example.
Dependencies
~2–10MB
~123K SLoC