src/solaris/classes/sun/nio/fs/UnixPath.java

Print this page




 641         } else {
 642             // same number of elements
 643             if (thatOffsetCount == thisOffsetCount) {
 644                 if (thisOffsetCount == 0)
 645                     return true;
 646                 int expectedLen = path.length;
 647                 if (this.isAbsolute() && !that.isAbsolute())
 648                     expectedLen--;
 649                 if (that.path.length != expectedLen)
 650                     return false;
 651             } else {
 652                 // this path has more elements so given path must be relative
 653                 if (that.isAbsolute())
 654                     return false;
 655             }
 656         }
 657 
 658         // compare bytes
 659         int thisPos = offsets[thisOffsetCount - thatOffsetCount];
 660         int thatPos = that.offsets[0];
 661         while (thatPos < that.path.length) {



 662             if (this.path[thisPos++] != that.path[thatPos++])
 663                 return false;
 664         }
 665 
 666         return true;
 667     }
 668 
 669     @Override
 670     public int compareTo(Path other) {
 671         int len1 = path.length;
 672         int len2 = ((UnixPath) other).path.length;
 673 
 674         int n = Math.min(len1, len2);
 675         byte v1[] = path;
 676         byte v2[] = ((UnixPath) other).path;
 677 
 678         int k = 0;
 679         while (k < n) {
 680             int c1 = v1[k] & 0xff;
 681             int c2 = v2[k] & 0xff;




 641         } else {
 642             // same number of elements
 643             if (thatOffsetCount == thisOffsetCount) {
 644                 if (thisOffsetCount == 0)
 645                     return true;
 646                 int expectedLen = path.length;
 647                 if (this.isAbsolute() && !that.isAbsolute())
 648                     expectedLen--;
 649                 if (that.path.length != expectedLen)
 650                     return false;
 651             } else {
 652                 // this path has more elements so given path must be relative
 653                 if (that.isAbsolute())
 654                     return false;
 655             }
 656         }
 657 
 658         // compare bytes
 659         int thisPos = offsets[thisOffsetCount - thatOffsetCount];
 660         int thatPos = that.offsets[0];
 661         int thatLen = that.path.length;
 662         if ((thatLen - thatPos) != (path.length - thisPos))
 663             return false;  
 664         while (thatPos < thatLen) {
 665             if (this.path[thisPos++] != that.path[thatPos++])
 666                 return false;
 667         }
 668 
 669         return true;
 670     }
 671 
 672     @Override
 673     public int compareTo(Path other) {
 674         int len1 = path.length;
 675         int len2 = ((UnixPath) other).path.length;
 676 
 677         int n = Math.min(len1, len2);
 678         byte v1[] = path;
 679         byte v2[] = ((UnixPath) other).path;
 680 
 681         int k = 0;
 682         while (k < n) {
 683             int c1 = v1[k] & 0xff;
 684             int c2 = v2[k] & 0xff;