public function uploadFile($sourceFilename, $destFilename)
{
// what are we doing?
$log = usingLog()->startAction("upload file '{$sourceFilename}' to '{$this->args[0]}':'{$destFilename}'");
// does the source file exist?
if (!is_file($sourceFilename)) {
$log->endAction("file '{$sourceFilename}' not found :(");
throw new E5xx_ActionFailed(__METHOD__);
}
// make sure we have valid host details
$hostDetails = $this->getHostDetails();
// get an object to talk to this host
$host = OsLib::getHostAdapter($this->st, $hostDetails->osName);
// upload the file
$result = $host->uploadFile($hostDetails, $sourceFilename, $destFilename);
// did the command used to upload succeed?
if ($result->didCommandFail()) {
$msg = "upload failed with return code '{$result->returnCode}' and output '{$result->output}'";
$log->endAction($msg);
throw new E5xx_ActionFailed(__METHOD__, $msg);
}
// all done
$log->endAction();
return $result;
}