345 try {
346 Path jimageFile = mdir.resolve(BasicImageWriter.MODULES_IMAGE_NAME);
347 OutputStream fos = Files.newOutputStream(jimageFile);
348 BufferedOutputStream bos = new BufferedOutputStream(fos);
349 return new DataOutputStream(bos);
350 } catch (IOException ex) {
351 throw new UncheckedIOException(ex);
352 }
353 }
354
355 /**
356 * Returns the file name of this entry
357 */
358 private String entryToFileName(ResourcePoolEntry entry) {
359 if (entry.type() == ResourcePoolEntry.Type.CLASS_OR_RESOURCE)
360 throw new IllegalArgumentException("invalid type: " + entry);
361
362 String module = "/" + entry.moduleName() + "/";
363 String filename = entry.path().substring(module.length());
364
365 // Remove radical native|config|...
366 return filename.substring(filename.indexOf('/') + 1);
367 }
368
369 /**
370 * Returns the path of the given entry to be written in the image
371 */
372 private Path entryToImagePath(ResourcePoolEntry entry) {
373 switch (entry.type()) {
374 case NATIVE_LIB:
375 String filename = entryToFileName(entry);
376 return Paths.get(nativeDir(filename), filename);
377 case NATIVE_CMD:
378 return Paths.get(BIN_DIRNAME, entryToFileName(entry));
379 case CONFIG:
380 return Paths.get(CONF_DIRNAME, entryToFileName(entry));
381 case HEADER_FILE:
382 return Paths.get(INCLUDE_DIRNAME, entryToFileName(entry));
383 case MAN_PAGE:
384 return Paths.get(MAN_DIRNAME, entryToFileName(entry));
385 case LEGAL_NOTICE:
|
345 try {
346 Path jimageFile = mdir.resolve(BasicImageWriter.MODULES_IMAGE_NAME);
347 OutputStream fos = Files.newOutputStream(jimageFile);
348 BufferedOutputStream bos = new BufferedOutputStream(fos);
349 return new DataOutputStream(bos);
350 } catch (IOException ex) {
351 throw new UncheckedIOException(ex);
352 }
353 }
354
355 /**
356 * Returns the file name of this entry
357 */
358 private String entryToFileName(ResourcePoolEntry entry) {
359 if (entry.type() == ResourcePoolEntry.Type.CLASS_OR_RESOURCE)
360 throw new IllegalArgumentException("invalid type: " + entry);
361
362 String module = "/" + entry.moduleName() + "/";
363 String filename = entry.path().substring(module.length());
364
365 // Remove radical lib|config|...
366 return filename.substring(filename.indexOf('/') + 1);
367 }
368
369 /**
370 * Returns the path of the given entry to be written in the image
371 */
372 private Path entryToImagePath(ResourcePoolEntry entry) {
373 switch (entry.type()) {
374 case NATIVE_LIB:
375 String filename = entryToFileName(entry);
376 return Paths.get(nativeDir(filename), filename);
377 case NATIVE_CMD:
378 return Paths.get(BIN_DIRNAME, entryToFileName(entry));
379 case CONFIG:
380 return Paths.get(CONF_DIRNAME, entryToFileName(entry));
381 case HEADER_FILE:
382 return Paths.get(INCLUDE_DIRNAME, entryToFileName(entry));
383 case MAN_PAGE:
384 return Paths.get(MAN_DIRNAME, entryToFileName(entry));
385 case LEGAL_NOTICE:
|