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.
16 #ifndef WRTDEVICEAPIS_FILESYSTEM_NODE_H_
17 #define WRTDEVICEAPIS_FILESYSTEM_NODE_H_
23 #include <dpl/shared_ptr.h>
24 #include <dpl/enable_shared_from_this.h>
25 #include <dpl/mutex.h>
27 #include <Filesystem/Enums.h>
28 #include <Filesystem/INode.h>
32 namespace WrtDeviceApis {
33 namespace Filesystem {
37 public DPL::EnableSharedFromThis<Node>
40 static Api::INodePtr resolve(const Api::IPathPtr& path);
43 Api::IPathPtr getPath() const;
44 Api::NodeType getType() const;
45 int getPermissions() const;
46 void setPermissions(int perms);
47 std::size_t getSize() const;
48 std::time_t getCreated() const;
49 std::time_t getModified() const;
50 Api::INodePtr getParent() const;
53 Api::INodePtr getChild(const Api::IPathPtr& path);
54 NameList getChildNames() const;
55 Api::NodeList getChildNodes(
56 const Api::NodeFilterPtr& filter = Api::NodeFilterPtr()) const;
57 void getChildNodes(const Api::EventListNodesPtr& event);
58 Api::INodePtr createChild(const Api::IPathPtr & path,
61 Api::IStreamPtr open(int mode);
62 void open(const Api::EventOpenPtr& event);
63 void remove(int options);
64 void read(const Api::EventReadTextPtr& event);
66 void onStreamClose(const StreamPtr& stream);
69 typedef std::set<StreamPtr> StreamList;
72 static bool exists(const Api::IPathPtr& path);
73 static struct stat stat(const Api::IPathPtr& path);
76 Node(const Api::IPathPtr& path, Api::NodeType type);
78 Node* createAsFile(const Api::IPathPtr& path,
80 void createAsFileInternal(const Api::IPathPtr& path);
82 Node* createAsDirectory(const Api::IPathPtr& path,
84 void createAsDirectoryInternal(const Api::IPathPtr& path);
86 void removeAsFile(const Api::IPathPtr& path);
87 void removeAsDirectory(const Api::IPathPtr& path,
90 void OnRequestReceived(const Api::EventListNodesPtr& event);
91 void OnRequestReceived(const Api::EventOpenPtr& event);
93 void OnRequestReceived(const Api::EventReadTextPtr& event);
94 std::string readText();
96 std::string toUri(int widgetId) const;
100 Api::NodeType m_type;
102 StreamList m_openStreams;
103 mutable DPL::Mutex m_openStreamsMutex;
106 typedef DPL::SharedPtr<Node> NodePtr;
111 #endif /* WRTDEVICEAPIS_FILESYSTEM_NODE_H_ */