1 #ifndef DALI_FILE_LOADER_H
2 #define DALI_FILE_LOADER_H
5 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/object/base-handle.h>
25 #include <dali/public-api/dali-adaptor-common.h>
33 * @brief File type formats
34 * The default format is binary
36 enum FileType ///< FileType format
38 BINARY, ///< File will be loaded as a binary
39 TEXT ///< File will be loaded as text
43 * @brief Load the file. It will load it either as a binary or as a text
45 * @param[in] filename Filename of the file to load.
46 * @param[in] memblock Dali::Vector containing the buffer loaded
47 * @param[in] fileType How we want to load the file. Binary or Text. Binary default
48 * @return error code. 0 - Error, 1 - Ok
52 DALI_ADAPTOR_API int ReadFile(const std::string& filename, Dali::Vector<char> & memblock, FileLoader::FileType fileType = BINARY);
55 * @brief Load the file. It will load it either as a binary or as a text
57 * @param[in] filename Filename of the file to load.
58 * @param[in] fileSize Size of the loaded file
59 * @param[in] memblock Dali::Vector containing the buffer loaded
60 * @param[in] fileType How we want to load the file. Binary or Text. Binary default
61 * @return error code. 0 - Error, 1 - Ok
64 DALI_ADAPTOR_API int ReadFile(const std::string& filename, std::streampos& fileSize, Dali::Vector<char> & memblock, FileLoader::FileType fileType = BINARY);
67 * @brief Get the file size of a file
69 * @param[in] filename Filename of the file to load.
70 * @return the size of the file or 0 if file not found
72 DALI_ADAPTOR_API std::streampos GetFileSize(const std::string& filename);
76 * @brief Download a requested file into a memory buffer.
78 * @param[in] filename Filename of the file to download.
79 * @param[out] dataBuffer A memory buffer object to be written with downloaded file data.
80 * @return error code. false - Error, true - Ok
82 DALI_ADAPTOR_API bool DownloadFileSynchronously(const std::string& filename, Dali::Vector<uint8_t> &dataBuffer);
87 #endif // DALI_FILE_LOADER_H