You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.4 KiB
51 lines
1.4 KiB
using LiteDB; |
|
|
|
namespace StabilityMatrix.Core.Models.Database; |
|
|
|
/// <summary> |
|
/// Represents a locally indexed image file. |
|
/// </summary> |
|
public class LocalImageFile |
|
{ |
|
/// <summary> |
|
/// Relative path of the file from the root images directory ("%LIBRARY%/Images"). |
|
/// </summary> |
|
[BsonId] |
|
public required string RelativePath { get; set; } |
|
|
|
/// <summary> |
|
/// Type of the model file. |
|
/// </summary> |
|
public LocalImageFileType ImageType { get; set; } |
|
|
|
/// <summary> |
|
/// Creation time of the file. |
|
/// </summary> |
|
public DateTimeOffset CreatedAt { get; set; } |
|
|
|
/// <summary> |
|
/// Last modified time of the file. |
|
/// </summary> |
|
public DateTimeOffset LastModifiedAt { get; set; } |
|
|
|
/// <summary> |
|
/// File name of the relative path. |
|
/// </summary> |
|
public string FileName => Path.GetFileName(RelativePath); |
|
|
|
/// <summary> |
|
/// File name of the relative path without extension. |
|
/// </summary> |
|
public string FileNameWithoutExtension => Path.GetFileNameWithoutExtension(RelativePath); |
|
|
|
public string GlobalFullPath => |
|
GlobalConfig.LibraryDir.JoinDir("Images").JoinFile(RelativePath); |
|
|
|
public string GetFullPath(string rootImageDirectory) |
|
{ |
|
return Path.Combine(rootImageDirectory, RelativePath); |
|
} |
|
|
|
public static readonly HashSet<string> SupportedImageExtensions = |
|
new() { ".png", ".jpg", ".jpeg", ".webp" }; |
|
}
|
|
|