Skip to content

Commit

Permalink
Merge pull request #410 from pkg/export-realpath
Browse files Browse the repository at this point in the history
Export RealPath for potential client use
  • Loading branch information
drakkan committed Mar 6, 2021
2 parents f50ad19 + 714bd5d commit 5b7da38
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5b7da38

Please sign in to comment.