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 changing directory times #84

Merged
merged 1 commit into from
May 20, 2024
Merged

Conversation

GerardSmit
Copy link
Contributor

@GerardSmit GerardSmit commented May 15, 2024

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

  • SetCreationTime
  • SetLastAccessTime
  • SetLastWriteTime

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:

zio/src/Zio/IFileSystem.cs

Lines 131 to 133 in ae0b1ca

/// <summary>
/// Sets the date and time the file was created.
/// </summary>

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

/// <param name="path">The path to a file or directory for which to set the creation date and time.</param>

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

@xoofx xoofx merged commit c23f0a0 into xoofx:main May 20, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants