xoofx / zio

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

UPath failures on windows (must be absolute) with Subsystem #40

Closed LimpingNinja closed 5 years ago

LimpingNinja commented 5 years ago

I'm using a physical file system and a subsystem and if I'm using OSX it works perfectly fine, but on Windows it fails with 'Path 'c:/path/here' must be absolute'

var path = "c:/path/here/" fs = new PhysicalFileSystem(); subfs = new SubFileSystem(fs, path);

This also fails on slower 'C:\path\here\'

I thought it was the trailing slash removal until I followed and noted that AssertAbsolute throws even with the trailing slash since the path does not start with / but c:/

LimpingNinja commented 5 years ago

'/mnt/c/path/here'

Also does not work, I see the documentation say that this typically does but I'm not sure why unless you were specifically running it under WSL which doesn't seem correct for x-platform. Looks like the assumptions made for this specifically tie across the library.

GerardSmit commented 5 years ago

I'm using a physical file system and a subsystem and if I'm using OSX it works perfectly fine, but on Windows it fails with 'Path 'c:/path/here' must be absolute'

This is by design. The README says the following:

With uniform paths, this filesystem on Windows is working like on a Windows Subsystem Linux

Note the word "like", it doesn't say Zio does this only on WSL. You always use the unix path-style, even on Windows.

'/mnt/c/path/here'
Also does not work, I see the documentation say that this typically does but I'm not sure why unless you were specifically running it under WSL which doesn't seem correct for x-platform. Looks like the assumptions made for this specifically tie across the library.

Do you get an exception? Does the program has access to the folder?

When I tried the latest version on .NET Core 2.2.5 (x64) it's working fine:

image

LimpingNinja commented 5 years ago

This is by design. The README says the following

Yes, I cited that in my update; that's my fault.

Do you get an exception? Does the program has access to the folder?

It has access, but ultimately it appeared to be my fault here - sorry for the false message; I somehow missed a directory exist call that was using standard filesystem check vs. the Zio check.

OlivierLePichon commented 7 months ago

Facing with exactly same problem on Windows.

I understand I must use a subPath formatted as "/mnt/c/path/here" to SubFileSystem ctor but my question is:

Is there a simple way to convert "c:\path\here\" to "/mnt/c/path/here"?

xoofx commented 7 months ago

Is there a simple way to convert "c:\path\here\" to "/mnt/c/path/here"?

https://github.com/xoofx/zio/blob/a563d0c58ff7b816ce9fe9783ad1df40e35ab923/src/Zio/IFileSystem.cs#L225

fs.ConvertPathFromInternal("/mnt/c/path/here") should do it assuming that fs is a PhysicalFileSystem

OlivierLePichon commented 7 months ago

Thanks! In my case, fs.ConvertPathFromInternal("c:\path\here\") produce exactly what I was expected: "/mnt/c/path/here"