diff options
author | Alexander Tkachev | 2016-05-24 12:31:27 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | caaa4c5a5d0bce7582cc6611d8bde53fbdb1f2d1 (patch) | |
tree | 4550fc9f3dbdba4feeeb68aeceb82a5146b9e542 /backends/cloud/dropbox | |
parent | 826a2a921cd0b0a72f71dd6f323097a2f449fab0 (diff) | |
download | scummvm-rg350-caaa4c5a5d0bce7582cc6611d8bde53fbdb1f2d1.tar.gz scummvm-rg350-caaa4c5a5d0bce7582cc6611d8bde53fbdb1f2d1.tar.bz2 scummvm-rg350-caaa4c5a5d0bce7582cc6611d8bde53fbdb1f2d1.zip |
CLOUD: Make DownloadRequest write to local file
Tested with .jpg file. Transfer complete, CRC-32 is the same.
Diffstat (limited to 'backends/cloud/dropbox')
-rw-r--r-- | backends/cloud/dropbox/dropboxstorage.cpp | 15 | ||||
-rw-r--r-- | backends/cloud/dropbox/dropboxstorage.h | 2 |
2 files changed, 13 insertions, 4 deletions
diff --git a/backends/cloud/dropbox/dropboxstorage.cpp b/backends/cloud/dropbox/dropboxstorage.cpp index 1b6dc1b92f..38ad12d94b 100644 --- a/backends/cloud/dropbox/dropboxstorage.cpp +++ b/backends/cloud/dropbox/dropboxstorage.cpp @@ -30,6 +30,7 @@ #include "common/debug.h" #include "common/json.h" #include <curl/curl.h> +#include <common/file.h> namespace Cloud { namespace Dropbox { @@ -100,15 +101,23 @@ Networking::NetworkReadStream *DropboxStorage::streamFile(Common::String path) { return request->execute(); } -void DropboxStorage::download(Common::String path, BoolCallback callback) { - ConnMan.addRequest(new DownloadRequest(callback, streamFile(path))); +void DropboxStorage::download(Common::String remotePath, Common::String localPath, BoolCallback callback) { + Common::DumpFile *f = new Common::DumpFile(); + if (!f->open(localPath)) { + warning("DropboxStorage: unable to open file to download into"); + if (callback) (*callback)(false); + delete f; + return; + } + + ConnMan.addRequest(new DownloadRequest(callback, streamFile(remotePath), f)); } void DropboxStorage::syncSaves(BoolCallback callback) { //this is not the real syncSaves() implementation //"" is root in Dropbox, not "/" //listDirectory("", new Common::Callback<DropboxStorage, Common::Array<StorageFile> >(this, &DropboxStorage::printFiles), true); - download("/notempty.txt", 0); + download("/remote/test.jpg", "local/test.jpg", 0); } void DropboxStorage::info(StorageInfoCallback outerCallback) { diff --git a/backends/cloud/dropbox/dropboxstorage.h b/backends/cloud/dropbox/dropboxstorage.h index 92c3746da5..415a3fe5fb 100644 --- a/backends/cloud/dropbox/dropboxstorage.h +++ b/backends/cloud/dropbox/dropboxstorage.h @@ -73,7 +73,7 @@ public: virtual Networking::NetworkReadStream *streamFile(Common::String path); /** Calls the callback when finished. */ - virtual void download(Common::String path, BoolCallback callback); + virtual void download(Common::String remotePath, Common::String localPath, BoolCallback callback); /** Calls the callback when finished. */ virtual void remove(Common::String path, BoolCallback callback) {} //TODO |