Hi Andre,

> I just accidentally found an issue in mkgmap. When creating a
> gmapsupp.img with a TYP file, mkgmap throws an exception if this file is
> readonly. When the TYP file is writable, this exception is not thrown.
> But I think, that mkgmap should never write to a TYP file, should it?

The attached patch should solve this issue.

Steve, shall I commit this?

Cheers,

Mark

diff --git a/src/uk/me/parabola/imgfmt/sys/FileImgChannel.java b/src/uk/me/parabola/imgfmt/sys/FileImgChannel.java
index d1a6907..3344a18 100644
--- a/src/uk/me/parabola/imgfmt/sys/FileImgChannel.java
+++ b/src/uk/me/parabola/imgfmt/sys/FileImgChannel.java
@@ -36,9 +36,13 @@ public class FileImgChannel implements ImgChannel {
 	private long position;
 
 	public FileImgChannel(String filename) {
+		this(filename, "rw");
+	}
+
+	public FileImgChannel(String filename, String mode) {
 		RandomAccessFile raf;
 		try {
-			raf = new RandomAccessFile(filename, "rw");
+			raf = new RandomAccessFile(filename, mode);
 		} catch (FileNotFoundException e) {
 			throw new ReadFailedException("Couldnot open " + filename, e);
 		}
diff --git a/src/uk/me/parabola/mkgmap/combiners/GmapsuppBuilder.java b/src/uk/me/parabola/mkgmap/combiners/GmapsuppBuilder.java
index 4d9e383..e5537e1 100644
--- a/src/uk/me/parabola/mkgmap/combiners/GmapsuppBuilder.java
+++ b/src/uk/me/parabola/mkgmap/combiners/GmapsuppBuilder.java
@@ -185,7 +185,7 @@ public class GmapsuppBuilder implements Combiner {
 	 * @param filename The input filename.
 	 */
 	private void addFile(FileSystem outfs, String filename) {
-		ImgChannel chan = new FileImgChannel(filename);
+		ImgChannel chan = new FileImgChannel(filename, "r");
 		try {
 			String imgname = createImgFilename(filename);
 			copyFile(chan, outfs, imgname);
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to