From ae8e7f39f5b3e4f647a29d39d19cce7626528bb1 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Wed, 25 May 2016 16:32:22 +0600 Subject: CLOUD: Make download() create necessary directories DumpFile::open() with createPath=true create would create the missing directories from the path before opening a file. Thus, one can easily create a file and avoid "can't open a file" error. --- backends/cloud/dropbox/dropboxstorage.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'backends/cloud') diff --git a/backends/cloud/dropbox/dropboxstorage.cpp b/backends/cloud/dropbox/dropboxstorage.cpp index 38ad12d94b..e5041466e9 100644 --- a/backends/cloud/dropbox/dropboxstorage.cpp +++ b/backends/cloud/dropbox/dropboxstorage.cpp @@ -103,7 +103,7 @@ Networking::NetworkReadStream *DropboxStorage::streamFile(Common::String path) { void DropboxStorage::download(Common::String remotePath, Common::String localPath, BoolCallback callback) { Common::DumpFile *f = new Common::DumpFile(); - if (!f->open(localPath)) { + if (!f->open(localPath, true)) { warning("DropboxStorage: unable to open file to download into"); if (callback) (*callback)(false); delete f; @@ -116,8 +116,8 @@ void DropboxStorage::download(Common::String remotePath, Common::String localPat void DropboxStorage::syncSaves(BoolCallback callback) { //this is not the real syncSaves() implementation //"" is root in Dropbox, not "/" - //listDirectory("", new Common::Callback >(this, &DropboxStorage::printFiles), true); - download("/remote/test.jpg", "local/test.jpg", 0); + //this must create all these directories: + download("/remote/test.jpg", "local/a/b/c/d/test.jpg", 0); } void DropboxStorage::info(StorageInfoCallback outerCallback) { -- cgit v1.2.3