mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
Add placeholder for random alphanumerics in filename (#216)
This commit is contained in:
parent
7fd013b6c8
commit
926855cd70
2 changed files with 8 additions and 0 deletions
|
@ -44,6 +44,8 @@ namespace GreenshotPlugin.Core {
|
|||
private const int MaxTitleLength = 80;
|
||||
private static readonly CoreConfiguration CoreConfig = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private const string UnsafeReplacement = "_";
|
||||
private static readonly Random RandomNumberGen = new Random();
|
||||
private static readonly Regex RandRegexp = new Regex("^R+$", RegexOptions.Compiled);
|
||||
|
||||
/// <summary>
|
||||
/// Remove invalid characters from the fully qualified filename
|
||||
|
@ -160,6 +162,7 @@ namespace GreenshotPlugin.Core {
|
|||
string replaceValue = string.Empty;
|
||||
string variable = match.Groups["variable"].Value;
|
||||
string parameters = match.Groups["parameters"].Value;
|
||||
string randomChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
if (parameters.Length > 0) {
|
||||
string[] parms = SplitRegexp.Split(parameters);
|
||||
|
@ -241,6 +244,10 @@ namespace GreenshotPlugin.Core {
|
|||
if (filenameSafeMode) {
|
||||
replaceValue = MakePathSafe(replaceValue);
|
||||
}
|
||||
} else if (RandRegexp.IsMatch(variable)) {
|
||||
for (int i = 0; i < variable.Length; i++) {
|
||||
replaceValue += randomChars[RandomNumberGen.Next(randomChars.Length)];
|
||||
}
|
||||
} else {
|
||||
// Handle other variables
|
||||
// Default use "now" for the capture take´n
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue