deterministicHashCode
This commit is contained in:
@ -20,15 +20,27 @@ internal abstract class Id
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static NameWithoutExtension GetNameWithoutExtension(IMetadataConfiguration configuration, string file)
|
||||
internal static FilePath GetFilePath(FilePath filePath, string file)
|
||||
{
|
||||
NameWithoutExtension result;
|
||||
FilePath result;
|
||||
string fileName = Path.GetFileName(file);
|
||||
string fileExtensionLowered = Path.GetExtension(file).ToLower();
|
||||
result = new(filePath.DirectoryName, fileExtensionLowered, file, filePath.Id, filePath.IsIdFormat, filePath.IsPaddedIdFormat, fileName, filePath.NameWithoutExtension);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static FilePath GetFilePath(IMetadataConfiguration configuration, string file)
|
||||
{
|
||||
FilePath result;
|
||||
int? id;
|
||||
short? multiplier;
|
||||
char negativeMarker;
|
||||
int absoluteValueOfId;
|
||||
string fileName = Path.GetFileName(file);
|
||||
string fileExtensionLowered = Path.GetExtension(file).ToLower();
|
||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file);
|
||||
short sortOrderOnlyLengthIndex = IId.GetSortOrderOnlyLengthIndex(configuration.Offset);
|
||||
string fileDirectoryName = Path.GetDirectoryName(file) ?? throw new NullReferenceException();
|
||||
bool nameWithoutExtensionIsIdFormat = IId.NameWithoutExtensionIsIdFormat(fileNameWithoutExtension);
|
||||
bool nameWithoutExtensionIsPaddedIdFormat = IId.NameWithoutExtensionIsPaddedIdFormat(fileNameWithoutExtension, sortOrderOnlyLengthIndex);
|
||||
if (!nameWithoutExtensionIsIdFormat && !nameWithoutExtensionIsPaddedIdFormat)
|
||||
@ -58,7 +70,26 @@ internal abstract class Id
|
||||
id = null;
|
||||
}
|
||||
}
|
||||
result = new(fileNameWithoutExtension, id, nameWithoutExtensionIsIdFormat, nameWithoutExtensionIsPaddedIdFormat);
|
||||
result = new(fileDirectoryName, fileExtensionLowered, file, id, nameWithoutExtensionIsIdFormat, nameWithoutExtensionIsPaddedIdFormat, fileName, fileNameWithoutExtension);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static int GetDeterministicHashCode(byte[] value)
|
||||
{
|
||||
int result;
|
||||
unchecked
|
||||
{
|
||||
int hash1 = (5381 << 16) + 5381;
|
||||
int hash2 = hash1;
|
||||
for (int i = 0; i < value.Length; i += 2)
|
||||
{
|
||||
hash1 = ((hash1 << 5) + hash1) ^ value[i];
|
||||
if (i == value.Length - 1)
|
||||
break;
|
||||
hash2 = ((hash2 << 5) + hash2) ^ value[i + 1];
|
||||
}
|
||||
result = hash1 + (hash2 * 1566083941);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -33,9 +33,19 @@ public interface IId
|
||||
static short GetSortOrderOnlyLengthIndex(int offset) =>
|
||||
(short)(offset.ToString().Length + 3);
|
||||
|
||||
NameWithoutExtension TestStatic_GetNameWithoutExtension(IMetadataConfiguration configuration, string file) =>
|
||||
GetNameWithoutExtension(configuration, file);
|
||||
static NameWithoutExtension GetNameWithoutExtension(IMetadataConfiguration configuration, string file) =>
|
||||
Id.GetNameWithoutExtension(configuration, file);
|
||||
FilePath TestStatic_GetFilePath(FilePath filePath, string file) =>
|
||||
GetFilePath(filePath, file);
|
||||
static FilePath GetFilePath(FilePath filePath, string file) =>
|
||||
Id.GetFilePath(filePath, file);
|
||||
|
||||
FilePath TestStatic_GetFilePath(IMetadataConfiguration configuration, string file) =>
|
||||
GetFilePath(configuration, file);
|
||||
static FilePath GetFilePath(IMetadataConfiguration configuration, string file) =>
|
||||
Id.GetFilePath(configuration, file);
|
||||
|
||||
int TestStatic_GetDeterministicHashCode(byte[] value) =>
|
||||
GetDeterministicHashCode(value);
|
||||
static int GetDeterministicHashCode(byte[] value) =>
|
||||
Id.GetDeterministicHashCode(value);
|
||||
|
||||
}
|
9
Shared/Models/Stateless/Methods/IRename.cs
Normal file
9
Shared/Models/Stateless/Methods/IRename.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
|
||||
public interface IRename
|
||||
{
|
||||
|
||||
string[]? ConvertAndGetFfmpegFiles(FilePath filePath);
|
||||
DeterministicHashCode GetDeterministicHashCode(FilePath filePath);
|
||||
|
||||
}
|
Reference in New Issue
Block a user