@@ -95,7 +95,7 @@ class Path private[io] (val jpath: JPath) {
9595 /** Creates a new Path with the specified path appended. Assumes
9696 * the type of the new component implies the type of the result.
9797 */
98- def / (child : Path ): Path = if (isEmpty) child else new Path (jpath. resolve(child.path) )
98+ def / (child : Path ): Path = resolve(child)
9999 def / (child : Directory ): Directory = / (child : Path ).toDirectory
100100 def / (child : File ): File = / (child : Path ).toFile
101101
@@ -121,19 +121,8 @@ class Path private[io] (val jpath: JPath) {
121121 def path : String = jpath.toString
122122 def normalize : Path = Path (jpath.normalize)
123123
124- def resolve (other : Path ) = if (other.isAbsolute || isEmpty) other else / (other)
125- def relativize (other : Path ) = {
126- assert(isAbsolute == other.isAbsolute, " Paths not of same type: " + this + " , " + other)
127-
128- def createRelativePath (baseSegs : List [String ], otherSegs : List [String ]) : String = {
129- (baseSegs, otherSegs) match {
130- case (b :: bs, o :: os) if b == o => createRelativePath(bs, os)
131- case (bs, os) => ((" .." + separator)* bs.length)+ os.mkString(separatorStr)
132- }
133- }
134-
135- Path (createRelativePath(segments, other.segments))
136- }
124+ def resolve (other : Path ) = Path (jpath.resolve(other.jpath))
125+ def relativize (other : Path ) = Path (jpath.relativize(other.jpath))
137126
138127 def segments : List [String ] = (path split separator).toList filterNot (_.length == 0 )
139128
0 commit comments