void CodaClientApplication::handleFileSystemOpen(const Coda::CodaCommandResult &result) { if (result.type != Coda::CodaCommandResult::SuccessReply) { std::fprintf(stderr, "Open remote file failed: %s\n", qPrintable(result.toString())); doExit(-1); return; } if (result.values.size() < 1 || result.values.at(0).data().isEmpty()) { std::fprintf(stderr, "Internal error: No filehandle obtained\n"); doExit(-1); return; } m_remoteFileHandle = result.values.at(0).data(); if (m_mode == Stat) { m_trkDevice->sendFileSystemFstatCommand(Coda::CodaCallback(this, &CodaClientApplication::handleFileSystemFStat), m_remoteFileHandle); return; } // Put. m_putFile.reset(new QFile(m_putLocalFile)); if (!m_putFile->open(QIODevice::ReadOnly)) { // Should not fail, was checked before std::fprintf(stderr, "Open local file failed: %s\n", qPrintable(m_putFile->errorString())); doExit(-1); return; } putSendNextChunk(); }
void CodaClientApplication::handleFileSystemWrite(const Coda::CodaCommandResult &result) { // Close remote file even if copy fails m_putWriteOk = result; if (!m_putWriteOk) std::fprintf(stderr, "Writing data failed: %s\n", qPrintable(result.toString())); if (!m_putWriteOk || m_putLastChunkSize < m_putChunkSize) { closeRemoteFile(); } else { putSendNextChunk(); } }
void CodaSignalHandler::handleFileSystemWrite(const Coda::CodaCommandResult &result) { // Close remote file even if copy fails d->putWriteOk = result; if (!d->putWriteOk) { QString fileName = QFileInfo(d->copyDstFileName).fileName(); reportError(tr("Could not write to file %1 on device: %2").arg(fileName).arg(result.errorString())); } if (!d->putWriteOk || d->putLastChunkSize < d->putChunkSize) { closeFile(); } else { putSendNextChunk(); } }
void CodaSignalHandler::handleFileSystemOpen(const Coda::CodaCommandResult &result) { if (result.type != Coda::CodaCommandResult::SuccessReply) { reportError(tr("Could not open remote file: %1").arg(result.errorString())); return; } if (result.values.size() < 1 || result.values.at(0).data().isEmpty()) { reportError(tr("Internal error: No filehandle obtained")); return; } if (d->action & ActionCopy) { d->remoteFileHandle = result.values.at(0).data(); d->remoteFile.reset(new QFile(d->copySrcFileName)); if (!d->remoteFile->open(QIODevice::ReadOnly)) { // Should not fail, was checked before reportError(tr("Could not open local file %1").arg(d->copySrcFileName)); return; } putSendNextChunk(); } else if (d->action & ActionDownload) { d->remoteFileHandle = result.values.at(0).data(); d->localFile.reset(new QFile(d->dlDstFileName)); // remove any existing file with the same name if (d->localFile->exists() && !d->localFile->remove()) { reportError(tr("Could not create host file: %1 due to error: %2").arg(d->localFile->fileName(), d->localFile->errorString())); return; } // open local file in write-only mode if (!d->localFile->open(QFile::WriteOnly)) { reportError(tr("Could not open host file for writing: %1 due to error: %2").arg(d->localFile->fileName(), d->localFile->errorString())); return; } d->codaDevice->sendFileSystemFstatCommand(Coda::CodaCallback(this, &CodaSignalHandler::handleFileSystemStart), d->remoteFileHandle); } }