src/share/classes/org/openjdk/jigsaw/ModuleFile.java
Print this page
*** 24,33 ****
--- 24,34 ----
*/
package org.openjdk.jigsaw;
import java.io.*;
+ import java.nio.charset.Charset;
import java.security.*;
import java.util.*;
import java.util.jar.*;
import java.util.zip.*;
*** 507,536 ****
filesWriter.println(Files.convertSeparator(relativize(destination, file)));
filesWriter.flush();
}
! void remove() throws IOException {
! ModuleFile.Reader.remove(destination);
}
// Removes a module, given its module install directory
! static void remove(File moduleDir) throws IOException {
// Firstly remove any files installed outside of the module dir
File files = new File(moduleDir, "files");
if (files.exists()) {
! try (FileInputStream fis = new FileInputStream(files);
! InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
! BufferedReader in = new BufferedReader(isr)) {
! String filename;
! while ((filename = in.readLine()) != null)
Files.delete(new File(moduleDir,
! Files.platformSeparator(filename)));
}
}
! Files.deleteTree(moduleDir);
}
// Returns the absolute path of the given section type.
private File getDirOfSection(SectionType type) {
if (type == SectionType.NATIVE_LIBS)
--- 508,546 ----
filesWriter.println(Files.convertSeparator(relativize(destination, file)));
filesWriter.flush();
}
! List<IOException> remove() {
! return ModuleFile.Reader.remove(destination);
}
// Removes a module, given its module install directory
! static List<IOException> remove(File moduleDir) {
! List<IOException> excs = new ArrayList<>();
// Firstly remove any files installed outside of the module dir
File files = new File(moduleDir, "files");
if (files.exists()) {
! try {
! List<String> filenames =
! java.nio.file.Files.readAllLines(files.toPath(),
! Charset.forName("UTF-8"));
! for (String fn : filenames) {
! try {
Files.delete(new File(moduleDir,
! Files.platformSeparator(fn)));
! } catch (IOException x) {
! excs.add(x);
}
}
+ } catch (IOException x) {
+ excs.add(x);
+ }
+ }
! excs.addAll(Files.deleteTreeUnchecked(moduleDir.toPath()));
! return excs;
}
// Returns the absolute path of the given section type.
private File getDirOfSection(SectionType type) {
if (type == SectionType.NATIVE_LIBS)