File naming stuff is (finally) centralized under AudioFileStorageExt

This commit is contained in:
Robert McRackan 2021-10-21 14:38:59 -04:00
parent e4fc104afe
commit d636ceed8e
17 changed files with 208 additions and 157 deletions

View file

@ -28,7 +28,7 @@ namespace FileManager
public string IllegalCharacterReplacements { get; set; }
/// <summary>Generate a valid path for this file or directory</summary>
public string GetFilename()
public string GetFilePath()
{
var filename = Template;

View file

@ -20,21 +20,6 @@ namespace FileManager
? (extension ?? "")?.Trim()
: '.' + extension.Trim('.');
public static string GetValidFilename(string dirFullPath, string filename, string extension, string metadataSuffix)
{
ArgumentValidator.EnsureNotNullOrWhiteSpace(dirFullPath, nameof(dirFullPath));
ArgumentValidator.EnsureNotNullOrWhiteSpace(filename, nameof(filename));
var template = $"<title> [<id>]";
var fullfilename = Path.Combine(dirFullPath, template + GetStandardizedExtension(extension));
var fileTemplate = new FileTemplate(fullfilename) { IllegalCharacterReplacements = "_" };
fileTemplate.AddParameterReplacement("title", filename);
fileTemplate.AddParameterReplacement("id", metadataSuffix);
return fileTemplate.GetFilename();
}
/// <summary>
/// Return position with correct number of leading zeros.
/// <br />- 2 of 9 => "2"