diff --git a/build/build-testacant.xml b/build/build-testacant.xml
new file mode 100644
index 0000000..29ed366
--- /dev/null
+++ b/build/build-testacant.xml
@@ -0,0 +1,98 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Testing ant support from version ${acVersion}...
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/com/webcodepro/applecommander/ui/AntTask.java b/src/com/webcodepro/applecommander/ui/AntTask.java
index 1b40b92..cdd84ed 100644
--- a/src/com/webcodepro/applecommander/ui/AntTask.java
+++ b/src/com/webcodepro/applecommander/ui/AntTask.java
@@ -19,24 +19,64 @@ package com.webcodepro.applecommander.ui;
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+import java.io.File;
import java.io.IOException;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
+import com.webcodepro.applecommander.storage.Disk;
+import com.webcodepro.applecommander.storage.FormattedDisk;
public class AntTask extends Task
{
public void execute() throws BuildException
{
/*
- * Commands: p, cc65, n, k
- * p: []
+ * Commands:
* cc65:
+ * d:
+ * e:
+ * i:
+ * k/u:
+ * ls/l/ll:
* n:
- * k:
- *
+ * p: []
+ * x:
+ * dos140:
+ * pro140/pro800:
+ * pas140/pas800:
+ * unshrink:
*/
- if (_command.equals("p") || (_command.equals("cc65")))
+ if (_command.equals("i"))
+ {
+ try
+ {
+ String[] onlyOneImage = { "nonsense", _imageName };
+ com.webcodepro.applecommander.ui.ac.getDiskInfo(onlyOneImage);
+ }
+ catch (Exception ex)
+ {
+ if (_failonerror)
+ throw new BuildException(ex);
+ else
+ System.out.println(ex.getMessage());
+ }
+ }
+ else if (_command.equals("e") || _command.equals("g"))
+ {
+ try
+ {
+ com.webcodepro.applecommander.ui.ac.getFile(_imageName, _fileName, _command.equals("e"));
+ }
+ catch (Exception ex)
+ {
+ if (_failonerror)
+ throw new BuildException(ex);
+ else
+ System.out.println(ex.getMessage());
+ }
+ }
+ else if (_command.equals("p") || (_command.equals("cc65")))
{
try
{
@@ -47,42 +87,157 @@ public class AntTask extends Task
}
catch (Exception ex)
{
- throw new BuildException(ex);
+ if (_failonerror)
+ throw new BuildException(ex);
+ else
+ System.out.println(ex.getMessage());
+ }
+ }
+ else if (_command.equals("d"))
+ {
+ try
+ {
+ com.webcodepro.applecommander.ui.ac.deleteFile(_imageName, _fileName);
+ }
+ catch (IOException io)
+ {
+ if (_failonerror)
+ throw new BuildException(io);
+ else
+ System.out.println(io.getMessage());
+ }
+ }
+ else if (_command.equals("n"))
+ {
+ try
+ {
+ com.webcodepro.applecommander.ui.ac.setDiskName(_imageName, _volName);
+ }
+ catch (IOException io)
+ {
+ if (_failonerror)
+ throw new BuildException(io);
+ else
+ System.out.println(io.getMessage());
+ }
+ }
+ else if (_command.equals("k") || _command.equals("u"))
+ {
+ try
+ {
+ if (_command.equals("k"))
+ com.webcodepro.applecommander.ui.ac.setFileLocked(_imageName, _fileName, true);
+ else // Assume unlock
+ com.webcodepro.applecommander.ui.ac.setFileLocked(_imageName, _fileName, false);
+ }
+ catch (IOException io)
+ {
+ if (_failonerror)
+ throw new BuildException(io);
+ else
+ System.out.println(io.getMessage());
+ }
+ }
+ else if (_command.equals("ls") || _command.equals("l") || _command.equals("ll"))
+ {
+ try
+ {
+ String[] onlyOneImage = { "nonsense", _imageName };
+ if (_command.equals("ls"))
+ com.webcodepro.applecommander.ui.ac.showDirectory(onlyOneImage, FormattedDisk.FILE_DISPLAY_STANDARD);
+ else if (_command.equals("l"))
+ com.webcodepro.applecommander.ui.ac.showDirectory(onlyOneImage, FormattedDisk.FILE_DISPLAY_NATIVE);
+ else // Assume "ll"
+ com.webcodepro.applecommander.ui.ac.showDirectory(onlyOneImage, FormattedDisk.FILE_DISPLAY_DETAIL);
+ }
+ catch (IOException io)
+ {
+ if (_failonerror)
+ throw new BuildException(io);
+ else
+ System.out.println(io.getMessage());
+ }
+ }
+ else if (_command.equals("dos140"))
+ {
+ try
+ {
+ com.webcodepro.applecommander.ui.ac.createDosDisk(_imageName, Disk.APPLE_140KB_DISK);
+ }
+ catch (IOException io)
+ {
+ if (_failonerror)
+ throw new BuildException(io);
+ else
+ System.out.println(io.getMessage());
+ }
+ }
+ else if ((_command.equals("pro800") || _command.equals("pro140")))
+ {
+ try
+ {
+ if (_command.equals("pro800"))
+ com.webcodepro.applecommander.ui.ac.createProDisk(_imageName, _volName, Disk.APPLE_800KB_DISK);
+ else
+ com.webcodepro.applecommander.ui.ac.createProDisk(_imageName, _volName, Disk.APPLE_140KB_DISK);
+ }
+ catch (IOException io)
+ {
+ if (_failonerror)
+ throw new BuildException(io);
+ else
+ System.out.println(io.getMessage());
+ }
+ }
+ else if ((_command.equals("pas800") || _command.equals("pas140")))
+ {
+ try
+ {
+ if (_command.equals("pas800"))
+ com.webcodepro.applecommander.ui.ac.createPasDisk(_imageName, _volName, Disk.APPLE_800KB_DISK);
+ else
+ com.webcodepro.applecommander.ui.ac.createPasDisk(_imageName, _volName, Disk.APPLE_140KB_DISK);
+ }
+ catch (IOException io)
+ {
+ if (_failonerror)
+ throw new BuildException(io);
+ else
+ System.out.println(io.getMessage());
+ }
+ }
+ else if (_command.equals("x"))
+ {
+ try
+ {
+ com.webcodepro.applecommander.ui.ac.getFiles(_imageName, _outputPath);
+ }
+ catch (IOException io)
+ {
+ if (_failonerror)
+ throw new BuildException(io);
+ else
+ System.out.println(io.getMessage());
+ }
+ }
+ else if (_command.equals("unshrink"))
+ {
+ try
+ {
+ com.webcodepro.applecommander.ui.ac.unshrink(_fileName, _imageName);
+ }
+ catch (IOException io)
+ {
+ if (_failonerror)
+ throw new BuildException(io);
+ else
+ System.out.println(io.getMessage());
}
}
else
{
- if (_command.equals("n"))
- {
- try
- {
- com.webcodepro.applecommander.ui.ac.setDiskName(_imageName, _volName);
- }
- catch (IOException io)
- {
- throw new BuildException(io);
- }
- }
- else
- {
- if (_command.equals("k"))
- {
- try
- {
- com.webcodepro.applecommander.ui.ac.setFileLocked(_imageName, _fileName, true);
- }
- catch (IOException io)
- {
- throw new BuildException(io);
- }
- }
- else
- {
- throw new BuildException("Command \""+_command+"\" not implemented.");
- }
- }
+ throw new BuildException("Command \"" + _command + "\" not implemented.");
}
-
}
public void setCommand(String command)
@@ -105,6 +260,11 @@ public class AntTask extends Task
_fileName = fileName;
}
+ public void setOutputPath(String outputPath)
+ {
+ _outputPath = outputPath;
+ }
+
public void setVolumeName(String volumeName)
{
_volName = volumeName;
@@ -120,6 +280,16 @@ public class AntTask extends Task
_address = address;
}
+ public void setFailOnError(String failonerror)
+ {
+ if (failonerror.equalsIgnoreCase("true"))
+ _failonerror = true;
+ if (failonerror.equalsIgnoreCase("false"))
+ _failonerror = false;
+ }
+
+ boolean _failonerror = true;
+
String _input = null;
String _command = null;
@@ -128,7 +298,9 @@ public class AntTask extends Task
String _fileName = null;
- String _volName = null;
+ String _volName = "ACDISK";
+
+ String _outputPath = null;
String _type = null;
diff --git a/src/com/webcodepro/applecommander/ui/ac.java b/src/com/webcodepro/applecommander/ui/ac.java
index 66d2bf3..4128aca 100644
--- a/src/com/webcodepro/applecommander/ui/ac.java
+++ b/src/com/webcodepro/applecommander/ui/ac.java
@@ -99,16 +99,16 @@ 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], new Name(args[2]), true);
+ getFile(args[1], args[2], true);
} 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], new Name(args[2]), false);
+ getFile(args[1], args[2], false);
} else if ("-p".equalsIgnoreCase(args[0])) { //$NON-NLS-1$
putFile(args[1], new Name(args[2]), args[3],
(args.length > 4 ? args[4] : "0x2000"));
} else if ("-d".equalsIgnoreCase(args[0])) { //$NON-NLS-1$
- deleteFile(args[1], new Name(args[2]));
+ deleteFile(args[1], args[2]);
} else if ("-k".equalsIgnoreCase(args[0])) { //$NON-NLS-1$
setFileLocked(args[1], args[2], true);
} else if ("-u".equalsIgnoreCase(args[0])) { //$NON-NLS-1$
@@ -247,9 +247,10 @@ public class ac {
/**
* Delete the file named fileName from the disk named imageName.
*/
- static void deleteFile(String imageName, Name name)
+ static void deleteFile(String imageName, String fileName)
throws IOException {
Disk disk = new Disk(imageName);
+ Name name = new Name(fileName);
if (!disk.isSDK()) {
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
for (int i = 0; i < formattedDisks.length; i++) {
@@ -272,9 +273,10 @@ 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, Name name, boolean filter)
+ static void getFile(String imageName, String fileName, boolean filter)
throws IOException {
Disk disk = new Disk(imageName);
+ Name name = new Name(fileName);
FormattedDisk[] formattedDisks = disk.getFormattedDisks();
for (int i = 0; i < formattedDisks.length; i++) {
FormattedDisk formattedDisk = formattedDisks[i];
@@ -302,7 +304,7 @@ public class ac {
*/
static void getFiles(String imageName, String directory) throws IOException {
Disk disk = new Disk(imageName);
- if (directory.length() > 0) {
+ if ((directory != null) && (directory.length() > 0)) {
// Add a final directory separator if the user didn't supply one
if (!directory.endsWith(File.separator))
directory = directory + File.separator;