InPlaceMoveDirectory
DirectoryName => DirectoryFullPath
This commit is contained in:
@ -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