thepath 0.0.6
The Path - the easy way to work with paths and files in D
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
The Path
Yet another attempt to implement high-level object-oriented interface to manage path and files in D. Inspired by Python's pathlib and D port of pathlib but implementing it in different way.
NOTE: this is alpha version, and api is still subject for change
Following ideas used in this project
- Implement struct or class
Path
that have to represent single path to file or directory. - Any operation on path have to create new instance of
Path
, thus no implicit modification of Path allowed to avoid side effects. - Simplify naming for frequent operations (introducing new type for this allows to do it without name collisions).
- Automatic tilde expansion when needed (for example before file operations),
thus allowing to easily work with patth like
~/my/path
without any special work needed.
Warning: Currently this lib is not tested on Windows or other platforms. So, it surelly works on Posix (linux only), but possibly, it should work on other platforms too. If you want to help to make it crossplatform, then contact me ( the first thing needed to make it cross platform, is to set up CI to run automated tests on other platforms).
To Do
- [x] Override comparison operators
- [ ] Override operators join paths
- [ ] Implement alias this feature to make it easily convertible to string.
- Do we need this
- [ ] match pattern
- [ ] Add ability to work with extensions
- [ ] Add automated tests for Windows
Examples
import thepath;
Path app_dir = Path("~/.local/my-app");
Path catalog_dir = app_dir.join("catalog");
void init() {
if (!app_dir.exists) {
app_dir.mkdir(true); // create recursive
}
if (!catalog_dir.exists) {
catalog_dir.mkdir(true);
}
}
void list_dir {
fopeach(Path p; catalog_dir.walk(SpanModel.breadth)) {
writeln(p.toAbsolute().toString());
}
}
For more example, check the documentation.
License
This library is licensed under MPL-2.0 license
- Registered by Dmytro Katyukha
- 0.0.6 released 3 years ago
- katyukha/thepath
- MPL-2.0
- Copyright © 2022, Dmytro Katyukha
- Authors:
- Dependencies:
- none
- Versions:
-
2.0.0 2024-Sep-10 1.2.0 2024-May-15 1.1.0 2023-Nov-04 1.0.0 2023-Oct-03 0.1.8 2023-Jul-26 - Download Stats:
-
-
0 downloads today
-
9 downloads this week
-
219 downloads this month
-
4303 downloads total
-
- Score:
- 2.6
- Short URL:
- thepath.dub.pm