Latest changes.

This commit is contained in:
Storm Dragon
2026-02-24 23:11:47 -05:00
parent 7531eacf64
commit 59f2880498
3 changed files with 63 additions and 16 deletions

View File

@@ -45,7 +45,8 @@ bool is_windows_reserved_filename(const string& in upperName) {
return false;
}
string sanitize_filename_base(string name, const int maxLength = 40, const string fallback = "item") {
string sanitize_filename_base_with_reserved_prefix(string name, const int maxLength = 40, const string fallback = "item",
const string reservedPrefix = "file_") {
string normalized = normalize_name_whitespace(name);
string result = "";
bool lastSeparator = false;
@@ -93,13 +94,26 @@ string sanitize_filename_base(string name, const int maxLength = 40, const strin
}
if (is_windows_reserved_filename(upperName)) {
result = "file_" + result;
string safePrefix = reservedPrefix;
if (safePrefix == "")
safePrefix = "file_";
result = safePrefix + result;
}
return result;
}
string sanitize_filename_base(string name, const int maxLength = 40, const string fallback = "item") {
return sanitize_filename_base_with_reserved_prefix(name, maxLength, fallback, "file_");
}
string build_filename_from_name_ex(const string& in name, const string& in extension = ".dat",
const int maxBaseLength = 40, const string fallback = "item",
const string reservedPrefix = "file_") {
return sanitize_filename_base_with_reserved_prefix(name, maxBaseLength, fallback, reservedPrefix) + extension;
}
string build_filename_from_name(const string& in name, const string& in extension = ".dat",
const int maxBaseLength = 40, const string fallback = "item") {
return sanitize_filename_base(name, maxBaseLength, fallback) + extension;
return build_filename_from_name_ex(name, extension, maxBaseLength, fallback, "file_");
}