InPlaceMoveDirectory
DirectoryName => DirectoryFullPath
This commit is contained in:
@ -4,7 +4,7 @@ using System.Text.Json.Serialization;
|
||||
namespace View_by_Distance.Shared.Models;
|
||||
|
||||
public record FileHolder(DateTime? CreationTime,
|
||||
string? DirectoryName,
|
||||
string? DirectoryFullPath,
|
||||
bool Exists,
|
||||
string ExtensionLowered,
|
||||
string FullName,
|
||||
@ -52,7 +52,7 @@ public record FileHolder(DateTime? CreationTime,
|
||||
{
|
||||
FileHolder result;
|
||||
result = new(new(filePath.CreationTicks),
|
||||
filePath.DirectoryName,
|
||||
filePath.DirectoryFullPath,
|
||||
true,
|
||||
filePath.ExtensionLowered,
|
||||
filePath.FullName,
|
||||
@ -66,7 +66,7 @@ public record FileHolder(DateTime? CreationTime,
|
||||
|
||||
private static FileHolder GetExisting(FileHolder fileHolder) =>
|
||||
new(fileHolder.CreationTime,
|
||||
fileHolder.DirectoryName,
|
||||
fileHolder.DirectoryFullPath,
|
||||
fileHolder.Exists,
|
||||
fileHolder.ExtensionLowered,
|
||||
fileHolder.FullName,
|
||||
@ -78,7 +78,7 @@ public record FileHolder(DateTime? CreationTime,
|
||||
|
||||
private static FileHolder GetNonExisting(FileHolder fileHolder) =>
|
||||
new(null,
|
||||
fileHolder.DirectoryName,
|
||||
fileHolder.DirectoryFullPath,
|
||||
fileHolder.Exists,
|
||||
fileHolder.ExtensionLowered,
|
||||
fileHolder.FullName,
|
||||
|
@ -5,7 +5,7 @@ using View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
namespace View_by_Distance.Shared.Models;
|
||||
|
||||
public record FilePath(long CreationTicks,
|
||||
string DirectoryName,
|
||||
string DirectoryFullPath,
|
||||
string ExtensionLowered,
|
||||
string FileNameFirstSegment,
|
||||
string FullName,
|
||||
@ -41,7 +41,7 @@ public record FilePath(long CreationTicks,
|
||||
int? sortOder;
|
||||
string fileNameFirstSegment = fileHolder.Name.Split('.')[0];
|
||||
int sortOrderOnlyLengthIndex = metadataConfiguration.Offset.ToString().Length;
|
||||
string fileDirectoryName = fileHolder.DirectoryName ?? throw new NullReferenceException();
|
||||
string fileDirectoryFullPath = fileHolder.DirectoryFullPath ?? throw new NullReferenceException();
|
||||
bool isIntelligentIdFormat = IId.NameWithoutExtensionIsIntelligentIdFormat(metadataConfiguration, fileNameFirstSegment);
|
||||
bool isPaddedIntelligentIdFormat = IId.NameWithoutExtensionIsPaddedIntelligentIdFormat(metadataConfiguration, sortOrderOnlyLengthIndex, fileNameFirstSegment);
|
||||
bool fileNameFirstSegmentIsIdFormat = !isPaddedIntelligentIdFormat && !isIntelligentIdFormat && IId.NameWithoutExtensionIsIdFormat(metadataConfiguration, fileHolder);
|
||||
@ -69,7 +69,7 @@ public record FilePath(long CreationTicks,
|
||||
else
|
||||
throw new NotSupportedException();
|
||||
result = new(fileHolder.CreationTime.Value.Ticks,
|
||||
fileDirectoryName,
|
||||
fileDirectoryFullPath,
|
||||
fileHolder.ExtensionLowered,
|
||||
fileNameFirstSegment,
|
||||
fileHolder.FullName,
|
||||
|
@ -3,21 +3,16 @@ namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
public interface IDate
|
||||
{
|
||||
|
||||
(bool?, string[]) TestStatic_IsWrongYear(string[] segments, string year) =>
|
||||
IsWrongYear(segments, year);
|
||||
static (bool?, string[]) IsWrongYear(string[] segments, string year) =>
|
||||
XDate.IsWrongYear(segments, year);
|
||||
(bool?, string[]) TestStatic_IsWrongYear(FilePath filePath, ExifDirectory exifDirectory) =>
|
||||
IsWrongYear(filePath, exifDirectory);
|
||||
static (bool?, string[]) IsWrongYear(FilePath filePath, ExifDirectory exifDirectory) =>
|
||||
XDate.IsWrongYear(filePath, exifDirectory);
|
||||
|
||||
(int Season, string seasonName) TestStatic_GetSeason(int dayOfYear) =>
|
||||
GetSeason(dayOfYear);
|
||||
static (int Season, string seasonName) GetSeason(int dayOfYear) =>
|
||||
XDate.GetSeason(dayOfYear);
|
||||
|
||||
(int Season, string seasonName) TestStatic_GetSeasonAB(int dayOfYear) =>
|
||||
GetSeasonAB(dayOfYear);
|
||||
static (int Season, string seasonName) GetSeasonAB(int dayOfYear) =>
|
||||
XDate.GetSeasonAB(dayOfYear);
|
||||
|
||||
DateTime? TestStatic_GetDateTimeOriginal(ExifDirectory exifDirectory) =>
|
||||
GetDateTimeOriginal(exifDirectory);
|
||||
static DateTime? GetDateTimeOriginal(ExifDirectory exifDirectory) =>
|
||||
|
@ -26,14 +26,14 @@ public interface IId
|
||||
string TestStatic_GetIgnoreFullPath(FilePath filePath, FileHolder fileHolder) =>
|
||||
GetIgnoreFullPath(filePath, fileHolder);
|
||||
static string GetIgnoreFullPath(FilePath filePath, FileHolder fileHolder) =>
|
||||
fileHolder.DirectoryName is null ?
|
||||
fileHolder.DirectoryFullPath is null ?
|
||||
throw new NotSupportedException() :
|
||||
filePath.Id > -1 ?
|
||||
fileHolder.NameWithoutExtension[^1] == '9' ?
|
||||
Path.Combine(fileHolder.DirectoryName, $"{fileHolder.NameWithoutExtension[..^1]}8{fileHolder.ExtensionLowered}") :
|
||||
Path.Combine(fileHolder.DirectoryFullPath, $"{fileHolder.NameWithoutExtension[..^1]}8{fileHolder.ExtensionLowered}") :
|
||||
throw new NotSupportedException("High") :
|
||||
fileHolder.NameWithoutExtension[^1] == '1' ?
|
||||
Path.Combine(fileHolder.DirectoryName, $"{fileHolder.NameWithoutExtension[..^1]}2{fileHolder.ExtensionLowered}") :
|
||||
Path.Combine(fileHolder.DirectoryFullPath, $"{fileHolder.NameWithoutExtension[..^1]}2{fileHolder.ExtensionLowered}") :
|
||||
throw new NotSupportedException("Low");
|
||||
|
||||
bool TestStatic_NameWithoutExtensionIsIntelligentIdFormat(MetadataConfiguration metadataConfiguration, string fileNameFirstSegment) =>
|
||||
|
@ -1,3 +1,4 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
@ -11,31 +12,18 @@ internal abstract class XDate
|
||||
(int Season, string seasonName) result = dayOfYear switch
|
||||
{
|
||||
< 78 => new(0, "Winter"),
|
||||
< 171 => new(1, "Spring"),
|
||||
< 264 => new(2, "Summer"),
|
||||
< 354 => new(3, "Fall"),
|
||||
_ => new(4, "Winter")
|
||||
< 124 => new(1, "Spring"),
|
||||
< 171 => new(2, "Spring"),
|
||||
< 217 => new(3, "Summer"),
|
||||
< 264 => new(4, "Summer"),
|
||||
< 309 => new(5, "Fall"),
|
||||
< 354 => new(6, "Fall"),
|
||||
_ => new(7, "Winter")
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static (int Season, string seasonName) GetSeasonAB(int dayOfYear)
|
||||
{
|
||||
(int Season, string seasonName) result = dayOfYear switch
|
||||
{
|
||||
< 78 => new(0, "WinterA"),
|
||||
< 124 => new(1, "SpringA"),
|
||||
< 171 => new(1, "SpringB"),
|
||||
< 217 => new(2, "SummerA"),
|
||||
< 264 => new(2, "SummerB"),
|
||||
< 309 => new(3, "FallA"),
|
||||
< 354 => new(3, "FallB"),
|
||||
_ => new(4, "WinterB")
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static (bool?, string[]) IsWrongYear(string[] segments, string year)
|
||||
private static (bool?, string[]) IsWrongYear(string[] segments, string year)
|
||||
{
|
||||
bool? result;
|
||||
string[] results = (
|
||||
@ -66,6 +54,47 @@ internal abstract class XDate
|
||||
return new(result, results);
|
||||
}
|
||||
|
||||
internal static (bool?, string[]) IsWrongYear(FilePath filePath, ExifDirectory exifDirectory)
|
||||
{
|
||||
string[] results = [];
|
||||
bool? result = null;
|
||||
string year;
|
||||
string directoryName;
|
||||
string[] directorySegments;
|
||||
List<DateTime> collection = [];
|
||||
string? check = Path.GetFullPath(filePath.FullName);
|
||||
string? pathRoot = Path.GetPathRoot(filePath.FullName);
|
||||
if (string.IsNullOrEmpty(pathRoot))
|
||||
throw new Exception();
|
||||
DateTime? dateTimeOriginal = GetDateTimeOriginal(exifDirectory);
|
||||
if (dateTimeOriginal is not null)
|
||||
collection.Add(dateTimeOriginal.Value);
|
||||
else
|
||||
{
|
||||
ReadOnlyCollection<DateTime> dateTimes = GetDateTimes(exifDirectory);
|
||||
foreach (DateTime dateTime in dateTimes)
|
||||
collection.Add(dateTime);
|
||||
}
|
||||
foreach (DateTime dateTime in collection)
|
||||
{
|
||||
year = dateTime.ToString("yyyy");
|
||||
for (int i = 0; i < int.MaxValue; i++)
|
||||
{
|
||||
check = Path.GetDirectoryName(check);
|
||||
if (string.IsNullOrEmpty(check) || check == pathRoot)
|
||||
break;
|
||||
directoryName = Path.GetFileName(check);
|
||||
directorySegments = directoryName.Split(' ');
|
||||
(result, results) = IsWrongYear(directorySegments, year);
|
||||
if (result is not null)
|
||||
break;
|
||||
}
|
||||
if (result is not null && !result.Value)
|
||||
break;
|
||||
}
|
||||
return new(result, results);
|
||||
}
|
||||
|
||||
internal static DateTime? GetDateTimeOriginal(ExifDirectory exifDirectory)
|
||||
{
|
||||
DateTime? result;
|
||||
@ -153,9 +182,8 @@ internal abstract class XDate
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static DateTime GetMinimum(ExifDirectory exifDirectory)
|
||||
private static ReadOnlyCollection<DateTime> GetDateTimes(ExifDirectory exifDirectory)
|
||||
{
|
||||
DateTime result;
|
||||
List<DateTime> results = [];
|
||||
foreach (ExifDirectoryBase exifDirectoryBase in exifDirectory.ExifBaseDirectories)
|
||||
{
|
||||
@ -207,6 +235,13 @@ internal abstract class XDate
|
||||
results.Add(fileMetadataDirectory.FileModifiedDate.Value);
|
||||
}
|
||||
}
|
||||
return new(results);
|
||||
}
|
||||
|
||||
internal static DateTime GetMinimum(ExifDirectory exifDirectory)
|
||||
{
|
||||
DateTime result;
|
||||
ReadOnlyCollection<DateTime> results = GetDateTimes(exifDirectory);
|
||||
result = results.Count == 0 ? DateTime.MinValue : results.Min();
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user