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
d1297e23
Commit
d1297e23
authored
Aug 03, 2010
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow reading images from the current directory in the CLI interface
parent
b13371ad
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
28 deletions
+40
-28
src/cli/cli_main.cpp
src/cli/cli_main.cpp
+10
-2
src/cli/cli_main.hpp
src/cli/cli_main.hpp
+1
-0
src/data/export_template.hpp
src/data/export_template.hpp
+3
-1
src/script/functions/export.cpp
src/script/functions/export.cpp
+1
-1
src/util/io/package.cpp
src/util/io/package.cpp
+6
-11
src/util/io/package.hpp
src/util/io/package.hpp
+19
-13
No files found.
src/cli/cli_main.cpp
View file @
d1297e23
...
...
@@ -26,8 +26,8 @@ CLISetInterface::CLISetInterface(const SetP& set, bool quiet)
if
(
!
cli
.
haveConsole
())
{
throw
Error
(
_
(
"Can not run command line interface without a console;
\n
start MSE with
\"
mse.com --cli
\"
"
));
}
ei
.
directory_relative
=
ei
.
directory_absolute
=
wxGetCwd
();
ei
.
allow_writes_outside
=
true
;
setExportInfoCwd
();
setSet
(
set
);
run
();
}
...
...
@@ -61,6 +61,14 @@ void CLISetInterface::onChangeSet() {
ei
.
set
=
set
;
}
void
CLISetInterface
::
setExportInfoCwd
()
{
// write to the current directory
ei
.
directory_relative
=
ei
.
directory_absolute
=
wxGetCwd
();
// read from the current directory
ei
.
export_template
=
intrusive
(
new
Package
());
ei
.
export_template
->
open
(
ei
.
directory_absolute
,
true
);
}
// ----------------------------------------------------------------------------- : Running
...
...
@@ -151,7 +159,7 @@ void CLISetInterface::handleCommand(const String& command) {
if
(
!
wxSetWorkingDirectory
(
arg
))
{
cli
.
showError
(
_
(
"Can't change working directory to "
)
+
arg
);
}
else
{
ei
.
directory_relative
=
ei
.
directory_absolute
=
wxGet
Cwd
();
setExportInfo
Cwd
();
}
}
}
else
if
(
before
==
_
(
":pwd"
)
||
before
==
_
(
":p"
))
{
...
...
src/cli/cli_main.hpp
View file @
d1297e23
...
...
@@ -44,6 +44,7 @@ class CLISetInterface : public SetView {
// export info, so we can write files
ExportInfo
ei
;
void
setExportInfoCwd
();
};
// ----------------------------------------------------------------------------- : EOF
...
...
src/data/export_template.hpp
View file @
d1297e23
...
...
@@ -18,6 +18,7 @@ DECLARE_POINTER_TYPE(Set);
DECLARE_POINTER_TYPE
(
Field
);
DECLARE_POINTER_TYPE
(
Style
);
DECLARE_POINTER_TYPE
(
ExportTemplate
);
DECLARE_POINTER_TYPE
(
Package
);
// ----------------------------------------------------------------------------- : ExportTemplate
...
...
@@ -48,7 +49,8 @@ struct ExportInfo {
ExportInfo
();
SetP
set
;
///< The set that is being exported
ExportTemplateP
export_template
;
///< The export template used
PackageP
export_template
;
///< The export template used
/// When using the CLI, this can be a fake package to allow reading from the cwd
String
directory_relative
;
///< The directory for storing extra files (or "" if !export->create_directory)
/// This is just the directory name
String
directory_absolute
;
///< The absolute path of the directory
...
...
src/script/functions/export.cpp
View file @
d1297e23
...
...
@@ -418,7 +418,7 @@ SCRIPT_FUNCTION(write_image_file) {
SCRIPT_OPTIONAL_PARAM_
(
int
,
height
);
ScriptObject
<
CardP
>*
card
=
dynamic_cast
<
ScriptObject
<
CardP
>*>
(
input
.
get
());
// is it a card?
Image
image
;
GeneratedImage
::
Options
options
(
width
,
height
,
ei
.
export_template
.
get
(),
ei
.
set
.
get
());
GeneratedImage
::
Options
options
(
width
,
height
,
ei
.
export_template
.
get
(),
ei
.
set
.
get
());
if
(
card
)
{
image
=
conform_image
(
export_bitmap
(
ei
.
set
,
card
->
getValue
()).
ConvertToImage
(),
options
);
}
else
{
...
...
src/util/io/package.cpp
View file @
d1297e23
...
...
@@ -66,7 +66,7 @@ const String& Package::absoluteFilename() const {
return
filename
;
}
void
Package
::
open
(
const
String
&
n
)
{
void
Package
::
open
(
const
String
&
n
,
bool
fast
)
{
assert
(
!
isOpened
());
// not already opened
// get absolute path
wxFileName
fn
(
n
);
...
...
@@ -78,7 +78,7 @@ void Package::open(const String& n) {
}
// type of package
if
(
wxDirExists
(
filename
))
{
openDirectory
();
openDirectory
(
fast
);
}
else
if
(
wxFileExists
(
filename
))
{
openZipfile
();
}
else
{
...
...
@@ -207,16 +207,15 @@ InputStreamP Package::openIn(const String& file) {
if
(
filename
.
find
(
_
(
".mse-"
))
!=
String
::
npos
)
{
throw
PackageError
(
_ERROR_2_
(
"file not found package like"
,
file
,
filename
));
}
throw
FileNotFoundError
(
file
,
filename
);
}
InputStreamP
stream
;
if
(
it
->
second
.
wasWritten
())
{
if
(
it
!=
files
.
end
()
&&
it
->
second
.
wasWritten
())
{
// written to this file, open the temp file
stream
=
shared
(
new
BufferedFileInputStream
(
it
->
second
.
tempName
));
}
else
if
(
wxFileExists
(
filename
+
_
(
"/"
)
+
file
))
{
// a file in directory package
stream
=
shared
(
new
BufferedFileInputStream
(
filename
+
_
(
"/"
)
+
file
));
}
else
if
(
wxFileExists
(
filename
)
&&
it
->
second
.
zipEntry
)
{
}
else
if
(
wxFileExists
(
filename
)
&&
it
!=
files
.
end
()
&&
it
->
second
.
zipEntry
)
{
// a file in a zip archive
// somebody in wx thought seeking was no longer needed, it now only works with the 'compatability constructor'
stream
=
shared
(
new
wxZipInputStream
(
filename
,
it
->
second
.
zipEntry
->
GetInternalName
()));
...
...
@@ -339,9 +338,8 @@ void Package::loadZipStream() {
zipStream
->
CloseEntry
();
}
void
Package
::
openDirectory
()
{
zipfile
=
false
;
openSubdir
(
wxEmptyString
);
void
Package
::
openDirectory
(
bool
fast
)
{
if
(
!
fast
)
openSubdir
(
wxEmptyString
);
}
void
Package
::
openSubdir
(
const
String
&
name
)
{
...
...
@@ -368,7 +366,6 @@ void Package::openSubdir(const String& name) {
}
void
Package
::
openZipfile
()
{
zipfile
=
true
;
// close old streams
delete
fileStream
;
fileStream
=
nullptr
;
delete
zipStream
;
zipStream
=
nullptr
;
...
...
@@ -382,7 +379,6 @@ void Package::openZipfile() {
}
void
Package
::
saveToDirectory
(
const
String
&
saveAs
,
bool
remove_unused
,
bool
is_copy
)
{
zipfile
=
false
;
// write to a directory
VCSP
vcs
=
getVCS
();
FOR_EACH
(
f
,
files
)
{
...
...
@@ -414,7 +410,6 @@ void Package::saveToDirectory(const String& saveAs, bool remove_unused, bool is_
}
void
Package
::
saveToZipfile
(
const
String
&
saveAs
,
bool
remove_unused
,
bool
is_copy
)
{
zipfile
=
true
;
// create a temporary zip file name
String
tempFile
=
saveAs
+
_
(
".tmp"
);
wxRemoveFile
(
tempFile
);
...
...
src/util/io/package.hpp
View file @
d1297e23
...
...
@@ -69,13 +69,22 @@ class Package : public IntrusivePtrVirtualBase {
/// The time this package was last modified
inline
wxDateTime
lastModified
()
const
{
return
modified
;
}
/// Open a package, should only be called when the package is constructed using the default constructor!
/// @pre open not called before [TODO]
void
open
(
const
String
&
package
);
/// Open a package
/**
* Should only be called when the package is constructed using the default constructor!
*
* If 'fast' is set, then for directories a full directory listing is not performed.
* This means that the file_infos will not be fully initialized.
*
* @pre open not called before [TODO]
*/
void
open
(
const
String
&
package
,
bool
fast
=
false
);
/// Saves the package, by default saves as a zip file, unless
/// it was already a directory
/** If remove_unused=true all files that were in the file and
/// Saves the package
/**
* By default saves as a zip file, unless it was already a directory.
*
* If remove_unused=true all files that were in the file and
* are not touched with referenceFile will be deleted from the new archive!
* This is a form of garbage collection, to get rid of old picture files for example.
*/
...
...
@@ -140,8 +149,8 @@ class Package : public IntrusivePtrVirtualBase {
// TODO: I dislike putting this here very much. There ought to be a better way.
virtual
VCSP
getVCS
()
{
return
intrusive
(
new
VCS
());
}
/// true if this is a zip file, false if a directory
(updated on open/save)
bool
isZipfile
()
{
return
zipfile
;
}
/// true if this is a zip file, false if a directory
bool
isZipfile
()
const
{
return
!
wxDirExists
(
filename
)
;
}
// --------------------------------------------------- : Private stuff
private:
...
...
@@ -163,9 +172,6 @@ class Package : public IntrusivePtrVirtualBase {
/// Last modified time
DateTime
modified
;
/// Zipfile flag
bool
zipfile
;
public:
/// Information on files in the package
/** Note: must be public for DECLARE_TYPEOF to work */
...
...
@@ -182,7 +188,7 @@ class Package : public IntrusivePtrVirtualBase {
wxZipInputStream
*
zipStream
;
void
loadZipStream
();
void
openDirectory
();
void
openDirectory
(
bool
fast
=
false
);
void
openSubdir
(
const
String
&
);
void
openZipfile
();
void
reopen
();
...
...
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