List of utility methods to do File Link
void | addSymlinkToFileInsideWorkspace() add Symlink To File Inside Workspace Files.createSymbolicLink(Paths.get(TEST_DIR, "SymlinkFile"), Paths.get("Dir1", "out.txt")); |
File | createRelativeSymlink(File link, File target, boolean relativize) create Relative Symlink if (relativize) { link = link.getCanonicalFile(); target = target.getCanonicalFile(); try { target = link.getParentFile().toPath().relativize(target.toPath()).toFile(); } catch (Throwable e) { return Files.createSymbolicLink(link.toPath(), target.toPath()).toFile(); |
File | createSymbolicLink(@Nonnull File symlink, File target) create Symbolic Link Path link = symlink.toPath(); if (!Files.exists(link, LinkOption.NOFOLLOW_LINKS)) { link = java.nio.file.Files.createSymbolicLink(link, target.toPath()); return link.toFile(); |
void | createSymbolicLink(File pTargetFile, File pLink) Wrapper for creating a symbolic link using java.nio Path target = Paths.get(pTargetFile.toURI()); Path link = Paths.get(pLink.toURI()); Files.createSymbolicLink(link, target); |
boolean | followLinks(LinkOption... options) Returns true if symbolic links should be followed boolean followLinks = true; for (LinkOption option : options) { if (option == LinkOption.NOFOLLOW_LINKS) { followLinks = false; } else if (option == null) { throw new NullPointerException(); } else { throw new AssertionError("Should not get here"); ... |
LinkOption[] | getLinkOptions(boolean followLinks) get Link Options if (followLinks) { return EMPTY_LINK_OPTIONS; } else { return NO_FOLLOW_OPTIONS.clone(); |
boolean | isLink(File f) is Link return Files.isSymbolicLink(Paths.get(f.getPath()));
|
boolean | isSymbolicLink(File file) is Symbolic Link try { File canonicalFile = file.getCanonicalFile(); File absoluteFile = file.getAbsoluteFile(); return !canonicalFile.getName().equals(absoluteFile.getName()) || !canonicalFile.getParent().equals(absoluteFile.getParentFile().getCanonicalPath()); } catch (IOException e) { return true; |
boolean | isSymbolicLink(String file) returns true for symbolic link , also "soft" link for windows, it is creates using mklink /D Link Target uses rmdir to remove soft links on windows. Path path = Paths.get(file); boolean isSymbolicLink = Files.isSymbolicLink(path); return isSymbolicLink; |
boolean | isSymlink(File file) is Symlink return Files.isSymbolicLink(file.toPath());
|