ADD: FTP - copy files between remote directories (SSH)

This commit is contained in:
Alexander Koblov 2023-12-10 18:57:14 +03:00
commit 8883b6936a
3 changed files with 26 additions and 0 deletions

View file

@ -124,6 +124,7 @@ type
function FileExists(const FileName: String): Boolean; virtual;
function CreateDir(const Directory: string): Boolean; override;
function ExecuteCommand(const Command: String): Boolean; virtual;
function CopyFile(const OldName, NewName: String): Boolean; virtual;
function ChangeMode(const FileName, Mode: String): Boolean; virtual;
function List(Directory: String; NameList: Boolean): Boolean; override;
function StoreFile(const FileName: string; Restore: Boolean): Boolean; override;
@ -789,6 +790,11 @@ begin
Result:= (FTPCommand(Command) div 100) = 2;
end;
function TFTPSendEx.CopyFile(const OldName, NewName: String): Boolean;
begin
Result:= False;
end;
function TFTPSendEx.ChangeMode(const FileName, Mode: String): Boolean;
begin
Result:= (FTPCommand('SITE CHMOD' + #32 + Mode + #32 + FileName) div 100) = 2;

View file

@ -820,6 +820,20 @@ begin
WriteConnectionList;
Result:= FS_FILE_OK;
end;
end
else if GetConnectionByPath(OldName, FtpSend, sOldName) then
begin
if FtpSend is TScpSend then
begin
sNewName := FtpSend.ClientToServer(NewName);
sNewName := ExtractRemoteFileName(sNewName);
ProgressProc(PluginNumber, OldName, NewName, 0);
if FtpSend.CopyFile(sOldName, sNewName) then
begin
ProgressProc(PluginNumber, OldName, NewName, 100);
Result := FS_FILE_OK;
end;
end;
end;
Exit;
end;

View file

@ -76,6 +76,7 @@ type
function DeleteDir(const Directory: string): Boolean; override;
function DeleteFile(const FileName: string): Boolean; override;
function ExecuteCommand(const Command: String): Boolean; override;
function CopyFile(const OldName, NewName: String): Boolean; override;
function ChangeWorkingDir(const Directory: string): Boolean; override;
function RenameFile(const OldName, NewName: string): Boolean; override;
function ChangeMode(const FileName, Mode: String): Boolean; override;
@ -671,6 +672,11 @@ begin
end;
end;
function TScpSend.CopyFile(const OldName, NewName: String): Boolean;
begin
Result:= SendCommand('cp -p ' + EscapeNoQuotes(OldName) + ' ' + EscapeNoQuotes(NewName), FAnswer);
end;
function TScpSend.ChangeWorkingDir(const Directory: string): Boolean;
begin
Result:= SendCommand('cd ' + EscapeNoQuotes(Directory), FAnswer);