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

Fix bug on SubFileSystem.ConvertPathToDelegate #50

Closed
dohki opened this issue May 22, 2020 · 6 comments
Closed

Fix bug on SubFileSystem.ConvertPathToDelegate #50

dohki opened this issue May 22, 2020 · 6 comments

Comments

@dohki
Copy link

dohki commented May 22, 2020

It just prepends root path to the relative path without considering current working directory.

return SubPath / safePath;

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
Copy link
Owner

xoofx commented May 22, 2020

PR welcome.

@xoofx
Copy link
Owner

xoofx commented Jun 17, 2020

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
Copy link
Author

dohki commented Jan 18, 2021

protected override UPath ConvertPathToDelegate(UPath path)
{
var safePath = path.ToRelative();
return SubPath / safePath;
}

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
Copy link
Owner

xoofx commented Jan 19, 2021

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
Copy link
Author

dohki commented Jan 19, 2021

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.

public static UPath ToAbsolute(this UPath path)
{
path.AssertNotNull();
if (path.IsAbsolute)
{
return path;
}
return path.IsEmpty ? UPath.Root : UPath.Root / path;
}

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
Copy link
Owner

xoofx commented Jan 19, 2021

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.

@xoofx xoofx closed this as completed Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants