From 299e6c5d33ee906fbc12cf8dbce743848b883271 Mon Sep 17 00:00:00 2001 From: Joogab Yun Date: Fri, 27 Dec 2019 17:33:40 +0900 Subject: [PATCH] [Tizen] Add DownloadRemoteFileIntoMemory function This reverts commit ec5487e60df11121950c595142a6ac8988c2f05f. Change-Id: I00f92d7d9870312fdb1ee31d0ea939f192e05935 --- dali/devel-api/adaptor-framework/file-loader.cpp | 15 +++++++++++++++ dali/devel-api/adaptor-framework/file-loader.h | 11 +++++++++++ .../generic/file-loader-impl-generic.cpp | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/dali/devel-api/adaptor-framework/file-loader.cpp b/dali/devel-api/adaptor-framework/file-loader.cpp index b63b5c7..c567456 100644 --- a/dali/devel-api/adaptor-framework/file-loader.cpp +++ b/dali/devel-api/adaptor-framework/file-loader.cpp @@ -23,10 +23,19 @@ // INTERNAL INCLUDES #include +#include namespace Dali { +namespace +{ + +// limit maximum image down load size to 50 MB +const size_t MAXIMUM_DOWNLOAD_IMAGE_SIZE = 50 * 1024 * 1024 ; + +} + namespace FileLoader { @@ -45,6 +54,12 @@ std::streampos GetFileSize(const std::string& filename) return Dali::Internal::Adaptor::GetFileSize(filename); } +bool DownloadFileSynchronously(const std::string& filename, Dali::Vector &dataBuffer) +{ + size_t dataSize; + return TizenPlatform::Network::DownloadRemoteFileIntoMemory( filename, dataBuffer, dataSize, MAXIMUM_DOWNLOAD_IMAGE_SIZE ); +} + } //FileLoader } //Dali diff --git a/dali/devel-api/adaptor-framework/file-loader.h b/dali/devel-api/adaptor-framework/file-loader.h index 7b158a9..a658952 100644 --- a/dali/devel-api/adaptor-framework/file-loader.h +++ b/dali/devel-api/adaptor-framework/file-loader.h @@ -70,6 +70,17 @@ DALI_ADAPTOR_API int ReadFile(const std::string& filename, std::streampos& fileS * @return the size of the file or 0 if file not found */ DALI_ADAPTOR_API std::streampos GetFileSize(const std::string& filename); + + +/** + * @brief Download a requested file into a memory buffer. + * + * @param[in] filename Filename of the file to download. + * @param[out] dataBuffer A memory buffer object to be written with downloaded file data. + * @return error code. false - Error, true - Ok + */ +DALI_ADAPTOR_API bool DownloadFileSynchronously(const std::string& filename, Dali::Vector &dataBuffer); + }; } // Dali diff --git a/dali/internal/adaptor-framework/generic/file-loader-impl-generic.cpp b/dali/internal/adaptor-framework/generic/file-loader-impl-generic.cpp index 45422e7..0d5d190 100644 --- a/dali/internal/adaptor-framework/generic/file-loader-impl-generic.cpp +++ b/dali/internal/adaptor-framework/generic/file-loader-impl-generic.cpp @@ -73,7 +73,7 @@ int ReadFile(const std::string& filename, std::streampos& fileSize, Dali::Vector } else { - DALI_LOG_WARNING( "file open failed for: \"%s\"", filename ); + DALI_LOG_WARNING( "file open failed for: \"%s\"", filename.c_str() ); } return errorCode; -- 2.7.4