Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a RelativePath class? #6

Open
LourensVeen opened this issue Jan 6, 2019 · 0 comments
Open

Add a RelativePath class? #6

LourensVeen opened this issue Jan 6, 2019 · 0 comments

Comments

@LourensVeen
Copy link
Contributor

Currently in cerulean, paths are always absolute. That's a good thing, because a current working directory is a bit of a tricky concept when you're dealing with remote file systems and network errors and such. However, we sometimes need relative paths, like in a recursive copy of a directory, where we need to obtain the relative path of a file inside the tree to be copied with respect to the root, so we can rebase it on the target directory to get an absolute path to copy the file to.

The chrono library in C++ has time_point and duration classes. A time_point is an absolute point in time, while a duration is the difference between two time_points. So you can add a duration to a time_point to get another time_point, or subtract it, or add two durations to get another duration. This concept seems like a good solution here.

So let's add a cerulean.RelativePath here. A RelativePath is abstract, and it's not associated with a FileSystem like a normal Path. RelativePaths can be concatenated using / to form a new RelativePath, and you can write path / relative_path to get a Path containing the concatenation.

A RelativePath is pure, which means you cannot access files through it. Which methods should it have? Some subset of PurePosixPath? TBD...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant