xoofx / zio

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

MemoryFileSystem.CreateDirectory fails at create "/" #61

Closed sebastienros closed 2 years ago

sebastienros commented 2 years ago

Like the standard System.IO API to create a directory, it processes all segments in the path. However when using something like fs.CreateDirectory("/a/b/c"); in Zio it will fail with System.UnauthorizedAccessException : Cannot create root directory '/'.

I would have expected it to ignore / since it already exists.

sebastienros commented 2 years ago

Apparently I made a mistake and it happens when calling CreateDirectory("/") specifically.

I am doing fs.CreateDirectory(path.GetDirectory()); and in this case the path was /index.html. I would still expect it not to throw.

xoofx commented 2 years ago

What type of fs is?

sebastienros commented 2 years ago

Happened with MemoryFileSystem.

xoofx commented 2 years ago

Yeah, it's a bug

xoofx commented 2 years ago

Fixed by commit f1e9350