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_INODE_H_
17 #define WRTDEVICEAPIS_FILESYSTEM_INODE_H_
22 #include <dpl/noncopyable.h>
23 #include <dpl/shared_ptr.h>
24 #include <Commons/EventReceiver.h>
25 #include "EventListNodes.h"
26 #include "EventOpen.h"
27 #include "EventReadText.h"
31 #include "INodeTypes.h"
32 #include "NodeFilter.h"
34 namespace WrtDeviceApis {
35 namespace Filesystem {
39 public Commons::EventRequestReceiver<EventListNodes>,
40 public Commons::EventRequestReceiver<EventOpen>,
41 public Commons::EventRequestReceiver<EventReadText>
44 typedef std::vector<std::string> NameList;
45 typedef NameList::iterator NodeListIterator;
51 * Gets direct child of this node.
52 * @param path Path to the child node.
53 * @return Ptr to the child node.
54 * @remarks Ownership passed to the caller.
56 virtual INodePtr getChild(const IPathPtr& path) = 0;
59 * Gets path of current node.
60 * @return Node's path.
62 virtual IPathPtr getPath() const = 0;
65 * Gets type of current node.
66 * @return Node's type.
68 virtual NodeType getType() const = 0;
71 * Gets permissions of the virtual node (not real filesystem node).
72 * @return Node's permissions.
74 virtual int getPermissions() const = 0;
77 * Sets permissions on the virtual node (not real filesystem node).
78 * @param perms Node's permissions @see Api::Filesystem::Permissions.
80 virtual void setPermissions(int perms) = 0;
83 * Gets list of names of direct child nodes.
84 * @return Names of child nodes.
86 virtual NameList getChildNames() const = 0;
89 * Gets list of direct child nodes.
90 * @return Child nodes.
91 * @remarks Ownership passed to the caller.
94 virtual NodeList getChildNodes(const NodeFilterPtr& filter =
95 NodeFilterPtr()) const /* WRT_PLUGINS_DEPRECATED */ = 0;
98 * Gets list of direct descendant nodes.
99 * @param event Get child nodes event.
101 virtual void getChildNodes(const EventListNodesPtr& event) = 0;
104 * Gets stream for this node.
105 * @param mode @see Api::Filesystem::AccessMode.
106 * @return Stream connected with current node.
107 * @deprecated Use async version of thi method instead.
109 virtual IStreamPtr open(int mode) = 0;
112 * Gets stream for this node.
113 * @param mode @see Api::Filesystem::AccessMode.
114 * @return Stream connected with current node.
116 virtual void open(const EventOpenPtr& event) = 0;
119 * Removes underlying filesystem node.
120 * @param options Removal options (by default removal is recursive).
121 * @remarks Synchronous.
123 * - OPT_RECURSIVE - remove node recursively.
125 virtual void remove(int options = OPT_RECURSIVE) = 0;
128 * Creates child of current node.
129 * @param path Path to the node to create.
130 * @param type Type of the node @see Api::Filesystem::NodeType.
131 * @param options Additional options see remarks (no options by default).
132 * @return Ptr to newly created node.
135 * - OPT_RECURSIVE - attempt to create all necessary sub-directories
137 virtual INodePtr createChild(const IPathPtr& path,
139 int options = OPT_NONE) = 0;
142 * Gets size of this node.
145 virtual std::size_t getSize() const = 0;
148 * Gets creation date of this node.
151 virtual std::time_t getCreated() const = 0;
154 * Gets last modification date of this node.
157 virtual std::time_t getModified() const = 0;
160 * Gets parent of this node.
161 * @return Parent node or NULL if no parent (e.g. in case of a root node).
163 virtual INodePtr getParent() const = 0;
166 * Gets platform permissions.
167 * @return Platform permissions (set of flags from @see Permissions enum).
169 virtual int getMode() const = 0;
172 * Reads whole file as text.
173 * @param event Read file event.
175 virtual void read(const EventReadTextPtr& event) = 0;
177 virtual std::string toUri(int widgetId) const = 0;
187 #endif /* WRTDEVICEAPIS_FILESYSTEM_INODE_H_ */