Search in sources :

Example 21 with MapFailedException

use of uk.me.parabola.imgfmt.MapFailedException in project mkgmap by openstreetmap.

the class MdrBuilder method onFinish.

/**
 * Called after all maps are processed.
 *
 * We are building a standalone mdr file, so that is
 */
public void onFinish() {
    // Write out the mdr file
    mdrFile.write();
    // Close the mdr.img file, thus causing it to be written out fully.
    imgfs.close();
    // Rename from the temporary file to the proper name. On windows the target file must
    // not exist for rename to work, so we are forced to remove it first.
    File outputName = new File(this.outputName);
    outputName.delete();
    boolean ok = tmpName.renameTo(outputName);
    if (!ok)
        throw new MapFailedException("Could not create mdr.img file");
}
Also used : MapFailedException(uk.me.parabola.imgfmt.MapFailedException) SRTFile(uk.me.parabola.imgfmt.app.srt.SRTFile) File(java.io.File) MDRFile(uk.me.parabola.imgfmt.app.mdr.MDRFile)

Example 22 with MapFailedException

use of uk.me.parabola.imgfmt.MapFailedException in project mkgmap by openstreetmap.

the class HGTReader method prepRead.

public void prepRead() {
    if (!read && path != null) {
        try {
            if (count == 0)
                log.info("allocating buffer for", fileName);
            else
                log.warn("re-allocating buffer for", fileName);
            if (path.endsWith(".zip"))
                extractFromZip(path, fileName);
            else {
                try (FileInputStream is = new FileInputStream(path)) {
                    buffer = is.getChannel().map(READ_ONLY, 0, is.getChannel().size());
                    read = true;
                }
            }
        } catch (FileNotFoundException e) {
            throw new MapFailedException("previously existing file is missing: " + path);
        } catch (IOException e) {
            log.error("failed to create buffer for file", path);
        }
    }
}
Also used : MapFailedException(uk.me.parabola.imgfmt.MapFailedException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream)

Aggregations

MapFailedException (uk.me.parabola.imgfmt.MapFailedException)22 IOException (java.io.IOException)11 File (java.io.File)4 FileNotFoundException (java.io.FileNotFoundException)4 TypData (uk.me.parabola.imgfmt.app.typ.TypData)3 SyntaxException (uk.me.parabola.mkgmap.scan.SyntaxException)3 FileInputStream (java.io.FileInputStream)2 OutOfMemoryError (java.lang.OutOfMemoryError)2 ExitException (uk.me.parabola.imgfmt.ExitException)2 FileNotWritableException (uk.me.parabola.imgfmt.FileNotWritableException)2 TYPFile (uk.me.parabola.imgfmt.app.typ.TYPFile)2 Path2D (java.awt.geom.Path2D)1 Rectangle2D (java.awt.geom.Rectangle2D)1 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MemoryPoolMXBean (java.lang.management.MemoryPoolMXBean)1 MemoryUsage (java.lang.management.MemoryUsage)1 ByteBuffer (java.nio.ByteBuffer)1