Skip to content

Commit 5b7da38

Browse files
authored
Merge pull request #410 from pkg/export-realpath
Export RealPath for potential client use
2 parents f50ad19 + 714bd5d commit 5b7da38

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

client.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,11 @@ func (c *Client) PosixRename(oldname, newname string) error {
789789
}
790790
}
791791

792-
func (c *Client) realpath(path string) (string, error) {
792+
// RealPath can be used to have the server canonicalize any given path name to an absolute path.
793+
//
794+
// This is useful for converting path names containing ".." components,
795+
// or relative pathnames without a leading slash into absolute paths.
796+
func (c *Client) RealPath(path string) (string, error) {
793797
id := c.nextID()
794798
typ, data, err := c.sendPacket(nil, &sshFxpRealpathPacket{
795799
ID: id,
@@ -820,7 +824,7 @@ func (c *Client) realpath(path string) (string, error) {
820824
// Getwd returns the current working directory of the server. Operations
821825
// involving relative paths will be based at this location.
822826
func (c *Client) Getwd() (string, error) {
823-
return c.realpath(".")
827+
return c.RealPath(".")
824828
}
825829

826830
// Mkdir creates the specified directory. An error will be returned if a file or

0 commit comments

Comments
 (0)