diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index b797ecf7a70..39c537dea5b 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -3191,8 +3191,8 @@ void MainWindow::on_actionSa_ve_Scene_as_Script_triggered() tr("Enter the name of your scene file.")); if(path.isEmpty()) return; - if(!path.contains("Polyhedron_demo_")) - path.prepend("Polyhedron_demo_"); + if(!path.contains("/tmp/Polyhedron_demo_")) + path.prepend("/tmp/Polyhedron_demo_"); try{ ssh_session session = nullptr; bool res = establish_ssh_session_from_agent(session, diff --git a/Polyhedron/demo/Polyhedron/Use_ssh.cpp b/Polyhedron/demo/Polyhedron/Use_ssh.cpp index 965abf23024..2fafe072444 100644 --- a/Polyhedron/demo/Polyhedron/Use_ssh.cpp +++ b/Polyhedron/demo/Polyhedron/Use_ssh.cpp @@ -26,6 +26,10 @@ #include #include + +#include +#include + bool test_result(int res) { switch(res){ @@ -240,21 +244,22 @@ bool push_file(ssh_session &session, const char* dest_path, const char* filepath) { + std::size_t processed = 0; + sftp_file sftpfile; //copy a file - ssh_scp scp = ssh_scp_new( - session, SSH_SCP_WRITE | SSH_SCP_RECURSIVE, "/tmp"); - if (scp == nullptr) + sftp_session sftp = sftp_new(session); + if (sftp == nullptr) { - std::cerr<<"Error allocating scp session: %s\n" + std::cerr<<"Error allocating sftp session:\n" << ssh_get_error(session)< timespan(size); - std::this_thread::sleep_for(timespan); - if (res != SSH_OK) + while ( size > 0 ) { - std::cerr<< "Can't write to remote file: %s\n" - << ssh_get_error(session)< 16384) + s = 16384; + res = sftp_write(sftpfile, buffer.data() + processed, s); + if ( res < 0) + { + std::cerr<< "Can't write data to file:\n" + << ssh_get_error(session)< buffer; - - ssh_scp scp = ssh_scp_new( - session, SSH_SCP_READ | SSH_SCP_RECURSIVE, from_path); - if (scp == nullptr) + sftp_file sftpfile; + sftp_session sftp = sftp_new(session); + if (sftp == nullptr) { - std::cerr<<"Error allocating scp session: %s\n" + std::cerr<<"Error allocating sftp session:\n" << ssh_get_error(session)<size; buffer.resize(size); - if(ssh_scp_accept_request(scp) != SSH_OK) + while ( size > 0 ) { - std::cerr<< "Could not accept request."< 16384) + s = 16384; + res = sftp_read(sftpfile, buffer.data() + processed, s); + if ( res < 0) { - std::cerr<< "Error receiving file data: %s\n"<< ssh_get_error(session)<size; std::ofstream file(to_path, std::ios::binary |std::ios::trunc); if(!file.write(buffer.data(), size)) { std::cerr<<"Error while writing file."<