mirror of
https://github.com/AppleCommander/AppleCommander.git
synced 2024-12-22 08:30:35 +00:00
Allow extraction to a file name for the ant task
This commit is contained in:
parent
6526cf3e0b
commit
b52df7745b
@ -19,7 +19,9 @@ package com.webcodepro.applecommander.ui;
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
|
||||
import org.apache.tools.ant.BuildException;
|
||||
import org.apache.tools.ant.Task;
|
||||
@ -63,9 +65,14 @@ public class AntTask extends Task
|
||||
}
|
||||
else if (_command.equals("e") || _command.equals("g"))
|
||||
{
|
||||
PrintStream outfile = System.out;
|
||||
try
|
||||
{
|
||||
com.webcodepro.applecommander.ui.ac.getFile(_imageName, _fileName, _command.equals("e"));
|
||||
if (_output != null)
|
||||
{
|
||||
outfile = new PrintStream(new FileOutputStream(_output));
|
||||
}
|
||||
com.webcodepro.applecommander.ui.ac.getFile(_imageName, _fileName, _command.equals("e"), outfile);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -251,6 +258,11 @@ public class AntTask extends Task
|
||||
_input = input;
|
||||
}
|
||||
|
||||
public void setOutput(String output)
|
||||
{
|
||||
_output = output;
|
||||
}
|
||||
|
||||
public void setImageName(String imageName)
|
||||
{
|
||||
_imageName = imageName;
|
||||
@ -298,6 +310,8 @@ public class AntTask extends Task
|
||||
|
||||
String _input = null;
|
||||
|
||||
String _output = null;
|
||||
|
||||
String _command = null;
|
||||
|
||||
String _imageName = null;
|
||||
|
@ -28,6 +28,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
@ -99,11 +100,11 @@ public class ac {
|
||||
} else if ("-ll".equalsIgnoreCase(args[0])) { //$NON-NLS-1$
|
||||
showDirectory(args, FormattedDisk.FILE_DISPLAY_DETAIL);
|
||||
} else if ("-e".equalsIgnoreCase(args[0])) { //$NON-NLS-1$
|
||||
getFile(args[1], args[2], true);
|
||||
getFile(args[1], args[2], true, System.out);
|
||||
} else if ("-x".equalsIgnoreCase(args[0])) { //$NON-NLS-1$
|
||||
getFiles(args[1], (args.length > 2 ? args[2] : ""));
|
||||
} else if ("-g".equalsIgnoreCase(args[0])) { //$NON-NLS-1$
|
||||
getFile(args[1], args[2], false);
|
||||
getFile(args[1], args[2], false, System.out);
|
||||
} else if ("-p".equalsIgnoreCase(args[0])) { //$NON-NLS-1$
|
||||
putFile(args[1], new Name(args[2]), args[3],
|
||||
(args.length > 4 ? args[4] : "0x2000"));
|
||||
@ -206,7 +207,10 @@ public class ac {
|
||||
entry.setAddress(stringToInt(address));
|
||||
}
|
||||
formattedDisk.save();
|
||||
} else {
|
||||
throw new IOException("Unable to create entry...");
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
throw new IOException(textBundle.get("CommandLineSDKReadOnly")); //$NON-NLS-1$
|
||||
@ -278,11 +282,13 @@ public class ac {
|
||||
* Get the file named filename from the disk named imageName; the file is
|
||||
* filtered according to its type and sent to <stdout>.
|
||||
*/
|
||||
static void getFile(String imageName, String fileName, boolean filter)
|
||||
static void getFile(String imageName, String fileName, boolean filter, PrintStream out)
|
||||
throws IOException {
|
||||
Disk disk = new Disk(imageName);
|
||||
Name name = new Name(fileName);
|
||||
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
|
||||
if (out == null)
|
||||
out = System.out;
|
||||
for (int i = 0; i < formattedDisks.length; i++) {
|
||||
FormattedDisk formattedDisk = formattedDisks[i];
|
||||
FileEntry entry = name.getEntry(formattedDisk);
|
||||
@ -292,10 +298,10 @@ public class ac {
|
||||
if (ff instanceof BinaryFileFilter)
|
||||
ff = new HexDumpFileFilter();
|
||||
byte[] buf = ff.filter(entry);
|
||||
System.out.write(buf, 0, buf.length);
|
||||
out.write(buf, 0, buf.length);
|
||||
} else {
|
||||
byte[] buf = entry.getFileData();
|
||||
System.out.write(buf, 0, buf.length);
|
||||
out.write(buf, 0, buf.length);
|
||||
}
|
||||
} else {
|
||||
System.err.println(textBundle.format(
|
||||
|
Loading…
Reference in New Issue
Block a user