public static FsFile newFile(File file) { return new FileFsFile(file); }
public static FsFile newFile(File file) { return new FileFsFile(file); }
public static FsFile newFile(String filePath) { return new FileFsFile(filePath); }
@Override public FsFile[] listFiles(final Filter filter) { return asFsFiles(file.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { return filter.accept(new FileFsFile(pathname)); } })); }
@Override public boolean accept(File pathname) { return filter.accept(new FileFsFile(pathname)); } }));
public static FsFile fileFromPath(String urlString) { if (urlString.startsWith("jar:")) { String[] parts = urlString.replaceFirst("jar:", "").split("!"); Fs fs = new JarFs(new File(parts[0])); return fs.join(parts[1].substring(1)); } else { return new FileFsFile(new File(urlString)); } }
/** * @deprecated Use {@link #fromURL(URL)} instead. */ @Deprecated public static FsFile fileFromPath(String urlString) { if (urlString.startsWith("jar:")) { String[] parts = urlString.replaceFirst("jar:", "").split("!", 0); Fs fs = new JarFs(new File(parts[0])); return fs.join(parts[1].substring(1)); } else { return new FileFsFile(new File(urlString)); } }
/** * Construct an FileFsFile from a series of path components. Path components that are * null or empty string will be ignored. * * @param paths Array of path components. * @return New FileFsFile. */ @NotNull public static FileFsFile from(String... paths) { File file = null; for (String path : paths) { if (path != null && path.length() > 0) { for (String part : path.split(Pattern.quote(FILE_SEPARATOR))) { if (file != null && part.equals(".")) continue; file = (file == null) ? new File(part) : new File(file, part); } } } return new FileFsFile(file); } }
/** * Construct an FileFsFile from a series of path components. Path components that are * null or empty string will be ignored. * * @param paths Array of path components. * @return New FileFsFile. */ @Nonnull public static FileFsFile from(String... paths) { File file = null; for (String path : paths) { if (path != null && path.length() > 0) { for (String part : path.split(Pattern.quote(FILE_SEPARATOR), 0)) { if (file != null && part.equals(".")) continue; file = (file == null) ? new File(part) : new File(file, part); } } } return new FileFsFile(file); } }
public static FsFile fromURL(URL url) { switch (url.getProtocol()) { case "file": return new FileFsFile(new File(url.getPath())); case "jar": String[] parts = url.getPath().split("!", 0); try { Fs fs = fromJar(new URL(parts[0])); return fs.join(parts[1].substring(1)); } catch (MalformedURLException e) { throw new IllegalArgumentException(e); } default: throw new IllegalArgumentException("unsupported fs type for '" + url + "'"); } }
@Override public FsFile[] listFiles(final Filter filter) { return asFsFiles(file.listFiles(pathname -> filter.accept(new FileFsFile(pathname)))); }
public static ResName qualifyFromFilePath(@NotNull final String packageName, @NotNull final String filePath) { final FileFsFile filePathFile = new FileFsFile(new File(filePath)); final String type = filePathFile.getParent().getName().split("-")[0]; final String name = filePathFile.getBaseName(); return new ResName(packageName, type, name); }
public static ResName qualifyFromFilePath(@Nonnull final String packageName, @Nonnull final String filePath) { final FileFsFile filePathFile = new FileFsFile(new File(filePath)); final String type = filePathFile.getParent().getName().split("-", 0)[0]; final String name = filePathFile.getBaseName(); return new ResName(packageName, type, name); }