Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
f3c3c546
Commit
f3c3c546
authored
Feb 22, 2011
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added add_extension function
Added ExportTemplate::byName Use ExportTemplate::byName in main
parent
c70f5032
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
1 deletion
+25
-1
src/data/export_template.cpp
src/data/export_template.cpp
+5
-0
src/data/export_template.hpp
src/data/export_template.hpp
+4
-0
src/main.cpp
src/main.cpp
+1
-1
src/util/file_utils.cpp
src/util/file_utils.cpp
+8
-0
src/util/file_utils.hpp
src/util/file_utils.hpp
+7
-0
No files found.
src/data/export_template.cpp
View file @
f3c3c546
...
...
@@ -11,6 +11,7 @@
#include <data/game.hpp>
#include <data/set.hpp>
#include <data/field.hpp>
#include <util/io/package_manager.hpp>
// ----------------------------------------------------------------------------- : Export template, basics
...
...
@@ -19,6 +20,10 @@ ExportTemplate::ExportTemplate()
,
create_directory
(
false
)
{}
ExportTemplateP
ExportTemplate
::
byName
(
const
String
&
name
)
{
return
package_manager
.
open
<
ExportTemplate
>
(
add_extension
(
name
,
_
(
".mse-export-template"
)));
}
String
ExportTemplate
::
typeNameStatic
()
{
return
_
(
"export-template"
);
}
String
ExportTemplate
::
typeName
()
const
{
return
_
(
"export-template"
);
}
Version
ExportTemplate
::
fileVersion
()
const
{
return
file_version_export_template
;
}
...
...
src/data/export_template.hpp
View file @
f3c3c546
...
...
@@ -38,6 +38,10 @@ class ExportTemplate : public Packaged {
virtual
String
typeName
()
const
;
Version
fileVersion
()
const
;
virtual
void
validate
(
Version
=
app_version
);
/// Loads the export template with a particular name
static
ExportTemplateP
byName
(
const
String
&
name
);
private:
DECLARE_REFLECTION
();
};
...
...
src/main.cpp
View file @
f3c3c546
...
...
@@ -269,7 +269,7 @@ int MSE::OnRun() {
throw
Error
(
_
(
"No input set file specified for --export"
));
}
String
export_template
=
args
[
1
];
ExportTemplateP
exp
=
package_manager
.
open
<
ExportTemplate
>
(
export_template
);
ExportTemplateP
exp
=
ExportTemplate
::
byName
(
export_template
);
SetP
set
=
import_set
(
args
[
2
]);
String
out
=
args
.
size
()
>=
4
?
args
[
3
]
:
_
(
""
);
ScriptValueP
result
=
export_set
(
set
,
set
->
cards
,
exp
,
out
);
...
...
src/util/file_utils.cpp
View file @
f3c3c546
...
...
@@ -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
==
_
(
'.'
);
}
...
...
src/util/file_utils.hpp
View file @
f3c3c546
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment