(byte[] pathBytes, int length,
boolean resolveAbsolute)
| 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. |
no test coverage detected