diff --git a/client.go b/client.go index dc8a423e..81b2d6c1 100644 --- a/client.go +++ b/client.go @@ -789,7 +789,11 @@ func (c *Client) PosixRename(oldname, newname string) error { } } -func (c *Client) realpath(path string) (string, error) { +// RealPath can be used to have the server canonicalize any given path name to an absolute path. +// +// This is useful for converting path names containing ".." components, +// or relative pathnames without a leading slash into absolute paths. +func (c *Client) RealPath(path string) (string, error) { id := c.nextID() typ, data, err := c.sendPacket(nil, &sshFxpRealpathPacket{ ID: id, @@ -820,7 +824,7 @@ func (c *Client) realpath(path string) (string, error) { // Getwd returns the current working directory of the server. Operations // involving relative paths will be based at this location. func (c *Client) Getwd() (string, error) { - return c.realpath(".") + return c.RealPath(".") } // Mkdir creates the specified directory. An error will be returned if a file or