mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: SSH+SCP - open current directory when remote directory is not specified
This commit is contained in:
parent
832462f36a
commit
4763aaa86e
2 changed files with 28 additions and 17 deletions
|
|
@ -555,7 +555,6 @@ end;
|
|||
|
||||
constructor TScpSend.Create(const Encoding: String);
|
||||
begin
|
||||
FCurrentDir:= '/';
|
||||
inherited Create(Encoding);
|
||||
FTargetPort:= '22';
|
||||
FListCommand:= 'ls -la';
|
||||
|
|
@ -581,6 +580,16 @@ begin
|
|||
Result:= Connect;
|
||||
if Result then
|
||||
begin
|
||||
if (Length(FCurrentDir) = 0) then
|
||||
begin
|
||||
if not SendCommand('pwd', FAnswer) then
|
||||
FCurrentDir:= '/'
|
||||
else begin
|
||||
FCurrentDir:= TrimRightLineEnding(FAnswer, tlbsLF);
|
||||
FCurrentDir:= CeUtf16ToUtf8(ServerToClient(FCurrentDir));
|
||||
end;
|
||||
DoStatus(False, 'Remote directory: ' + FCurrentDir);
|
||||
end;
|
||||
if not FAutoDetect then
|
||||
begin
|
||||
FAutoDetect:= True;
|
||||
|
|
|
|||
|
|
@ -96,8 +96,6 @@ begin
|
|||
end;
|
||||
|
||||
function TSftpSend.Connect: Boolean;
|
||||
var
|
||||
Return: Integer;
|
||||
begin
|
||||
Result:= inherited Connect;
|
||||
|
||||
|
|
@ -107,18 +105,6 @@ begin
|
|||
|
||||
Result:= Assigned(FSFTPSession);
|
||||
|
||||
if Result and (Length(FCurrentDir) = 0) then
|
||||
begin
|
||||
SetLength(FCurrentDir, MAX_PATH + 1);
|
||||
Return:= libssh2_sftp_realpath(FSFTPSession, '.', PAnsiChar(FCurrentDir), MAX_PATH);
|
||||
if Return < 1 then
|
||||
FCurrentDir:= '/'
|
||||
else begin
|
||||
SetLength(FCurrentDir, Return);
|
||||
FCurrentDir:= CeUtf16ToUtf8(ServerToClient(FCurrentDir));
|
||||
end;
|
||||
end;
|
||||
|
||||
if not Result then begin
|
||||
libssh2_session_free(FSession);
|
||||
FSock.CloseSocket;
|
||||
|
|
@ -129,14 +115,30 @@ end;
|
|||
constructor TSftpSend.Create(const Encoding: String);
|
||||
begin
|
||||
inherited Create(Encoding);
|
||||
FCurrentDir:= EmptyStr;
|
||||
FCanResume := True;
|
||||
end;
|
||||
|
||||
function TSftpSend.Login: Boolean;
|
||||
var
|
||||
Return: Integer;
|
||||
begin
|
||||
Result:= Connect;
|
||||
if Result and FAuto then DetectEncoding;
|
||||
if Result then
|
||||
begin
|
||||
if (Length(FCurrentDir) = 0) then
|
||||
begin
|
||||
SetLength(FCurrentDir, MAX_PATH + 1);
|
||||
Return:= libssh2_sftp_realpath(FSFTPSession, '.', PAnsiChar(FCurrentDir), MAX_PATH);
|
||||
if Return < 1 then
|
||||
FCurrentDir:= '/'
|
||||
else begin
|
||||
SetLength(FCurrentDir, Return);
|
||||
FCurrentDir:= CeUtf16ToUtf8(ServerToClient(FCurrentDir));
|
||||
end;
|
||||
DoStatus(False, 'Remote directory: ' + FCurrentDir);
|
||||
end;
|
||||
if FAuto then DetectEncoding;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSftpSend.Logout: Boolean;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue