/** * Returns the target of the given symlink. Returns the empty string if * the given path does not refer to a symlink or there is an error * accessing the symlink. * @param f File representing the symbolic link. * @return The target of the symbolic link, empty string on error or if not * a symlink. */ public static String readLink(File f) { /* NB: Use readSymbolicLink in java.nio.file.Path once available. Could * use getCanonicalPath in File to get the target of the symlink but that * does not indicate if the given path refers to a symlink. */ if (f == null) { LOG.warn("Can not read a null symLink"); return ""; } try { return Shell.execCommand( Shell.getReadlinkCommand(f.toString())).trim(); } catch (IOException x) { return ""; } }
/** * Returns the target of the given symlink. Returns the empty string if * the given path does not refer to a symlink or there is an error * accessing the symlink. * @param f File representing the symbolic link. * @return The target of the symbolic link, empty string on error or if not * a symlink. */ public static String readLink(File f) { /* NB: Use readSymbolicLink in java.nio.file.Path once available. Could * use getCanonicalPath in File to get the target of the symlink but that * does not indicate if the given path refers to a symlink. */ try { return Shell.execCommand( Shell.getReadlinkCommand(f.toString())).trim(); } catch (IOException x) { return ""; } }
/** * Returns the target of the given symlink. Returns the empty string if * the given path does not refer to a symlink or there is an error * accessing the symlink. * @param f File representing the symbolic link. * @return The target of the symbolic link, empty string on error or if not * a symlink. */ public static String readLink(File f) { /* NB: Use readSymbolicLink in java.nio.file.Path once available. Could * use getCanonicalPath in File to get the target of the symlink but that * does not indicate if the given path refers to a symlink. */ try { return Shell.execCommand( Shell.getReadlinkCommand(f.toString())).trim(); } catch (IOException x) { return ""; } }
/** * Returns the target of the given symlink. Returns the empty string if * the given path does not refer to a symlink or there is an error * accessing the symlink. * @param f File representing the symbolic link. * @return The target of the symbolic link, empty string on error or if not * a symlink. */ public static String readLink(File f) { /* NB: Use readSymbolicLink in java.nio.file.Path once available. Could * use getCanonicalPath in File to get the target of the symlink but that * does not indicate if the given path refers to a symlink. */ try { return Shell.execCommand( Shell.getReadlinkCommand(f.toString())).trim(); } catch (IOException x) { return ""; } }
/** * Returns the target of the given symlink. Returns the empty string if * the given path does not refer to a symlink or there is an error * accessing the symlink. * @param f File representing the symbolic link. * @return The target of the symbolic link, empty string on error or if not * a symlink. */ public static String readLink(File f) { /* NB: Use readSymbolicLink in java.nio.file.Path once available. Could * use getCanonicalPath in File to get the target of the symlink but that * does not indicate if the given path refers to a symlink. */ try { return Shell.execCommand( Shell.getReadlinkCommand(f.toString())).trim(); } catch (IOException x) { return ""; } }