xoofx / zio

A cross-platform abstract/virtual filesystem framework with many built-ins filesystems for .NET
BSD 2-Clause "Simplified" License
806 stars 61 forks source link

Fix bug on SubFileSystem.ConvertPathToDelegate #50

Closed dohki closed 3 years ago

dohki commented 4 years ago

It just prepends root path to the relative path without considering current working directory. https://github.com/xoofx/zio/blob/d245c2c4297a2cf79c753d94e917a706eb4d7bdb/src/Zio/FileSystems/SubFileSystem.cs#L68

Can you implement this two features?

  1. Add member for current working directory to SubFileSystem
  2. Add method for changing the member mentioned in 1.

Thank you.

xoofx commented 4 years ago

PR welcome.

xoofx commented 4 years ago

path without considering current working directory.

Actually I don't understand the issue. Can you elaborate? What is a current directory in a sub file system?

dohki commented 3 years ago

https://github.com/xoofx/zio/blob/d245c2c4297a2cf79c753d94e917a706eb4d7bdb/src/Zio/FileSystems/SubFileSystem.cs#L65-L69 This implementation is fine when path is absolute. The problem happens when path is relative because it doesn't consider the current working directory. path.ToRelative won't affect relative path since itself is already an relative path and the result safePath will be directly appended to SubPath as if it were an absolute path.

xoofx commented 3 years ago

Again, I don't understand, there is no concept of current directory in Zio. SubPath is supposed to be an absolute folder. Could you give an example with what you are trying to do?

dohki commented 3 years ago

Relative path is literally the path relative to the current working directory. But, it seems Zio works like as if current working directory is root (e.g. /) as you said. https://github.com/xoofx/zio/blob/8026d37030d4011fec428226bf199ef47909e815/src/Zio/UPathExtensions.cs#L40-L50 Then, I'll be sure to pass only absolute path to ConvertPathToDelegate after prepending current working directory on relative path case if you don't want to introduce current working directory concept.

xoofx commented 3 years ago

if you don't want to introduce current working directory concept.

It can't. A current working directory is only relevant for a system wide current directory. In Zio, you can have multiple filesystems in // that don't share anything. So a current directory has no meaning.

Zio works only with absolute paths when accessing a filesystems.