Path: redb-route/redb.Route.GenericFile/GenericFileFacts.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.GenericFile/GenericFileFacts.cs
----
using redb.Route.Expressions;
namespace redb.Route.GenericFile;
///
/// The file facts of a file a consumer is handling, for the file keys in its own options (moveTo,
/// preMove, moveFailed, doneFileName, idempotentKey). The values are the ones the file
/// consumer writes into the redbFile.* headers, so ${file:ext} in moveTo and in a
/// <log> of the same route agree.
///
public sealed class GenericFileFacts : IFileFacts
{
private readonly IFileOperations _ops;
private readonly string? _basePath;
/// The facts of , which is now at .
/// The polled file.
/// Where the file is now: its own path, or where a pre-move or a read lock put it.
/// The transport's path helpers.
public GenericFileFacts(GenericFileInfo file, string workPath, IFileOperations ops)
: this(file.Name, workPath, file.BasePath, ops)
{
Length = file.Length;
LastModified = file.LastModified;
}
///
/// The facts known from a path alone, for the compatibility form of the consumer hooks: the size and the last
/// write time are not known here and are null.
///
public GenericFileFacts(string fileName, string workPath, string? basePath, IFileOperations ops)
{
ArgumentNullException.ThrowIfNull(fileName);
ArgumentNullException.ThrowIfNull(ops);
_ops = ops;
_basePath = basePath;
Name = fileName;
AbsolutePath = workPath;
}
///
public string? Name { get; }
///
public string? NameOnly => _ops.GetFileNameWithoutExtension(Name!);
///
public string? Extension => FileLanguage.WithoutDot(_ops.GetExtension(Name!).ToLowerInvariant());
///
public string? Parent => string.IsNullOrEmpty(AbsolutePath) ? null : _ops.GetParentPath(AbsolutePath);
///
public string? AbsolutePath { get; }
///
public string? RelativePath => string.IsNullOrEmpty(AbsolutePath) || _basePath is null
? null
: _ops.GetRelativePath(_basePath, AbsolutePath);
///
public long? Length { get; }
///
public DateTimeOffset? LastModified { get; }
}