Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / native_client_sdk / src / libraries / nacl_io / dir_node.h
blobc188d3fbe57dba39b9fc72b9711c89e31cc99f42
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 DirNode(Filesystem* fs, mode_t mode);
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);
46 virtual Error Fchmod(mode_t mode);
48 // Adds a finds or adds a directory entry as an INO, updating the refcount
49 virtual Error AddChild(const std::string& name, const ScopedNode& node);
50 virtual Error RemoveChild(const std::string& name);
51 virtual Error FindChild(const std::string& name, ScopedNode* out_node);
52 virtual int ChildCount();
54 protected:
55 void BuildCache_Locked();
56 void ClearCache_Locked();
58 private:
59 GetDentsHelper cache_;
60 NodeMap_t map_;
61 bool cache_built_;
63 friend class DevFs;
64 friend class Html5Fs;
65 friend class HttpFs;
66 friend class MemFs;
69 } // namespace nacl_io
71 #endif // LIBRARIES_NACL_IO_DIR_NODE_H_