MCPcopy Create free account
hub / github.com/davidgiven/luje / resolveLink

Method resolveLink

lib/java/io/File.java:630–662  ·  view source on GitHub ↗
(byte[] pathBytes, int length,
            boolean resolveAbsolute)

Source from the content-addressed store, hash-verified

628 * directories if resolveAbsolute is true.
629 */
630 private byte[] resolveLink(byte[] pathBytes, int length,
631 boolean resolveAbsolute) throws IOException {
632 boolean restart = false;
633 byte[] linkBytes, temp;
634 do {
635 linkBytes = getLinkImpl(pathBytes);
636 if (linkBytes == pathBytes) {
637 break;
638 }
639 if (linkBytes[0] == separatorChar) {
640 // link to an absolute path, if resolving absolute paths,
641 // resolve the parent dirs again
642 restart = resolveAbsolute;
643 pathBytes = linkBytes;
644 } else {
645 int last = length - 1;
646 while (pathBytes[last] != separatorChar) {
647 last--;
648 }
649 last++;
650 temp = new byte[last + linkBytes.length];
651 System.arraycopy(pathBytes, 0, temp, 0, last);
652 System.arraycopy(linkBytes, 0, temp, last, linkBytes.length);
653 pathBytes = temp;
654 }
655 length = pathBytes.length;
656 } while (existsImpl(pathBytes));
657 // resolve the parent directories
658 if (restart) {
659 return resolve(pathBytes);
660 }
661 return pathBytes;
662 }
663
664 /**
665 * Returns a new file created using the canonical path of this file.

Callers 2

getCanonicalPathMethod · 0.95
resolveMethod · 0.95

Calls 4

getLinkImplMethod · 0.95
arraycopyMethod · 0.95
existsImplMethod · 0.95
resolveMethod · 0.95

Tested by

no test coverage detected