Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / native_client_sdk / src / libraries / nacl_io / passthroughfs / real_node.h
1 // Copyright 2014 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.
4 //
5 #ifndef LIBRARIES_NACL_IO_PASSTHROUGHFS_REAL_NODE_H_
6 #define LIBRARIES_NACL_IO_PASSTHROUGHFS_REAL_NODE_H_
7
8 #include "nacl_io/node.h"
9
10 namespace nacl_io {
11
12 class RealNode : public Node {
13  public:
14   RealNode(Filesystem* filesystem, int real_fd, bool close_on_destroy = false);
15
16  protected:
17   virtual Error Init(int flags) { return 0; }
18
19   virtual void Destroy();
20
21  public:
22   // Normal read/write operations on a file
23   virtual Error Read(const HandleAttr& attr,
24                      void* buf,
25                      size_t count,
26                      int* out_bytes);
27   virtual Error Write(const HandleAttr& attr,
28                       const void* buf,
29                       size_t count,
30                       int* out_bytes);
31   virtual Error FTruncate(off_t size);
32   virtual Error GetDents(size_t offs,
33                          struct dirent* pdir,
34                          size_t count,
35                          int* out_bytes);
36   virtual Error GetStat(struct stat* stat);
37   virtual Error Isatty();
38   virtual Error MMap(void* addr,
39                      size_t length,
40                      int prot,
41                      int flags,
42                      size_t offset,
43                      void** out_addr);
44
45  private:
46   int real_fd_;
47   bool close_on_destroy_;
48 };
49
50 }  // namespace nacl_io
51
52 #endif  // LIBRARIES_NACL_IO_PASSTHROUGHFS_REAL_NODE_H_