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

Fix changing directory times #84

Closed GerardSmit closed 4 months ago

GerardSmit commented 4 months ago

This PR fixes the following methods when the path is a directory:

The current implementation uses File, which is invalid for directories. When you try to invoke the method with a directory path, you'll get the following exception (.NET 8 and .NET FX 4.8):

System.UnauthorizedAccessException
Access to the path 'C:\Sources\zio\src\Zio.Tests\bin\Debug\net472\TestCreateDirectory' is denied.

The XML documentation is not clear whether this should be supported or not. In the summary it says changing the file time:

https://github.com/xoofx/zio/blob/ae0b1ca58e0d59de1bd530fe4261a9fcbbb757c2/src/Zio/IFileSystem.cs#L131-L133

But in the path-param it's saying it accepts files and directories:

https://github.com/xoofx/zio/blob/ae0b1ca58e0d59de1bd530fe4261a9fcbbb757c2/src/Zio/IFileSystem.cs#L134

If we decide to merge this PR, should we change the XML documentation summary, so it mentions directories as well?