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");
}
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);
}
}
}
Aggregations