Remove unused files.
[platform/core/uifw/dali-adaptor.git] / platform-abstractions / tizen / resource-loader / resource-loader.cpp
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include "resource-loader.h"
20
21 // EXTERNAL HEADERS
22 #include <iostream>
23 #include <fstream>
24 #include <queue>
25 #include <cstring>
26 #include <dali/devel-api/common/map-wrapper.h>
27 #include <dali/devel-api/threading/mutex.h>
28
29 // INTERNAL HEADERS
30 #include <dali/integration-api/bitmap.h>
31 #include <dali/integration-api/debug.h>
32 #include <dali/public-api/common/dali-common.h>
33 #include <dali/devel-api/common/set-wrapper.h>
34 #include <dali/public-api/math/vector2.h>
35 #include "debug/resource-loader-debug.h"
36
37 using namespace Dali::Integration;
38
39 namespace Dali
40 {
41
42 namespace TizenPlatform
43 {
44
45 /********************************************************************************/
46 /****************************   RESOURCE LOADER METHODS  ************************/
47 /********************************************************************************/
48 ResourceLoader::ResourceLoader()
49 {
50 }
51
52 ResourceLoader::~ResourceLoader()
53 {
54 }
55
56 bool ResourceLoader::SaveFile(const std::string& filename, const unsigned char * buffer, unsigned int numBytes )
57 {
58   DALI_LOG_TRACE_METHOD(gLoaderFilter);
59
60   DALI_ASSERT_DEBUG( 0 != filename.length());
61
62   bool result = false;
63
64   std::filebuf buf;
65   buf.open(filename.c_str(), std::ios::out | std::ios_base::trunc | std::ios::binary);
66   if( buf.is_open() )
67   {
68     std::ostream stream(&buf);
69
70     // determine size of buffer
71     int length = static_cast<int>(numBytes);
72
73     // write contents of buffer to the file
74     stream.write(reinterpret_cast<const char*>(buffer), length);
75
76     if( !stream.bad() )
77     {
78       DALI_LOG_INFO(gLoaderFilter, Debug::Verbose, "ResourceLoader::SaveFile(%s) - wrote %d bytes\n", filename.c_str(), length);
79       result = true;
80     }
81   }
82
83 #if defined(DEBUG_BUILD)
84   if( !result )
85   {
86     DALI_LOG_INFO(gLoaderFilter, Debug::Verbose, "ResourceLoader::SaveFile(%s) - failed to load\n", filename.c_str());
87   }
88 #endif
89
90   return result;
91 }
92
93 } // namespace TizenPlatform
94
95 } // namespace Dali