From 460bb6609a61ee1283a4f23e81e91e857f30f319 Mon Sep 17 00:00:00 2001 From: Michiel Oda Date: Tue, 8 Jul 2025 13:24:45 +0200 Subject: [PATCH 1/3] Extending File with GetXTime methods - File.GetCreationTime(path) - File.GetCreationTimeUtc(path) - File.GetLastWriteTime(path) - File.GetLastWriteTimeUtc(path) - File.GetLastAccessTime(path) - File.GetLastAccessTimeUtc(path) --- FileSystem/FileIOLinux.cs | 30 ++++++++++++++++++++++++++++++ FileSystem/FileIOWin.cs | 30 ++++++++++++++++++++++++++++++ FileSystem/IFileIO.cs | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) diff --git a/FileSystem/FileIOLinux.cs b/FileSystem/FileIOLinux.cs index 7d5154f..2f33619 100644 --- a/FileSystem/FileIOLinux.cs +++ b/FileSystem/FileIOLinux.cs @@ -208,6 +208,36 @@ public FileAttributes GetAttributes(string path) return File.GetAttributes(path); } + public DateTime GetCreationTime(string path) + { + return File.GetCreationTime(path); + } + + public DateTime GetCreationTimeUtc(string path) + { + return File.GetCreationTimeUtc(path); + } + + public DateTime GetLastWriteTime(string path) + { + return File.GetLastWriteTime(path); + } + + public DateTime GetLastWriteTimeUtc(string path) + { + return File.GetLastWriteTimeUtc(path); + } + + public DateTime GetLastAccessTime(string path) + { + return File.GetLastAccessTime(path); + } + + public DateTime GetLastAccessTimeUtc(string path) + { + return File.GetLastAccessTimeUtc(path); + } + private static bool TryAllowWritesOnFile(string path) { try diff --git a/FileSystem/FileIOWin.cs b/FileSystem/FileIOWin.cs index cf86d38..f19c683 100644 --- a/FileSystem/FileIOWin.cs +++ b/FileSystem/FileIOWin.cs @@ -208,6 +208,36 @@ public System.IO.FileAttributes GetAttributes(string path) return File.GetAttributes(path); } + public DateTime GetCreationTime(string path) + { + return File.GetCreationTime(path); + } + + public DateTime GetCreationTimeUtc(string path) + { + return File.GetCreationTimeUtc(path); + } + + public DateTime GetLastWriteTime(string path) + { + return File.GetLastWriteTime(path); + } + + public DateTime GetLastWriteTimeUtc(string path) + { + return File.GetLastWriteTimeUtc(path); + } + + public DateTime GetLastAccessTime(string path) + { + return File.GetLastAccessTime(path); + } + + public DateTime GetLastAccessTimeUtc(string path) + { + return File.GetLastAccessTimeUtc(path); + } + private static bool TryAllowWritesOnFile(string path) { try diff --git a/FileSystem/IFileIO.cs b/FileSystem/IFileIO.cs index ea4053b..f4dbea1 100644 --- a/FileSystem/IFileIO.cs +++ b/FileSystem/IFileIO.cs @@ -1,6 +1,8 @@ namespace Skyline.DataMiner.CICD.FileSystem { + using System; using System.Text; + using Microsoft.Win32.SafeHandles; /// Provides static methods for the creation, copying, deletion, moving, and opening of a single file, and aids in the creation of objects. public interface IFileIO @@ -279,5 +281,35 @@ public interface IFileIO /// The path to the file. /// The of the file on the path. System.IO.FileAttributes GetAttributes(string path); + + /// Gets the creation date and time of the specified file. + /// A structure set to the creation date and time for the specified file. This value is expressed in local time. + /// The file for which to obtain creation date and time information. + DateTime GetCreationTime(string path); + + /// Gets the creation date and time, in Coordinated Universal Time (UTC) format, of the specified file. + /// A structure set to the creation date and time for the specified file. This value is expressed in UTC time. + /// The file for which to obtain creation date and time information, in Coordinated Universal Time (UTC) format. + DateTime GetCreationTimeUtc(string path); + + /// Gets the date and time that the specified file was last written to. + /// The file for which to obtain write date and time information. + /// A structure set to the date and time that the specified file was last written to. This value is expressed in local time. + DateTime GetLastWriteTime(string path); + + /// Gets the date and time, in coordinated universal time (UTC) time, that the specified file was last written to. + /// The file for which to obtain write date and time information. + /// A structure set to the date and time that the specified file was last written to. This value is expressed in UTC time. + DateTime GetLastWriteTimeUtc(string path); + + /// Gets the date and time that the specified file was last accessed. + /// The file for which to obtain access date and time information. + /// A structure set to the date and time that the specified file was last accessed. This value is expressed in local time. + DateTime GetLastAccessTime(string path); + + /// Gets the date and time, in coordinated universal time (UTC), that the specified file was last accessed. + /// The file for which to obtain access date and time information. + /// A structure set to the date and time that the specified file was last accessed. This value is expressed in UTC time. + DateTime GetLastAccessTimeUtc(string path); } } \ No newline at end of file From 5da597ece419a4645cab6ffe9f695331ba39978b Mon Sep 17 00:00:00 2001 From: Michiel Oda Date: Wed, 23 Jul 2025 11:32:11 +0200 Subject: [PATCH 2/3] Try to fix permission issue --- FileSystem/FileIOWin.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/FileSystem/FileIOWin.cs b/FileSystem/FileIOWin.cs index f19c683..3178ba7 100644 --- a/FileSystem/FileIOWin.cs +++ b/FileSystem/FileIOWin.cs @@ -185,6 +185,8 @@ public void Copy(string sourcePath, string destinationPath) public void Copy(string sourcePath, string destinationPath, bool overwrite) { + TryAllowWritesOnFile(sourcePath); + TryAllowWritesOnFile(destinationPath); File.Copy(sourcePath, destinationPath, overwrite); } From 543c2ab7a0d44d2488324ac6ec6a3d150ceb8cfc Mon Sep 17 00:00:00 2001 From: Michiel Oda Date: Tue, 5 Aug 2025 10:52:50 +0200 Subject: [PATCH 3/3] Remove unused using --- FileSystem/IFileIO.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/FileSystem/IFileIO.cs b/FileSystem/IFileIO.cs index f4dbea1..dd98f12 100644 --- a/FileSystem/IFileIO.cs +++ b/FileSystem/IFileIO.cs @@ -2,7 +2,6 @@ { using System; using System.Text; - using Microsoft.Win32.SafeHandles; /// Provides static methods for the creation, copying, deletion, moving, and opening of a single file, and aids in the creation of objects. public interface IFileIO