rofinn / FilePaths.jl

A type based approach to working with filesystem paths in julia
Other
82 stars 14 forks source link

Add support for Windows network paths #32

Open jannefiluren opened 6 years ago

jannefiluren commented 6 years ago

FilePaths does not seem support Windows network paths at the moment (see this issue on the Julia vs code extension). They typically look like this \\data\... and I would like to add support for them in FilePaths. I would appriciate any hints on how I could do that, and what test I need to add.

rofinn commented 6 years ago

That seems like a great idea! The general plan I had was for folks to implement custom path types in their own packages (e.g., WNPaths.jl, S3Paths.jl, NFSPaths.jl) and just depend on FilePathsBase.jl which I'm hoping will be julia stdlib one day. This will allow other packages to just depend on FilePathsBase.jl and WNPaths.jl without needing FilePaths.jl or its interop dependencies.

As a starting point, I'd recommend looking at the following files for how you might want to define your subtype:

  1. paths.jl - Defines most of the AbstractPath API.
  2. posix.jl - Implements the required AbstractPath interface to allow the rest of the API to work.

If you have any questions or concerns about the AbstractPath interface please file an issue on FilePathsBase.jl.

jannefiluren commented 6 years ago

Thanks for your reply. I have been looking at the code for a bit right now. I have very little experience with paths overall though, and I am a poor Julia programmer, so apologies for that first.

Should I add a new type, similar to WindowsPath, called for example WindowNetworkPath? Should this type even be a subtype of WindowsPath?

I guess that at this line of code, I would have to create a WindowsNetworkPath?

Am I on the right track at all?

rofinn commented 6 years ago

I would make WindowsNetworkPath (or UNCPath) a subtype of AbstractPath because WindowsPath is already a concrete type and I don't expect a lot of the WindowsPath methods to work for UNCPaths. I think that we'll want define a registration system for calling Path (or using the p_str macro) and having it automatically detect things like UNCPaths, but that shouldn't be necessary for you to get started.