mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
trim filenames, apparently writing a file "some card " is not possible on windows, it drops the trailing space.
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1448 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -42,11 +42,18 @@ bool is_filename_char(Char c) {
|
||||
|
||||
String clean_filename(const String& name) {
|
||||
String clean;
|
||||
// allow only valid characters, and remove leading whitespace
|
||||
bool start = true;
|
||||
FOR_EACH_CONST(c, name) {
|
||||
if (is_filename_char(c)) {
|
||||
if (is_filename_char(c) && !(start && c == _(' '))) {
|
||||
start = false;
|
||||
clean += c;
|
||||
}
|
||||
}
|
||||
// remove trailing whitespace
|
||||
while (!clean.empty() && clean[clean.size()-1] == _(' ')) {
|
||||
clean.resize(clean.size()-1);
|
||||
}
|
||||
if (clean.empty() || starts_with(clean, _("."))) {
|
||||
clean = _("no-name") + clean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user