Skip to content

Commit

Permalink
Export signal: check savefile for null-ness. Resolves #506.
Browse files Browse the repository at this point in the history
  • Loading branch information
bengtmartensson committed Nov 4, 2023
1 parent 3b7ef89 commit b62754e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ protected void possiblyMakeExecutable(File file) {

@Override
public void export(RemoteSet remoteSet, String title, File saveFile, String encoding) throws IOException, TransformerException {
export(remoteSet, title, saveFile.getCanonicalPath(), encoding);
if (saveFile != null)
export(remoteSet, title, saveFile.getCanonicalPath(), encoding);
}

private void export(RemoteSet remoteSet, String title, String fileName, String encoding) throws IOException, TransformerException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ public boolean considersRepetitions() {
}

public void export(Document document, File file, String charsetName) throws FileNotFoundException, UnsupportedEncodingException {
XmlUtils.printDOM(file, document, charsetName, null);
if (file != null)
XmlUtils.printDOM(file, document, charsetName, null);
}

public void export(String payload, File file, String charsetName) throws FileNotFoundException, UnsupportedEncodingException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,13 @@ public boolean supportsEmbeddedFormats() {
@Override
public void export(RemoteSet remoteSet, String title, File file, String charsetName)
throws IOException, GirrException, IrCoreException, IrpException {
try (PrintStream printStream = new PrintStream(file, charsetName)) {
for (Remote remote : remoteSet)
for (CommandSet commandSet : remote)
for (Command command : commandSet)
printStream.println(formatCommand(command, 1));
}
if (file != null)
try (PrintStream printStream = new PrintStream(file, charsetName)) {
for (Remote remote : remoteSet)
for (CommandSet commandSet : remote)
for (Command command : commandSet)
printStream.println(formatCommand(command, 1));
}
}

private String formatCommand(Command command, int count) throws GirrException, IrpException, IrCoreException {
Expand Down

0 comments on commit b62754e

Please sign in to comment.