Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / native_client_sdk / src / libraries / nacl_io / dir_node.h
blob29d271f7f679dfac1f36a4af332268d51a83a35b
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef LIBRARIES_NACL_IO_DIR_NODE_H_
6 #define LIBRARIES_NACL_IO_DIR_NODE_H_
8 #include <map>
9 #include <string>
10 #include <vector>
12 #include "nacl_io/getdents_helper.h"
13 #include "nacl_io/node.h"
15 namespace nacl_io {
17 class DevFs;
18 class Html5Fs;
19 class HttpFs;
20 class MemFs;
21 class DirNode;
23 typedef sdk_util::ScopedRef<DirNode> ScopedDirNode;
25 class DirNode : public Node {
26 protected:
27 explicit DirNode(Filesystem* fs);
28 virtual ~DirNode();
30 public:
31 typedef std::map<std::string, ScopedNode> NodeMap_t;
33 virtual Error FTruncate(off_t size);
34 virtual Error GetDents(size_t offs,
35 struct dirent* pdir,
36 size_t count,
37 int* out_bytes);
38 virtual Error Read(const HandleAttr& attr,
39 void* buf,
40 size_t count,
41 int* out_bytes);
42 virtual Error Write(const HandleAttr& attr,
43 const void* buf,
44 size_t count,
45 int* out_bytes);
47 // Adds a finds or adds a directory entry as an INO, updating the refcount
48 virtual Error AddChild(const std::string& name, const ScopedNode& node);
49 virtual Error RemoveChild(const std::string& name);
50 virtual Error FindChild(const std::string& name, ScopedNode* out_node);
51 virtual int ChildCount();
53 protected:
54 void BuildCache_Locked();
55 void ClearCache_Locked();
57 private:
58 GetDentsHelper cache_;
59 NodeMap_t map_;
60 bool cache_built_;
62 friend class DevFs;
63 friend class Html5Fs;
64 friend class HttpFs;
65 friend class MemFs;
68 } // namespace nacl_io
70 #endif // LIBRARIES_NACL_IO_DIR_NODE_H_