use of uk.me.parabola.imgfmt.fs.ImgChannel in project mkgmap by openstreetmap.
the class GmapiBuilder method unzipImg.
private static void unzipImg(String srcImgName, Path destDir) throws IOException {
FileSystem fs = ImgFS.openFs(srcImgName);
for (DirectoryEntry ent : fs.list()) {
String fullname = ent.getFullName();
try (ImgChannel f = fs.open(fullname, "r")) {
String name = displayName(fullname);
if (Objects.equals(name, "."))
continue;
Files.createDirectories(destDir);
copyToFile(f, destDir.resolve(name));
}
}
}
use of uk.me.parabola.imgfmt.fs.ImgChannel in project mkgmap by openstreetmap.
the class FileCopier method addImg.
private void addImg(FileSystem outfs, FileInfo info) {
FileCopier fc = new FileCopier(info.getFilename());
List<SubFileInfo> subFiles = info.subFiles();
for (SubFileInfo sf : subFiles) {
try {
ImgChannel chan = outfs.create(sf.getName());
Closeable sync = fc.add(sf.getName(), chan);
((FileLink) chan).link(sf, sync);
} catch (FileExistsException e) {
log.warn("Could not copy " + sf.getName(), e);
}
}
}
use of uk.me.parabola.imgfmt.fs.ImgChannel in project mkgmap by openstreetmap.
the class MdrBuilder method init.
/**
* Create the mdr file and initialise.
* It has a name that is based on the overview-mapname option, as does
* the associated MDX file.
*
* @param args The command line arguments.
*/
public void init(CommandArgs args) {
String name = args.get("overview-mapname", "osmmap");
String outputDir = args.getOutputDir();
outputName = Utils.joinPath(outputDir, name + "_mdr.img");
ImgChannel mdrChan;
try {
// Create the .img file system/archive
FileSystemParam params = new FileSystemParam();
tmpName = File.createTempFile("mdr", null, new File(outputDir));
tmpName.deleteOnExit();
imgfs = ImgFS.createFs(tmpName.getPath(), params);
// Create the MDR file within the .img
mdrChan = imgfs.create(name.toUpperCase(Locale.ENGLISH) + ".MDR");
} catch (IOException e) {
throw new ExitException("Could not create global index file");
}
// Create the sort description
Sort sort = SrtTextReader.sortForCodepage(args.getCodePage());
// Set the options that we are using for the mdr.
MdrConfig config = new MdrConfig();
config.setHeaderLen(568);
config.setWritable(true);
config.setForDevice(false);
config.setOutputDir(outputDir);
config.setSort(sort);
config.setIndexOptions(args);
// Wrap the MDR channel with the MDRFile object
mdrFile = new MDRFile(mdrChan, config);
try {
ImgChannel srtChan = imgfs.create(name.toUpperCase(Locale.ENGLISH) + ".SRT");
SRTFile srtFile = new SRTFile(srtChan);
srtFile.setSort(sort);
srtFile.write();
// Do not close srtFile here
} catch (FileExistsException e) {
throw new ExitException("Could not create SRT file within index file");
}
}
Aggregations