Mirror.Length
This commit is contained in:
parent
f0d6fcab1b
commit
131d24882e
32
.vscode/launch.json
vendored
32
.vscode/launch.json
vendored
@ -174,6 +174,21 @@
|
|||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
"requireExactSource": false
|
"requireExactSource": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Mirror-Length",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "launch",
|
||||||
|
"preLaunchTask": "build",
|
||||||
|
"program": "${workspaceFolder}/Mirror-Length/bin/Debug/net7.0/win-x64/Mirror-Length.dll",
|
||||||
|
"args": [],
|
||||||
|
"env": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
},
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"console": "externalTerminal",
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"requireExactSource": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Move-By-Id",
|
"name": "Move-By-Id",
|
||||||
"type": "coreclr",
|
"type": "coreclr",
|
||||||
@ -259,23 +274,6 @@
|
|||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
"requireExactSource": false
|
"requireExactSource": false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "Save-Image-Info",
|
|
||||||
"type": "coreclr",
|
|
||||||
"request": "launch",
|
|
||||||
"preLaunchTask": "build",
|
|
||||||
"program": "${workspaceFolder}/Save-Image-Info/bin/Debug/net7.0/win-x64/Save-Image-Info.dll",
|
|
||||||
"args": [
|
|
||||||
"s"
|
|
||||||
],
|
|
||||||
"env": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
},
|
|
||||||
"cwd": "${workspaceFolder}",
|
|
||||||
"console": "externalTerminal",
|
|
||||||
"stopAtEntry": false,
|
|
||||||
"requireExactSource": false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "Set-Created-Date",
|
"name": "Set-Created-Date",
|
||||||
"type": "coreclr",
|
"type": "coreclr",
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<UserSecretsId>fa06c6db-0226-42ca-8728-68b1e336184d</UserSecretsId>
|
<UserSecretsId>fa06c6db-0226-42ca-8728-68b1e336184d</UserSecretsId>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PackageId>Phares.View.by.Distance.Save.Image.Info</PackageId>
|
<PackageId>Phares.View.by.Distance.Mirror.Length</PackageId>
|
||||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
||||||
<Version>7.0.101.1</Version>
|
<Version>7.0.101.1</Version>
|
||||||
<Authors>Mike Phares</Authors>
|
<Authors>Mike Phares</Authors>
|
141
Mirror-Length/MirrorLength.cs
Normal file
141
Mirror-Length/MirrorLength.cs
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Phares.Shared;
|
||||||
|
using Serilog;
|
||||||
|
using ShellProgressBar;
|
||||||
|
using View_by_Distance.Mirror.Length.Models;
|
||||||
|
using View_by_Distance.Shared.Models.Methods;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Mirror.Length;
|
||||||
|
|
||||||
|
public class MirrorLength
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly AppSettings _AppSettings;
|
||||||
|
private readonly string _WorkingDirectory;
|
||||||
|
private readonly Configuration _Configuration;
|
||||||
|
private readonly IsEnvironment _IsEnvironment;
|
||||||
|
private readonly IConfigurationRoot _ConfigurationRoot;
|
||||||
|
private readonly Property.Models.Configuration _PropertyConfiguration;
|
||||||
|
|
||||||
|
public MirrorLength(List<string> args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
|
||||||
|
{
|
||||||
|
if (isSilent)
|
||||||
|
{ }
|
||||||
|
if (console is null)
|
||||||
|
{ }
|
||||||
|
_AppSettings = appSettings;
|
||||||
|
_IsEnvironment = isEnvironment;
|
||||||
|
_WorkingDirectory = workingDirectory;
|
||||||
|
_ConfigurationRoot = configurationRoot;
|
||||||
|
ILogger? log = Log.ForContext<MirrorLength>();
|
||||||
|
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
|
||||||
|
Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
|
||||||
|
_PropertyConfiguration = propertyConfiguration;
|
||||||
|
_Configuration = configuration;
|
||||||
|
propertyConfiguration.Update();
|
||||||
|
log.Information(propertyConfiguration.RootDirectory);
|
||||||
|
Verify();
|
||||||
|
List<string> lines = MirrorLengthFilesInDirectories(log);
|
||||||
|
if (!lines.Any())
|
||||||
|
File.WriteAllLines($"D:/Tmp/Phares/{DateTime.Now.Ticks}.tsv", lines);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Verify()
|
||||||
|
{
|
||||||
|
if (_AppSettings is null)
|
||||||
|
{ }
|
||||||
|
if (_IsEnvironment is null)
|
||||||
|
{ }
|
||||||
|
if (_Configuration is null)
|
||||||
|
{ }
|
||||||
|
if (_ConfigurationRoot is null)
|
||||||
|
{ }
|
||||||
|
if (_WorkingDirectory is null)
|
||||||
|
{ }
|
||||||
|
if (_PropertyConfiguration is null)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<(string, string, DateTime, long)[]> GetToDoCollection(ProgressBar progressBar, List<string[]> filesCollection)
|
||||||
|
{
|
||||||
|
List<(string, string, DateTime, long)[]> results = new();
|
||||||
|
FileInfo fileInfo;
|
||||||
|
List<string> lines = new();
|
||||||
|
List<(string, string, DateTime, long)> collection;
|
||||||
|
foreach (string[] files in filesCollection)
|
||||||
|
{
|
||||||
|
lines.Clear();
|
||||||
|
progressBar.Tick();
|
||||||
|
collection = new();
|
||||||
|
foreach (string file in files)
|
||||||
|
{
|
||||||
|
if (file.EndsWith("len"))
|
||||||
|
continue;
|
||||||
|
fileInfo = new(file);
|
||||||
|
if (string.IsNullOrEmpty(fileInfo.DirectoryName))
|
||||||
|
continue;
|
||||||
|
collection.Add((fileInfo.DirectoryName, file, fileInfo.LastWriteTime, fileInfo.Length));
|
||||||
|
}
|
||||||
|
if (!collection.Any())
|
||||||
|
continue;
|
||||||
|
results.Add(collection.ToArray());
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Save(ProgressBar progressBar, List<(string directory, string file, DateTime lastWriteTime, long length)[]> results)
|
||||||
|
{
|
||||||
|
string checkFile;
|
||||||
|
string checkDirectory;
|
||||||
|
string? firstDirectory;
|
||||||
|
List<string> directories = new();
|
||||||
|
foreach ((string Directory, string, DateTime, long)[] collection in results)
|
||||||
|
{
|
||||||
|
progressBar.Tick();
|
||||||
|
directories.Clear();
|
||||||
|
firstDirectory = collection.First().Directory;
|
||||||
|
if (string.IsNullOrEmpty(firstDirectory))
|
||||||
|
continue;
|
||||||
|
checkDirectory = $"{_AppSettings.Destination}{firstDirectory[1..]}";
|
||||||
|
if (Directory.Exists(checkDirectory))
|
||||||
|
continue;
|
||||||
|
_ = Directory.CreateDirectory(checkDirectory);
|
||||||
|
foreach ((string directory, string _, DateTime _, long _) in collection)
|
||||||
|
{
|
||||||
|
checkDirectory = $"{_AppSettings.Destination}{directory[1..]}";
|
||||||
|
if (directories.Contains(checkDirectory))
|
||||||
|
continue;
|
||||||
|
directories.Add(checkDirectory);
|
||||||
|
if (!Directory.Exists(checkDirectory))
|
||||||
|
_ = Directory.CreateDirectory(checkDirectory);
|
||||||
|
}
|
||||||
|
foreach ((string _, string file, DateTime lastWriteTime, long length) in collection)
|
||||||
|
{
|
||||||
|
checkFile = $"{_AppSettings.Destination}{file[1..]}len";
|
||||||
|
if (!Shared.Models.Stateless.Methods.IPath.WriteAllText(checkFile, length.ToString(), updateToWhenMatches: null, compareBeforeWrite: true, updateDateWhenMatches: false))
|
||||||
|
continue;
|
||||||
|
File.SetLastWriteTime(checkFile, lastWriteTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<string> MirrorLengthFilesInDirectories(ILogger log)
|
||||||
|
{
|
||||||
|
List<string> results = new();
|
||||||
|
ProgressBar progressBar;
|
||||||
|
const string fileSearchFilter = "*";
|
||||||
|
string message = nameof(MirrorLength);
|
||||||
|
const string directorySearchFilter = "*";
|
||||||
|
List<string> distinctDirectories = new();
|
||||||
|
List<string[]> filesCollection = Shared.Models.Stateless.Methods.IDirectory.GetFilesCollection(_PropertyConfiguration.RootDirectory, directorySearchFilter, fileSearchFilter);
|
||||||
|
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
||||||
|
progressBar = new(filesCollection.Count, message, options);
|
||||||
|
List<(string, string, DateTime, long)[]> collection = GetToDoCollection(progressBar, filesCollection);
|
||||||
|
progressBar.Dispose();
|
||||||
|
progressBar = new(filesCollection.Count, message, options);
|
||||||
|
Save(progressBar, collection);
|
||||||
|
progressBar.Dispose();
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
17
Mirror-Length/Models/AppSettings.cs
Normal file
17
Mirror-Length/Models/AppSettings.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
namespace View_by_Distance.Mirror.Length.Models;
|
||||||
|
|
||||||
|
public record AppSettings(string Company,
|
||||||
|
char Destination,
|
||||||
|
int MaxDegreeOfParallelism,
|
||||||
|
string WorkingDirectoryName)
|
||||||
|
{
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,12 +1,13 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace View_by_Distance.Save.Image.Info.Models.Binder;
|
namespace View_by_Distance.Mirror.Length.Models.Binder;
|
||||||
|
|
||||||
public class AppSettings
|
public class AppSettings
|
||||||
{
|
{
|
||||||
|
|
||||||
public string? Company { get; set; }
|
public string? Company { get; set; }
|
||||||
|
public string? Destination { get; set; }
|
||||||
public int? MaxDegreeOfParallelism { get; set; }
|
public int? MaxDegreeOfParallelism { get; set; }
|
||||||
public string? WorkingDirectoryName { get; set; }
|
public string? WorkingDirectoryName { get; set; }
|
||||||
|
|
||||||
@ -21,12 +22,15 @@ public class AppSettings
|
|||||||
Models.AppSettings result;
|
Models.AppSettings result;
|
||||||
if (appSettings?.Company is null)
|
if (appSettings?.Company is null)
|
||||||
throw new NullReferenceException(nameof(appSettings.Company));
|
throw new NullReferenceException(nameof(appSettings.Company));
|
||||||
|
if (appSettings?.Destination is null || appSettings.Destination.Length != 1)
|
||||||
|
throw new NullReferenceException(nameof(appSettings.Destination));
|
||||||
if (appSettings?.MaxDegreeOfParallelism is null)
|
if (appSettings?.MaxDegreeOfParallelism is null)
|
||||||
throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism));
|
throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism));
|
||||||
if (appSettings?.WorkingDirectoryName is null)
|
if (appSettings?.WorkingDirectoryName is null)
|
||||||
throw new NullReferenceException(nameof(appSettings.WorkingDirectoryName));
|
throw new NullReferenceException(nameof(appSettings.WorkingDirectoryName));
|
||||||
result = new(
|
result = new(
|
||||||
appSettings.Company,
|
appSettings.Company,
|
||||||
|
appSettings.Destination.First(),
|
||||||
appSettings.MaxDegreeOfParallelism.Value,
|
appSettings.MaxDegreeOfParallelism.Value,
|
||||||
appSettings.WorkingDirectoryName
|
appSettings.WorkingDirectoryName
|
||||||
);
|
);
|
@ -3,7 +3,7 @@ using Phares.Shared;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace View_by_Distance.Save.Image.Info.Models.Binder;
|
namespace View_by_Distance.Mirror.Length.Models.Binder;
|
||||||
|
|
||||||
public class Configuration
|
public class Configuration
|
||||||
{
|
{
|
@ -1,7 +1,7 @@
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace View_by_Distance.Save.Image.Info.Models;
|
namespace View_by_Distance.Mirror.Length.Models;
|
||||||
|
|
||||||
public class Configuration
|
public class Configuration
|
||||||
{
|
{
|
@ -1,4 +1,4 @@
|
|||||||
namespace View_by_Distance.Save.Image.Info.Models.Stateless;
|
namespace View_by_Distance.Mirror.Length.Models.Stateless;
|
||||||
|
|
||||||
public static class SerilogExtensionMethods
|
public static class SerilogExtensionMethods
|
||||||
{
|
{
|
@ -3,10 +3,10 @@ using Phares.Shared;
|
|||||||
using Serilog;
|
using Serilog;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using View_by_Distance.Save.Image.Info.Models;
|
using View_by_Distance.Mirror.Length.Models;
|
||||||
using View_by_Distance.Shared.Models.Stateless.Methods;
|
using View_by_Distance.Shared.Models.Stateless.Methods;
|
||||||
|
|
||||||
namespace View_by_Distance.Save.Image.Info;
|
namespace View_by_Distance.Mirror.Length;
|
||||||
|
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
@ -41,7 +41,7 @@ public class Program
|
|||||||
if (args is null)
|
if (args is null)
|
||||||
throw new Exception("args is null!");
|
throw new Exception("args is null!");
|
||||||
Shared.Models.Console console = new();
|
Shared.Models.Console console = new();
|
||||||
_ = new SaveImageInfo(args, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
|
_ = new MirrorLength(args, isEnvironment, configurationRoot, appSettings, workingDirectory, silentIndex > -1, console);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"Company": "Mike Phares",
|
"Company": "Mike Phares",
|
||||||
|
"Destination": "L",
|
||||||
"Linux": {},
|
"Linux": {},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
@ -1,29 +0,0 @@
|
|||||||
using System.Text.Json;
|
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
|
|
||||||
namespace View_by_Distance.Save.Image.Info.Models;
|
|
||||||
|
|
||||||
public class AppSettings
|
|
||||||
{
|
|
||||||
|
|
||||||
public string Company { init; get; }
|
|
||||||
public int MaxDegreeOfParallelism { init; get; }
|
|
||||||
public string WorkingDirectoryName { init; get; }
|
|
||||||
|
|
||||||
[JsonConstructor]
|
|
||||||
public AppSettings(string company,
|
|
||||||
int maxDegreeOfParallelism,
|
|
||||||
string workingDirectoryName)
|
|
||||||
{
|
|
||||||
Company = company;
|
|
||||||
MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
|
||||||
WorkingDirectoryName = workingDirectoryName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using System.Text.Json.Serialization;
|
|
||||||
|
|
||||||
namespace View_by_Distance.Save.Image.Info.Models;
|
|
||||||
|
|
||||||
public class ImageInfo
|
|
||||||
{
|
|
||||||
|
|
||||||
public DateTime? CreationTime { get; init; }
|
|
||||||
public DateTime? LastWriteTime { get; init; }
|
|
||||||
public long? Length { get; init; }
|
|
||||||
public string Name { get; init; }
|
|
||||||
|
|
||||||
[JsonConstructor]
|
|
||||||
public ImageInfo(DateTime? creationTime, DateTime? lastWriteTime, long? length, string name)
|
|
||||||
{
|
|
||||||
CreationTime = creationTime;
|
|
||||||
LastWriteTime = lastWriteTime;
|
|
||||||
Length = length;
|
|
||||||
Name = name;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,122 +0,0 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Phares.Shared;
|
|
||||||
using Serilog;
|
|
||||||
using ShellProgressBar;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.Json;
|
|
||||||
using View_by_Distance.Save.Image.Info.Models;
|
|
||||||
using View_by_Distance.Shared.Models;
|
|
||||||
using View_by_Distance.Shared.Models.Methods;
|
|
||||||
|
|
||||||
namespace View_by_Distance.Save.Image.Info;
|
|
||||||
|
|
||||||
public class SaveImageInfo
|
|
||||||
{
|
|
||||||
|
|
||||||
private readonly AppSettings _AppSettings;
|
|
||||||
private readonly string _WorkingDirectory;
|
|
||||||
private readonly Configuration _Configuration;
|
|
||||||
private readonly IsEnvironment _IsEnvironment;
|
|
||||||
private readonly IConfigurationRoot _ConfigurationRoot;
|
|
||||||
private readonly Property.Models.Configuration _PropertyConfiguration;
|
|
||||||
|
|
||||||
public SaveImageInfo(List<string> args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
|
|
||||||
{
|
|
||||||
if (isSilent)
|
|
||||||
{ }
|
|
||||||
if (console is null)
|
|
||||||
{ }
|
|
||||||
_AppSettings = appSettings;
|
|
||||||
_IsEnvironment = isEnvironment;
|
|
||||||
_WorkingDirectory = workingDirectory;
|
|
||||||
_ConfigurationRoot = configurationRoot;
|
|
||||||
ILogger? log = Log.ForContext<SaveImageInfo>();
|
|
||||||
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
|
|
||||||
Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
|
|
||||||
_PropertyConfiguration = propertyConfiguration;
|
|
||||||
_Configuration = configuration;
|
|
||||||
propertyConfiguration.Update();
|
|
||||||
log.Information(propertyConfiguration.RootDirectory);
|
|
||||||
Verify();
|
|
||||||
List<string> lines = SaveImageInfoFilesInDirectories(log);
|
|
||||||
File.WriteAllLines($"D:/Tmp/Phares/{DateTime.Now.Ticks}.tsv", lines);
|
|
||||||
if (!lines.Any())
|
|
||||||
_ = Shared.Models.Stateless.Methods.IPath.DeleteEmptyDirectories(propertyConfiguration.RootDirectory);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Verify()
|
|
||||||
{
|
|
||||||
if (_AppSettings is null)
|
|
||||||
{ }
|
|
||||||
if (_IsEnvironment is null)
|
|
||||||
{ }
|
|
||||||
if (_Configuration is null)
|
|
||||||
{ }
|
|
||||||
if (_ConfigurationRoot is null)
|
|
||||||
{ }
|
|
||||||
if (_WorkingDirectory is null)
|
|
||||||
{ }
|
|
||||||
if (_PropertyConfiguration is null)
|
|
||||||
{ }
|
|
||||||
}
|
|
||||||
|
|
||||||
private StringBuilder GetLines(ProgressBar progressBar, List<string[]> filesCollection)
|
|
||||||
{
|
|
||||||
StringBuilder result = new();
|
|
||||||
string json;
|
|
||||||
string? directory;
|
|
||||||
ImageInfo imageInfo;
|
|
||||||
FileHolder[] fileHolders;
|
|
||||||
List<string> lines = new();
|
|
||||||
int rootDirectoryLength = _PropertyConfiguration.RootDirectory.Length;
|
|
||||||
foreach (string[] files in filesCollection)
|
|
||||||
{
|
|
||||||
lines.Clear();
|
|
||||||
progressBar.Tick();
|
|
||||||
fileHolders = (from l in files select new FileHolder(l)).ToArray();
|
|
||||||
foreach (FileHolder fileHolder in from l in fileHolders orderby l.Name.Length, l.Name select l)
|
|
||||||
{
|
|
||||||
if (fileHolder.ExtensionLowered == ".id" || fileHolder.ExtensionLowered == ".lsv" || fileHolder.DirectoryName is null)
|
|
||||||
continue;
|
|
||||||
imageInfo = new(fileHolder.CreationTime, fileHolder.LastWriteTime, fileHolder.Length, fileHolder.Name);
|
|
||||||
json = JsonSerializer.Serialize(imageInfo);
|
|
||||||
lines.Add(json);
|
|
||||||
}
|
|
||||||
if (lines.Any())
|
|
||||||
{
|
|
||||||
directory = Path.GetDirectoryName(files.First());
|
|
||||||
if (directory is null || directory.Length < rootDirectoryLength)
|
|
||||||
continue;
|
|
||||||
_ = result.AppendLine(directory[rootDirectoryLength..]);
|
|
||||||
foreach (string line in lines)
|
|
||||||
_ = result.AppendLine(line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Save(StringBuilder stringBuilder)
|
|
||||||
{
|
|
||||||
string checkFile = Path.Combine(_PropertyConfiguration.RootDirectory, ".json");
|
|
||||||
string text = stringBuilder.ToString();
|
|
||||||
_ = Shared.Models.Stateless.Methods.IPath.WriteAllText(checkFile, text, updateToWhenMatches: null, compareBeforeWrite: true, updateDateWhenMatches: false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<string> SaveImageInfoFilesInDirectories(ILogger log)
|
|
||||||
{
|
|
||||||
List<string> results = new();
|
|
||||||
ProgressBar progressBar;
|
|
||||||
const string fileSearchFilter = "*";
|
|
||||||
string message = nameof(SaveImageInfo);
|
|
||||||
const string directorySearchFilter = "*";
|
|
||||||
List<string> distinctDirectories = new();
|
|
||||||
List<string[]> filesCollection = Shared.Models.Stateless.Methods.IDirectory.GetFilesCollection(_PropertyConfiguration.RootDirectory, directorySearchFilter, fileSearchFilter);
|
|
||||||
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
|
||||||
progressBar = new(filesCollection.Count, message, options);
|
|
||||||
StringBuilder lines = GetLines(progressBar, filesCollection);
|
|
||||||
progressBar.Dispose();
|
|
||||||
Save(lines);
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -38,7 +38,12 @@ internal abstract partial class XDirectory
|
|||||||
results.Add(Directory.GetFiles(directory, fileSearchFilter, SearchOption.TopDirectoryOnly));
|
results.Add(Directory.GetFiles(directory, fileSearchFilter, SearchOption.TopDirectoryOnly));
|
||||||
string[] directories = Directory.GetDirectories(directory, directorySearchFilter, SearchOption.TopDirectoryOnly);
|
string[] directories = Directory.GetDirectories(directory, directorySearchFilter, SearchOption.TopDirectoryOnly);
|
||||||
foreach (string innerDirectory in directories)
|
foreach (string innerDirectory in directories)
|
||||||
results.Add(Directory.GetFiles(innerDirectory, fileSearchFilter, SearchOption.AllDirectories));
|
{
|
||||||
|
try
|
||||||
|
{ results.Add(Directory.GetFiles(innerDirectory, fileSearchFilter, SearchOption.AllDirectories)); }
|
||||||
|
catch (UnauthorizedAccessException)
|
||||||
|
{ continue; }
|
||||||
|
}
|
||||||
int ceilingAverage = results.Any() ? GetCeilingAverage(results) : 0;
|
int ceilingAverage = results.Any() ? GetCeilingAverage(results) : 0;
|
||||||
results = GetFilesCollection(results, ceilingAverage);
|
results = GetFilesCollection(results, ceilingAverage);
|
||||||
return results;
|
return results;
|
||||||
|
@ -35,6 +35,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Map", "Map\Map.csproj", "{9
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Metadata", "Metadata\Metadata.csproj", "{961D11A0-44C8-48CD-BEEE-A6E6903AE58F}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Metadata", "Metadata\Metadata.csproj", "{961D11A0-44C8-48CD-BEEE-A6E6903AE58F}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mirror-Length", "Mirror-Length\Mirror-Length.csproj", "{035A3DB4-1D0B-4872-ABAE-1D637BB89B1C}"
|
||||||
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Move-By-Id", "Move-By-Id\Move-By-Id.csproj", "{0FDFBC71-3801-483F-A4AC-CC8CF857D54F}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Move-By-Id", "Move-By-Id\Move-By-Id.csproj", "{0FDFBC71-3801-483F-A4AC-CC8CF857D54F}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Person", "Person\Person.csproj", "{C5003A39-334B-444B-9873-39B26E58D667}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Person", "Person\Person.csproj", "{C5003A39-334B-444B-9873-39B26E58D667}"
|
||||||
@ -51,8 +53,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rename", "Rename\Rename.csp
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Resize", "Resize\Resize.csproj", "{27D0D869-394D-4B07-83DF-2095B16026FC}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Resize", "Resize\Resize.csproj", "{27D0D869-394D-4B07-83DF-2095B16026FC}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Save-Image-Info", "Save-Image-Info\Save-Image-Info.csproj", "{22B8C2B6-2D6E-4166-86CD-D37D11617A79}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Set-Created-Date", "Set-Created-Date\Set-Created-Date.csproj", "{B067643E-9F59-46A1-A001-ACF4661F059C}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Set-Created-Date", "Set-Created-Date\Set-Created-Date.csproj", "{B067643E-9F59-46A1-A001-ACF4661F059C}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{B4FB6B43-36EC-404D-B934-5C695C6E32CC}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{B4FB6B43-36EC-404D-B934-5C695C6E32CC}"
|
||||||
@ -196,5 +196,9 @@ Global
|
|||||||
{22B8C2B6-2D6E-4166-86CD-D37D11617A79}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{22B8C2B6-2D6E-4166-86CD-D37D11617A79}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{22B8C2B6-2D6E-4166-86CD-D37D11617A79}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{22B8C2B6-2D6E-4166-86CD-D37D11617A79}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{22B8C2B6-2D6E-4166-86CD-D37D11617A79}.Release|Any CPU.Build.0 = Release|Any CPU
|
{22B8C2B6-2D6E-4166-86CD-D37D11617A79}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{035A3DB4-1D0B-4872-ABAE-1D637BB89B1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{035A3DB4-1D0B-4872-ABAE-1D637BB89B1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{035A3DB4-1D0B-4872-ABAE-1D637BB89B1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{035A3DB4-1D0B-4872-ABAE-1D637BB89B1C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
Loading…
x
Reference in New Issue
Block a user