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:
0.0.1 2022-Sep-18
~master 2022-Sep-18
Show all 2 versions
Download Stats:
  • 0 downloads today

  • 1 downloads this week

  • 1 downloads this month

  • 4 downloads total

Score:
0.0
Short URL:
thepath.dub.pm