thepath 0.0.2
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.
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());
}
}
- Registered by Dmytro Katyukha
- 0.0.2 released 2 years ago
- katyukha/thepath
- MPL-2.0
- Copyright © 2022, Dmytro Katyukha
- Authors:
- Dependencies:
- none
- Versions:
-
1.2.0 2024-May-15 1.1.0 2023-Nov-04 1.0.0 2023-Oct-03 0.1.8 2023-Jul-26 0.1.7 2023-Jun-18 - Download Stats:
-
-
0 downloads today
-
90 downloads this week
-
90 downloads this month
-
3506 downloads total
-
- Score:
- 1.6
- Short URL:
- thepath.dub.pm