File naming stuff is (finally) centralized under AudioFileStorageExt
This commit is contained in:
parent
e4fc104afe
commit
d636ceed8e
17 changed files with 208 additions and 157 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue