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 {
38 public Commons::EventRequestReceiver<EventListNodes>,
39 public Commons::EventRequestReceiver<EventOpen>,
40 public Commons::EventRequestReceiver<EventReadText>
43 typedef std::vector<std::string> NameList;
44 typedef NameList::iterator NodeListIterator;
50 * Gets direct child of this node.
51 * @param path Path to the child node.
52 * @return Ptr to the child node.
53 * @remarks Ownership passed to the caller.
55 virtual INodePtr getChild(const IPathPtr& path) = 0;
58 * Gets path of current node.
59 * @return Node's path.
61 virtual IPathPtr getPath() const = 0;
64 * Gets type of current node.
65 * @return Node's type.
67 virtual NodeType getType() const = 0;
70 * Gets permissions of the virtual node (not real filesystem node).
71 * @return Node's permissions.
73 virtual int getPermissions() const = 0;
76 * Sets permissions on the virtual node (not real filesystem node).
77 * @param perms Node's permissions @see Api::Filesystem::Permissions.
79 virtual void setPermissions(int perms) = 0;
82 * Gets list of names of direct child nodes.
83 * @return Names of child nodes.
85 virtual NameList getChildNames() const = 0;
88 * Gets list of direct child nodes.
89 * @return Child nodes.
90 * @remarks Ownership passed to the caller.
93 virtual NodeList getChildNodes(const NodeFilterPtr& filter =
94 NodeFilterPtr()) const /*DEPREC*/ = 0;
97 * Gets list of direct descendant nodes.
98 * @param event Get child nodes event.
100 virtual void getChildNodes(const EventListNodesPtr& event) = 0;
103 * Gets stream for this node.
104 * @param mode @see Api::Filesystem::AccessMode.
105 * @return Stream connected with current node.
106 * @deprecated Use async version of thi method instead.
108 virtual IStreamPtr open(int mode) = 0;
111 * Gets stream for this node.
112 * @param mode @see Api::Filesystem::AccessMode.
113 * @return Stream connected with current node.
115 virtual void open(const EventOpenPtr& event) = 0;
118 * Removes underlying filesystem node.
119 * @param options Removal options (by default removal is recursive).
120 * @remarks Synchronous.
122 * - OPT_RECURSIVE - remove node recursively.
124 virtual void remove(int options = OPT_RECURSIVE) = 0;
127 * Creates child of current node.
128 * @param path Path to the node to create.
129 * @param type Type of the node @see Api::Filesystem::NodeType.
130 * @param options Additional options see remarks (no options by default).
131 * @return Ptr to newly created node.
134 * - OPT_RECURSIVE - attempt to create all necessary sub-directories
136 virtual INodePtr createChild(const IPathPtr& path,
138 int options = OPT_NONE) = 0;
141 * Gets size of this node.
144 virtual std::size_t getSize() const = 0;
147 * Gets creation date of this node.
150 virtual std::time_t getCreated() const = 0;
153 * Gets last modification date of this node.
156 virtual std::time_t getModified() const = 0;
159 * Gets parent of this node.
160 * @return Parent node or NULL if no parent (e.g. in case of a root node).
162 virtual INodePtr getParent() const = 0;
165 * Gets platform permissions.
166 * @return Platform permissions (set of flags from @see Permissions enum).
168 virtual int getMode() const = 0;
171 * Reads whole file as text.
172 * @param event Read file event.
174 virtual void read(const EventReadTextPtr& event) = 0;
176 virtual std::string toUri(int widgetId) const = 0;
185 #endif /* WRTDEVICEAPIS_FILESYSTEM_INODE_H_ */