From b83052b538b35bbe40f5d5d679852c86c08f3ebd Mon Sep 17 00:00:00 2001 From: Cassondra Foesch Date: Sat, 6 Mar 2021 08:48:23 +0000 Subject: [PATCH 1/2] Export RealPath for potential client use --- client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index dc8a423e..d56cddc4 100644 --- a/client.go +++ b/client.go @@ -789,7 +789,7 @@ func (c *Client) PosixRename(oldname, newname string) error { } } -func (c *Client) realpath(path string) (string, error) { +func (c *Client) RealPath(path string) (string, error) { id := c.nextID() typ, data, err := c.sendPacket(nil, &sshFxpRealpathPacket{ ID: id, @@ -820,7 +820,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 From 714bd5db80eb25a1811fe204b0dd6323d415457a Mon Sep 17 00:00:00 2001 From: Cassondra Foesch Date: Sat, 6 Mar 2021 09:03:37 +0000 Subject: [PATCH 2/2] +godoc --- client.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client.go b/client.go index d56cddc4..81b2d6c1 100644 --- a/client.go +++ b/client.go @@ -789,6 +789,10 @@ func (c *Client) PosixRename(oldname, newname 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{