mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -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:
+3
-1
@@ -208,7 +208,9 @@ void Set::reflect_cards<Writer> (Writer& tag) {
|
||||
} else {
|
||||
set<String> used;
|
||||
FOR_EACH(card, cards) {
|
||||
String filename = normalize_internal_filename(clean_filename(card->identification()));
|
||||
// pick a unique filename for this card
|
||||
// can't use Package::newFileName, because then we get conflicts with the previous save of the same card
|
||||
String filename = _("card ") + normalize_internal_filename(clean_filename(card->identification()));
|
||||
String full_name = filename;
|
||||
int i = 0;
|
||||
|
||||
|
||||
@@ -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