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 {
36 public DPL::EnableSharedFromThis<Node>
39 static Api::INodePtr resolve(const Api::IPathPtr& path);
42 Api::IPathPtr getPath() const;
43 Api::NodeType getType() const;
44 int getPermissions() const;
45 void setPermissions(int perms);
46 std::size_t getSize() const;
47 std::time_t getCreated() const;
48 std::time_t getModified() const;
49 Api::INodePtr getParent() const;
52 Api::INodePtr getChild(const Api::IPathPtr& path);
53 NameList getChildNames() const;
54 Api::NodeList getChildNodes(
55 const Api::NodeFilterPtr& filter = Api::NodeFilterPtr()) const;
56 void getChildNodes(const Api::EventListNodesPtr& event);
57 Api::INodePtr createChild(const Api::IPathPtr & path,
60 Api::IStreamPtr open(int mode);
61 void open(const Api::EventOpenPtr& event);
62 void remove(int options);
63 void read(const Api::EventReadTextPtr& event);
65 void onStreamClose(const StreamPtr& stream);
68 typedef std::set<StreamPtr> StreamList;
71 static bool exists(const Api::IPathPtr& path);
72 static struct stat stat(const Api::IPathPtr& path);
75 Node(const Api::IPathPtr& path, Api::NodeType type);
77 Node* createAsFile(const Api::IPathPtr& path,
79 void createAsFileInternal(const Api::IPathPtr& path);
81 Node* createAsDirectory(const Api::IPathPtr& path,
83 void createAsDirectoryInternal(const Api::IPathPtr& path);
85 void removeAsFile(const Api::IPathPtr& path);
86 void removeAsDirectory(const Api::IPathPtr& path,
89 void OnRequestReceived(const Api::EventListNodesPtr& event);
90 void OnRequestReceived(const Api::EventOpenPtr& event);
92 void OnRequestReceived(const Api::EventReadTextPtr& event);
93 std::string readText();
95 std::string toUri(int widgetId) const;
101 StreamList m_openStreams;
102 mutable DPL::Mutex m_openStreamsMutex;
105 typedef DPL::SharedPtr<Node> NodePtr;
109 #endif /* WRTDEVICEAPIS_FILESYSTEM_NODE_H_ */