@Override public InputStream open() throws IOException { if (isIllegalSymlink()) { throw new FileNotFoundException(f.getPath()); } try { return Files.newInputStream(f.toPath()); } catch (InvalidPathException e) { throw new IOException(e); } }
@Override public long length() throws IOException { if (isIllegalSymlink()) { return 0; } return f.length(); } @Override public int mode() throws IOException {
@Override public boolean isFile() throws IOException { if (isIllegalSymlink()) { return false; } return f.isFile(); } @Override public boolean exists() throws IOException {
@Override public VirtualFile[] list() throws IOException { if (isIllegalSymlink()) { return new VirtualFile[0]; } File[] kids = f.listFiles(); if (kids == null) { return new VirtualFile[0]; } VirtualFile[] vfs = new VirtualFile[kids.length]; for (int i = 0; i < kids.length; i++) { vfs[i] = new FileVF(kids[i], root); } return vfs; } @Override public String[] list(String glob) throws IOException {
@Override public InputStream open() throws IOException { if (isIllegalSymlink()) { throw new FileNotFoundException(f.getPath()); } try { return Files.newInputStream(f.toPath()); } catch (InvalidPathException e) { throw new IOException(e); } } private boolean isIllegalSymlink() { // TODO JENKINS-26838
@Override public boolean canRead() throws IOException { if (isIllegalSymlink()) { return false; } return f.canRead(); } @Override public InputStream open() throws IOException {
@Override public boolean exists() throws IOException { if (isIllegalSymlink()) { return false; } return f.exists(); } @Override public VirtualFile[] list() throws IOException {
@Override public boolean isDirectory() throws IOException { if (isIllegalSymlink()) { return false; } return f.isDirectory(); } @Override public boolean isFile() throws IOException {
@Override public String[] list(String glob) throws IOException { if (isIllegalSymlink()) { return new String[0]; } return new Scanner(glob).invoke(f, null); } @Override public VirtualFile child(String name) {
@Override public boolean isFile() throws IOException { if (isIllegalSymlink()) { return false; } return f.isFile(); } @Override public boolean exists() throws IOException {
@Override public long lastModified() throws IOException { if (isIllegalSymlink()) { return 0; } return f.lastModified(); } @Override public boolean canRead() throws IOException {
@Override public long length() throws IOException { if (isIllegalSymlink()) { return 0; } return f.length(); } @Override public long lastModified() throws IOException {
@Override public boolean canRead() throws IOException { if (isIllegalSymlink()) { return false; } return f.canRead(); } @Override public InputStream open() throws IOException {
@Override public boolean exists() throws IOException { if (isIllegalSymlink()) { return false; } return f.exists(); } @Override public String readLink() throws IOException {
@Override public VirtualFile[] list() throws IOException { if (isIllegalSymlink()) { return new VirtualFile[0]; } File[] kids = f.listFiles(); if (kids == null) { return new VirtualFile[0]; } VirtualFile[] vfs = new VirtualFile[kids.length]; for (int i = 0; i < kids.length; i++) { vfs[i] = new FileVF(kids[i], root); } return vfs; } @Override
@Override public long lastModified() throws IOException { if (isIllegalSymlink()) { return 0; } return f.lastModified(); } @Override public boolean canRead() throws IOException {
@Override public int mode() throws IOException { if (isIllegalSymlink()) { return -1; } return IOUtils.mode(f); } @Override public long lastModified() throws IOException {
@Override public Collection<String> list(String includes, String excludes, boolean useDefaultExcludes) throws IOException { if (isIllegalSymlink()) { return Collections.emptySet(); } return new Scanner(includes, excludes, useDefaultExcludes).invoke(f, null); } @Override public VirtualFile child(String name) {
@Override public String readLink() throws IOException { if (isIllegalSymlink()) { return null; // best to just ignore link -> ../whatever } return Util.resolveSymlink(f); } @Override public VirtualFile[] list() throws IOException {
@Override public boolean isDirectory() throws IOException { if (isIllegalSymlink()) { return false; } return f.isDirectory(); } @Override public boolean isFile() throws IOException {