Skip to content

Change Path into a wrapper around java.nio.file.Path? #346

@lihaoyi

Description

@lihaoyi

We could preserve the type-level distinction between Path and RelPath, as well as the nice superficial syntax and API. But there are things in nio.file.Path that I want:

This would be a non-trivial philosophical change that would change Paths from a transparent struct into an opaque type. Or at very least contain a pointer to an opaque type, the java.nio.file.FileSystem.

In general, the variables holding the Root and Filesystem have to live on the paths if we want to be able to perform operations that span multiple Roots or Filesystems, which we probably do. In the simplest case, Windows users would need to move files between drives.

This is impossible if you store the Root and Filesystem anywhere else, e.g. on the operations (e.g. D_drive.cp, C_drive.rm) because you won't be able to refer to paths on multiple drives in one operation.

This would also make it more awkward to use (abuse?) Path and RelPath for other non-filesystem usages. That could be considered a good thing. I've done this and it always proves to be confusing. Better to define a separate non-ammonite Path and have the types keep you straight

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions