Skip to content
This repository was archived by the owner on Feb 6, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/Warden.Watchers.Disk/FileInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Warden.Watchers.Disk
using System;

namespace Warden.Watchers.Disk
{
/// <summary>
/// Details of the performed file analysis.
Expand Down Expand Up @@ -40,8 +42,14 @@ public class FileInfo
/// </summary>
public string Directory { get; }

/// <summary>
/// File creation time in coordinated universal time (UTC).
/// </summary>
public DateTime CreationTimeUtc { get; }

protected FileInfo(string path, string name, string extension,
bool exists, long size, string partition, string directory)
bool exists, long size, string partition, string directory,
DateTime creationTimeUtc)
{
Path = path;
Name = name;
Expand All @@ -51,6 +59,7 @@ protected FileInfo(string path, string name, string extension,
Size = size;
Partition = partition;
Directory = directory;
CreationTimeUtc = creationTimeUtc;
}

/// <summary>
Expand All @@ -63,7 +72,7 @@ protected FileInfo(string path, string name, string extension,
/// <param name="directory">Full path of the directory in which the file exists e.g. D:\Images.</param>
/// <returns></returns>
public static FileInfo NotFound(string name, string path, string extension, string partition, string directory)
=> new FileInfo(name, path, extension, false, 0, partition, directory);
=> new FileInfo(name, path, extension, false, 0, partition, directory, new DateTime());

/// <summary>
///
Expand All @@ -74,9 +83,10 @@ public static FileInfo NotFound(string name, string path, string extension, stri
/// <param name="sizeBytes">Size in bytes.</param>
/// <param name="partition">Name of the directory in which the file exists e.g. D:\.</param>
/// <param name="directory">Full path of the directory in which the file exists e.g. D:\Images.</param>
/// <param name="creationTimeUtc">File creation time in coordinated universal time (UTC).</param>
/// <returns></returns>
public static FileInfo Create(string name, string path, string extension, long sizeBytes,
string partition, string directory)
=> new FileInfo(name, path, extension, true, sizeBytes, partition, directory);
string partition, string directory, DateTime creationTimeUtc)
=> new FileInfo(name, path, extension, true, sizeBytes, partition, directory, creationTimeUtc);
}
}
2 changes: 1 addition & 1 deletion src/Warden.Watchers.Disk/IDiskChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private FileInfo CheckFile(string file)
return FileInfo.NotFound(info.Name, info.FullName, info.Extension, partition, info.DirectoryName);

return FileInfo.Create(info.Name, info.FullName, info.Extension, info.Length, partition,
info.DirectoryName);
info.DirectoryName, info.CreationTimeUtc);
}
}
}