@@ -158,8 +158,8 @@ func (p *Path) RemoveAll() error {
158158 return p .Fs ().RemoveAll (p .String ())
159159}
160160
161- // Rename renames a file
162- func (p * Path ) Rename (newname string ) error {
161+ // RenameStr renames a file
162+ func (p * Path ) RenameStr (newname string ) error {
163163 if err := p .Fs ().Rename (p .String (), newname ); err != nil {
164164 return err
165165 }
@@ -169,10 +169,9 @@ func (p *Path) Rename(newname string) error {
169169 return nil
170170}
171171
172- // RenamePath is the same as Rename except the argument is a Path object. The attributes
173- // of the path object is retained and does not inherit anything from target.
174- func (p * Path ) RenamePath (target * Path ) error {
175- return p .Rename (target .String ())
172+ // Rename renames a file
173+ func (p * Path ) Rename (target * Path ) error {
174+ return p .RenameStr (target .String ())
176175}
177176
178177// Stat returns the os.FileInfo of the given path
@@ -392,7 +391,7 @@ func (p *Path) Join(elems ...string) *Path {
392391 for _ , path := range elems {
393392 paths = append (paths , path )
394393 }
395- return NewPathAfero (filepath .Join (paths ... ), p .Fs ())
394+ return NewPathAfero (strings .Join (paths , p . Sep ), p .Fs ())
396395}
397396
398397// JoinPath is the same as Join() except it accepts a path object
@@ -451,6 +450,13 @@ func (p *Path) RelativeTo(other *Path) (*Path, error) {
451450 return NewPathAfero (strings .Join (relativePath , "/" ), p .Fs ()), nil
452451}
453452
453+ // RelativeToStr computes a relative version of path to the other path. For instance,
454+ // if the object is /path/to/foo.txt and you provide /path/ as the argment, the
455+ // returned Path object will represent to/foo.txt.
456+ func (p * Path ) RelativeToStr (other string ) (* Path , error ) {
457+ return p .RelativeTo (NewPathAfero (other , p .Fs ()))
458+ }
459+
454460// Lstat lstat's the path if the underlying afero filesystem supports it. If
455461// the filesystem does not support afero.Lstater, or if the filesystem implements
456462// afero.Lstater but returns false for the "lstat called" return value.
@@ -474,6 +480,14 @@ func (p *Path) Lstat() (os.FileInfo, error) {
474480// * filesystem-specific functions *
475481// *********************************
476482
483+ // SymlinkStr symlinks to the target location. This will fail if the underlying
484+ // afero filesystem does not implement afero.Linker.
485+ //
486+ // THIS METHOD IS NOT TYPE SAFE.
487+ func (p * Path ) SymlinkStr (target string ) error {
488+ return p .Symlink (NewPathAfero (target , p .Fs ()))
489+ }
490+
477491// Symlink symlinks to the target location. This will fail if the underlying
478492// afero filesystem does not implement afero.Linker.
479493//
@@ -539,7 +553,7 @@ func (p *Path) DeepEquals(other *Path) (bool, error) {
539553 return false , err
540554 }
541555
542- return selfResolved .Equals (otherResolved ), nil
556+ return selfResolved .Clean (). Equals (otherResolved . Clean () ), nil
543557}
544558
545559// Equals returns whether or not the object's path is identical
@@ -589,6 +603,12 @@ func (p *Path) Glob(pattern string) ([]*Path, error) {
589603 return Glob (p .Fs (), p .Join (pattern ).String ())
590604}
591605
606+ // Clean returns a new object that is a lexically-cleaned
607+ // version of Path.
608+ func (p * Path ) Clean () * Path {
609+ return NewPathAfero (filepath .Clean (p .String ()), p .Fs ())
610+ }
611+
592612// Mtime returns the modification time of the given path.
593613func (p * Path ) Mtime () (time.Time , error ) {
594614 stat , err := p .Stat ()
0 commit comments