public Schema load() throws IOException { if (sources.isEmpty()) { throw new IllegalStateException("No sources added."); } try (Closer closer = Closer.create()) { // Map the physical path to the file system root. For regular directories the key and the // value are equal. For ZIP files the key is the path to the .zip, and the value is the root // of the file system within it. Map<Path, Path> directories = new LinkedHashMap<>(); for (Path source : sources) { if (Files.isRegularFile(source)) { FileSystem sourceFs = FileSystems.newFileSystem(source, getClass().getClassLoader()); closer.register(sourceFs); directories.put(source, getOnlyElement(sourceFs.getRootDirectories())); } else { directories.put(source, source); } } return loadFromDirectories(directories); } }
public Schema load() throws IOException { if (sources.isEmpty()) { throw new IllegalStateException("No sources added."); } try (Closer closer = Closer.create()) { // Map the physical path to the file system root. For regular directories the key and the // value are equal. For ZIP files the key is the path to the .zip, and the value is the root // of the file system within it. Map<Path, Path> directories = new LinkedHashMap<>(); for (Path source : sources) { if (Files.isRegularFile(source)) { FileSystem sourceFs = FileSystems.newFileSystem(source, getClass().getClassLoader()); closer.register(sourceFs); directories.put(source, getOnlyElement(sourceFs.getRootDirectories())); } else { directories.put(source, source); } } return loadFromDirectories(directories); } }
public Schema load() throws IOException { if (sources.isEmpty()) { throw new IllegalStateException("No sources added."); } try (Closer closer = Closer.create()) { // Map the physical path to the file system root. For regular directories the key and the // value are equal. For ZIP files the key is the path to the .zip, and the value is the root // of the file system within it. Map<Path, Path> directories = new LinkedHashMap<>(); for (Path source : sources) { if (Files.isRegularFile(source)) { FileSystem sourceFs = FileSystems.newFileSystem(source, getClass().getClassLoader()); closer.register(sourceFs); for (Path root : sourceFs.getRootDirectories()) { directories.put(source, root); } } else { directories.put(source, source); } } return loadFromDirectories(directories); } }