mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
Make extension optional in --export command.
Added add_extension function Added ExportTemplate::byName Use ExportTemplate::byName in main
This commit is contained in:
@@ -38,6 +38,14 @@ bool ignore_file(const String& name) {
|
||||
return name == _("Thumbs.db"); // winXP explorer thumbnails
|
||||
}
|
||||
|
||||
String add_extension(const String& filename, String const& extension) {
|
||||
if (extension.size() <= filename.size() && is_substr(filename, filename.size() - extension.size(), extension)) {
|
||||
return filename;
|
||||
} else {
|
||||
return filename + extension;
|
||||
}
|
||||
}
|
||||
|
||||
bool is_filename_char(Char c) {
|
||||
return isAlnum(c) || c == _(' ') || c == _('_') || c == _('-') || c == _('.');
|
||||
}
|
||||
|
||||
@@ -25,6 +25,13 @@ String normalize_internal_filename(const String& filename);
|
||||
/** true for hidden OS and version control files */
|
||||
bool ignore_file(const String& name);
|
||||
|
||||
/// Add an extension to a filename if it is not already present
|
||||
/** add_extension("test",".txt") == "test.txt"
|
||||
* add_extension("test.txt",".txt") == "test.txt"
|
||||
* add_extension("test.xyz",".txt") == "test.xyz.txt"
|
||||
*/
|
||||
String add_extension(const String& filename, String const& extension);
|
||||
|
||||
/// Make sure a string is safe to use as a filename
|
||||
String clean_filename(const String& name);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user