tizen 2.3 release
[framework/web/wearable/wrt-plugins-tizen.git] / src / Filesystem / FilesystemExternalUtils.cpp
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        FilesystemExternalUtils.cpp
20  */
21
22 #include "FilesystemExternalUtils.h"
23
24 #include <string>
25 #include <sys/stat.h>
26 #include <cerrno>
27 #include <cstring>
28 #include <cstdlib>
29 #include <unistd.h>
30
31 #include <Logger.h>
32 #include <PlatformException.h>
33 #include <Commons/WrtAccess/WrtAccess.h>
34 #include <Export.h>
35
36 #include "Enums.h"
37 #include "Manager.h"
38 #include "FilesystemUtils.h"
39 #include "FilesystemPathUtils.h"
40 #include "JSErrors.h"
41
42
43 namespace DeviceAPI
44 {
45 namespace Filesystem
46 {
47 namespace External
48 {
49
50 void DLL_EXPORT initializeManager() {
51     LOGD("initializeManager start");
52     Utils::initializeManager();
53     LOGD("initializeManager end");
54 }
55
56 std::string DLL_EXPORT fromVirtualPath(const std::string& arg, JSContextRef context)
57 {
58     LOGD("fromVirtualPath start");
59     std::string fullPath;
60     {
61         auto path = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, arg);
62         fullPath = path->getFullPath();
63     }
64     LOGD("fromVirtualPath end %s -> %s", arg.c_str(), fullPath.c_str());
65     return fullPath;
66 }
67
68 std::string DLL_EXPORT toVirtualPath(const std::string& arg, JSContextRef context)
69 {
70     LOGD("toVirtualPath start");
71     auto virtualPath = Utils::toVirtualPath(context, arg);
72     LOGD("toVirtualPath end %s -> %s", arg.c_str(), virtualPath.c_str());
73     return virtualPath;
74 }
75
76 bool DLL_EXPORT isVirtualPath(const std::string& path)
77 {
78     LOGD("isVirtualPath start");
79     bool result = Utils::isVirtualPath(path);
80     LOGD("isVirtualPath end");
81     return result;
82 }
83
84 }
85 }
86 }
87
88
89
90
91
92
93
94