@@ -95,7 +95,7 @@ class Path private[io] (val jpath: JPath) {
95
95
/** Creates a new Path with the specified path appended. Assumes
96
96
* the type of the new component implies the type of the result.
97
97
*/
98
- def / (child : Path ): Path = if (isEmpty) child else new Path (jpath. resolve(child.path) )
98
+ def / (child : Path ): Path = resolve(child)
99
99
def / (child : Directory ): Directory = / (child : Path ).toDirectory
100
100
def / (child : File ): File = / (child : Path ).toFile
101
101
@@ -121,19 +121,8 @@ class Path private[io] (val jpath: JPath) {
121
121
def path : String = jpath.toString
122
122
def normalize : Path = Path (jpath.normalize)
123
123
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))
137
126
138
127
def segments : List [String ] = (path split separator).toList filterNot (_.length == 0 )
139
128
0 commit comments