Compare commits

1 Commits

Author SHA1 Message Date
fc4449f515 log-iso-information (Day-Helper-2025-06-28) 2025-06-29 14:25:54 -07:00
3 changed files with 97 additions and 0 deletions

6
.vscode/launch.json vendored
View File

@ -11,6 +11,12 @@
"preLaunchTask": "build", "preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/net8.0/win-x64/File-Folder-Helper.dll", "program": "${workspaceFolder}/bin/Debug/net8.0/win-x64/File-Folder-Helper.dll",
"args": [ "args": [
"s",
"X",
"F:/0-ISO-A",
"Day-Helper-2025-06-28",
"*.iso",
"F",
"s", "s",
"X", "X",
"D:/5-Other-Small", "D:/5-Other-Small",

View File

@ -0,0 +1,89 @@
using System.Collections.ObjectModel;
using DiscUtils.Iso9660;
using Microsoft.Extensions.Logging;
namespace File_Folder_Helper.ADO2025.PI6;
internal static partial class Helper20250628 {
private record Record(string Path,
long Size,
long Ticks);
internal static void LogIsoInformation(ILogger<Worker> logger, List<string> args) {
logger.LogInformation(args[0]);
logger.LogInformation(args[1]);
logger.LogInformation(args[2]);
string searchPattern = args[2];
string sourceDirectory = Path.GetFullPath(args[0].Split('~')[0]);
string[] searchPatternFiles = Directory.GetFiles(sourceDirectory, searchPattern, SearchOption.AllDirectories);
ReadOnlyCollection<Record> records = GetRecords(searchPatternFiles);
LogIsoInformation(logger, records, args[3]);
}
private static ReadOnlyCollection<Record> GetRecords(string[] searchPatternFiles) {
List<Record> results = [];
Record record;
string[] files;
FileInfo fileInfo;
foreach (string searchPatternFile in searchPatternFiles) {
fileInfo = new(searchPatternFile);
record = new(searchPatternFile, fileInfo.Length, fileInfo.LastWriteTime.Ticks);
results.Add(record);
}
return results.AsReadOnly();
}
private static string GetSizeWithSuffix(long value) {
string result;
int i = 0;
string[] SizeSuffixes = ["bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
if (value < 0) {
result = "-" + GetSizeWithSuffix(-value);
} else {
while (Math.Round(value / 1024f) >= 1) {
value /= 1024;
i++;
}
result = string.Format("{0:n1} {1}", value, SizeSuffixes[i]);
}
return result;
}
private static void LogIsoInformation(ILogger<Worker> logger, ReadOnlyCollection<Record> records, string letter) {
string size;
string[] files;
List<string> messages = [];
Record[] sorted = records.OrderBy(l => l.Ticks).ToArray();
string directory = Path.Combine(Environment.CurrentDirectory, ".vscode", "helper");
foreach (Record record in sorted) {
if (string.IsNullOrEmpty(record.Path)) {
using FileStream fileStream = File.OpenRead(record.Path);
CDReader reader = new(fileStream, true);
files = reader.GetFiles("", "*");
foreach (string _ in files) {
}
}
size = GetSizeWithSuffix(record.Size);
messages.Add($"#; {size}");
messages.Add($"#; {new DateTime(record.Ticks):yyyy-MM-dd HH:mm:ss.fff}");
messages.Add($"$driveLetter = \"{letter}:\"");
messages.Add($"$isoImg = \"{record.Path}\"");
messages.Add("$diskImg = Mount-DiskImage -ImagePath $isoImg -NoDriveLetter");
messages.Add("$volInfo = $diskImg | Get-Volume");
messages.Add("mountvol $driveLetter $volInfo.UniqueId");
messages.Add(string.Empty);
}
if (Directory.Exists(directory)) {
File.WriteAllText(Path.Combine(directory, ".lsv"), string.Join(Environment.NewLine, messages));
} else {
messages.Reverse();
foreach (string message in messages) {
logger.LogInformation(message);
}
}
}
}

View File

@ -171,6 +171,8 @@ internal static class HelperDay
ADO2025.PI6.Helper20250602.EquipmentAutomationFrameworkCellInstanceStateImageVerbIf(logger, args); ADO2025.PI6.Helper20250602.EquipmentAutomationFrameworkCellInstanceStateImageVerbIf(logger, args);
else if (args[1] == "Day-Helper-2025-06-18") else if (args[1] == "Day-Helper-2025-06-18")
ADO2025.PI6.Helper20250618.MoveAllButXOfEach(logger, args); ADO2025.PI6.Helper20250618.MoveAllButXOfEach(logger, args);
else if (args[1] == "Day-Helper-2025-06-28")
ADO2025.PI6.Helper20250628.LogIsoInformation(logger, args);
else else
throw new Exception(appSettings.Company); throw new Exception(appSettings.Company);
} }