use of com.ibm.j9ddr.libraries.FooterLibraryEntry in project openj9 by eclipse.
the class NativeLibrariesCommand method showLibList.
// list the libraries from the core file and report whether or not they have been collected
private void showLibList(Context ctx, PrintStream out) {
LibReader reader = new LibReader();
out.println("Showing library list for " + DDRInteractive.getPath());
Collection<? extends IModule> libs = null;
try {
libs = ctx.process.getModules();
} catch (CorruptDataException e) {
out.println("Corrupt data exception when retrieving list of libraries : " + e.getMessage());
return;
}
getExeFromDDR(ctx, out);
for (IModule lib : libs) {
try {
out.println("Lib : " + lib.getName());
FooterLibraryEntry entry = reader.getEntry(lib.getName());
if (entry == null) {
out.println("\tLibrary is not appended to the core file, it may be present on the local disk");
} else {
out.println("\tLibrary has been collected");
out.println("\tPath : " + entry.getPath());
out.println("\tName : " + entry.getName());
out.println("\tSize : " + entry.getSize());
}
} catch (CorruptDataException e) {
out.println("Library name is corrupt");
}
}
}
use of com.ibm.j9ddr.libraries.FooterLibraryEntry in project openj9 by eclipse.
the class NativeLibrariesCommand method extractLibs.
private void extractLibs(Context ctx, PrintStream out, File path, boolean overwrite) {
if (path == null) {
// no path was specified so derive it from the startup parameters
boolean useCurrentDir = !DDRInteractive.getPath().contains(File.separator);
if (useCurrentDir) {
String curdir = System.getProperty("user.dir");
path = new File(curdir);
} else {
// need to strip off the end file name
path = new File(DDRInteractive.getPath());
if (path.isFile()) {
path = path.getParentFile();
}
}
}
out.println("Extracting libraries to : " + path.getAbsolutePath());
LibReader reader = new LibReader();
try {
for (FooterLibraryEntry entry : reader.getEntries()) {
if (entry == null) {
// skip over null entries in the list
continue;
}
String dir = entry.getPath();
if (dir.charAt(0) == '/') {
// absolute path so convert to a relative one
dir = dir.substring(1);
}
if ((File.separatorChar == '\\') && dir.contains("/")) {
// convert from a linux path to a windows one
dir.replace('/', '\\');
}
File library = new File(path, dir).getCanonicalFile();
// need to create the extraction directory if required
if (library.isFile()) {
if (library.getParentFile() != null) {
library.getParentFile().mkdirs();
}
if (library.exists()) {
if (overwrite) {
out.println("Deleting existing library");
library.delete();
} else {
out.println("Library " + library.getPath() + " already exists on disk so skipping (to overwrite run !dclibs extract overwrite)");
continue;
}
}
} else {
if (!library.getParentFile().equals(path)) {
library.getParentFile().mkdirs();
}
}
out.println("Extracting " + library);
reader.extractLibrary(entry.getPath(), library);
}
} catch (IOException e) {
out.println("Error extracting libraries : " + e.getMessage());
}
}
Aggregations