Ready to test Windows Project

This commit is contained in:
2025-02-16 21:30:17 -07:00
parent 039355f31e
commit 3ea4926f5e
33 changed files with 1226 additions and 205 deletions

View File

@ -21,29 +21,44 @@ public record FileHolder(DateTime? CreationTime,
return result;
}
private static FileHolder GetExisting(NginxFileSystem nginxFileSystem, int? id) =>
new(CreationTime: nginxFileSystem.LastModified,
DirectoryFullPath: Path.GetDirectoryName(nginxFileSystem.URI?.OriginalString ?? throw new Exception()),
Exists: true,
ExtensionLowered: Path.GetExtension(nginxFileSystem.Name).ToLower(),
FullName: nginxFileSystem.URI?.OriginalString ?? throw new Exception(),
Id: id,
LastWriteTime: nginxFileSystem.LastModified,
Length: nginxFileSystem.Length is null ? null : (long)nginxFileSystem.Length.Value,
Name: nginxFileSystem.Name,
NameWithoutExtension: Path.GetFileNameWithoutExtension(nginxFileSystem.Name));
public static FileHolder Get(NginxFileSystem nginxFileSystem) =>
GetExisting(nginxFileSystem, id: null);
private static FileHolder GetExisting(FileInfo fileInfo, int? id) =>
new(fileInfo.CreationTime,
fileInfo.DirectoryName,
fileInfo.Exists,
fileInfo.Extension.ToLower(),
fileInfo.FullName,
id,
fileInfo.LastWriteTime,
fileInfo.Length,
fileInfo.Name,
Path.GetFileNameWithoutExtension(fileInfo.FullName));
new(CreationTime: fileInfo.CreationTime,
DirectoryFullPath: fileInfo.DirectoryName,
Exists: fileInfo.Exists,
ExtensionLowered: fileInfo.Extension.ToLower(),
FullName: fileInfo.FullName,
Id: id,
LastWriteTime: fileInfo.LastWriteTime,
Length: fileInfo.Length,
Name: fileInfo.Name,
NameWithoutExtension: Path.GetFileNameWithoutExtension(fileInfo.FullName));
private static FileHolder GetNonExisting(FileInfo fileInfo, int? id) =>
new(null,
fileInfo.DirectoryName,
fileInfo.Exists,
fileInfo.Extension.ToLower(),
fileInfo.FullName,
id,
null,
null,
fileInfo.Name,
Path.GetFileNameWithoutExtension(fileInfo.FullName));
new(CreationTime: null,
DirectoryFullPath: fileInfo.DirectoryName,
Exists: fileInfo.Exists,
ExtensionLowered: fileInfo.Extension.ToLower(),
FullName: fileInfo.FullName,
Id: id,
LastWriteTime: null,
Length: null,
Name: fileInfo.Name,
NameWithoutExtension: Path.GetFileNameWithoutExtension(fileInfo.FullName));
public static FileHolder Get(FileInfo fileInfo, int? id) =>
fileInfo.Exists ? GetExisting(fileInfo, id) : GetNonExisting(fileInfo, id);
@ -52,42 +67,42 @@ public record FileHolder(DateTime? CreationTime,
{
FileHolder result;
DateTime dateTime = new(filePath.CreationTicks);
result = new(dateTime,
filePath.DirectoryFullPath,
true,
filePath.ExtensionLowered,
filePath.FullName,
id,
new(filePath.LastWriteTicks),
filePath.Length,
filePath.Name,
Path.GetFileNameWithoutExtension(filePath.FullName));
result = new(CreationTime: dateTime,
DirectoryFullPath: filePath.DirectoryFullPath,
Exists: true,
ExtensionLowered: filePath.ExtensionLowered,
FullName: filePath.FullName,
Id: id,
LastWriteTime: new(filePath.LastWriteTicks),
Length: filePath.Length,
Name: filePath.Name,
NameWithoutExtension: Path.GetFileNameWithoutExtension(filePath.FullName));
return result;
}
private static FileHolder GetExisting(FileHolder fileHolder) =>
new(fileHolder.CreationTime,
fileHolder.DirectoryFullPath,
fileHolder.Exists,
fileHolder.ExtensionLowered,
fileHolder.FullName,
new(CreationTime: fileHolder.CreationTime,
DirectoryFullPath: fileHolder.DirectoryFullPath,
Exists: fileHolder.Exists,
ExtensionLowered: fileHolder.ExtensionLowered,
FullName: fileHolder.FullName,
Id: null,
fileHolder.LastWriteTime,
fileHolder.Length,
fileHolder.Name,
Path.GetFileNameWithoutExtension(fileHolder.FullName));
LastWriteTime: fileHolder.LastWriteTime,
Length: fileHolder.Length,
Name: fileHolder.Name,
NameWithoutExtension: Path.GetFileNameWithoutExtension(fileHolder.FullName));
private static FileHolder GetNonExisting(FileHolder fileHolder) =>
new(null,
fileHolder.DirectoryFullPath,
fileHolder.Exists,
fileHolder.ExtensionLowered,
fileHolder.FullName,
new(CreationTime: null,
DirectoryFullPath: fileHolder.DirectoryFullPath,
Exists: fileHolder.Exists,
ExtensionLowered: fileHolder.ExtensionLowered,
FullName: fileHolder.FullName,
Id: null,
null,
null,
fileHolder.Name,
Path.GetFileNameWithoutExtension(fileHolder.FullName));
LastWriteTime: null,
Length: null,
Name: fileHolder.Name,
NameWithoutExtension: Path.GetFileNameWithoutExtension(fileHolder.FullName));
public static FileHolder Get(FileHolder fileHolder) =>
fileHolder.Exists ? GetExisting(fileHolder) : GetNonExisting(fileHolder);