2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @file prepare_external_storage.cpp
18 * @author Soyoung Kim (sy037.kim@samsung.com)
22 #include "prepare_external_storage.h"
23 #include <dpl/assert.h>
24 #include <dpl/log/log.h>
25 #include <dpl/singleton_impl.h>
27 IMPLEMENT_SINGLETON(PrepareExternalStorage)
29 PrepareExternalStorage::PrepareExternalStorage() :
34 PrepareExternalStorage::~PrepareExternalStorage()
39 void PrepareExternalStorage::Initialize(const DPL::String &pkgId)
41 m_pkdIdStr = DPL::ToUTF8String(pkgId);
42 const char* id = m_pkdIdStr.c_str();
44 if (APP2EXT_SD_CARD == app2ext_get_app_location(id) && (NULL == m_handle))
46 m_handle = app2ext_init(APP2EXT_SD_CARD);
48 int ret = m_handle->interface.enable(id);
50 LogError("app2ext enable failed : " << ret);
52 LogDebug("app2ext enable success");
55 LogError("app2ext init failed");
60 void PrepareExternalStorage::Deinitialize()
62 if (NULL != m_handle) {
63 if (0 < m_handle->interface.disable(m_pkdIdStr.c_str())) {
64 LogError("app2ext disable failed");