thepath 0.0.1

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.expandTilde.toAbsolute().toString());
    }
}
Authors:
  • Dmytro Katyukha
Dependencies:
none
Versions:
1.1.0 2023-Nov-04
1.0.0 2023-Oct-03
0.1.8 2023-Jul-26
0.1.7 2023-Jun-18
0.1.6 2023-Jun-16
Show all 35 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 2 downloads this month

  • 3416 downloads total

Score:
0.2
Short URL:
thepath.dub.pm