mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-09-24 07:45:06 +00:00
Add IS-CAB CreateFilenamePattern from UnshieldSharp
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using SabreTools.Models.InstallShieldCabinet;
|
||||
|
||||
namespace SabreTools.Serialization.Wrappers
|
||||
@@ -135,6 +136,29 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cabinet Set
|
||||
|
||||
/// <summary>
|
||||
/// Create the generic filename pattern to look for from the input filename
|
||||
/// </summary>
|
||||
/// <returns>String representing the filename pattern for a cabinet set, null on error</returns>
|
||||
public static string? CreateFilenamePattern(string filename)
|
||||
{
|
||||
string? pattern = null;
|
||||
if (string.IsNullOrEmpty(filename))
|
||||
return pattern;
|
||||
|
||||
string? directory = Path.GetDirectoryName(Path.GetFullPath(filename));
|
||||
if (directory != null)
|
||||
pattern = Path.Combine(directory, Path.GetFileNameWithoutExtension(filename));
|
||||
else
|
||||
pattern = Path.GetFileNameWithoutExtension(filename);
|
||||
|
||||
return new Regex(@"\d+$").Replace(pattern, string.Empty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Component
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user