Upstream version 5.34.92.0
[platform/framework/web/crosswalk.git] / src / native_client_sdk / src / libraries / nacl_io / html5fs / html5_fs_node.h
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.
4
5 #ifndef LIBRARIES_NACL_IO_HTML5FS_HTML5_FS_NODE_H_
6 #define LIBRARIES_NACL_IO_HTML5FS_HTML5_FS_NODE_H_
7
8 #include <ppapi/c/pp_resource.h>
9 #include "nacl_io/node.h"
10
11 namespace nacl_io {
12
13 class Html5Fs;
14
15 class Html5FsNode : public Node {
16  public:
17   // Normal OS operations on a node (file), can be called by the kernel
18   // directly so it must lock and unlock appropriately.  These functions
19   // must not be called by the filesystem.
20   virtual Error FSync();
21   virtual Error GetDents(size_t offs,
22                          struct dirent* pdir,
23                          size_t count,
24                          int* out_bytes);
25   virtual Error GetStat(struct stat* stat);
26   virtual Error Read(const HandleAttr& attr,
27                      void* buf,
28                      size_t count,
29                      int* out_bytes);
30   virtual Error FTruncate(off_t size);
31   virtual Error Write(const HandleAttr& attr,
32                       const void* buf,
33                       size_t count,
34                       int* out_bytes);
35
36   virtual int GetType();
37   virtual Error GetSize(size_t* out_size);
38   virtual bool IsaDir();
39   virtual bool IsaFile();
40
41  protected:
42   Html5FsNode(Filesystem* filesystem, PP_Resource fileref);
43
44   // Init with standard open flags
45   virtual Error Init(int open_flags);
46   virtual void Destroy();
47
48  private:
49   PP_Resource fileref_resource_;
50   PP_Resource fileio_resource_;  // 0 if the file is a directory.
51
52   friend class Html5Fs;
53 };
54
55 }  // namespace nacl_io
56
57 #endif  // LIBRARIES_NACL_IO_HTML5FS_HTML5_FS_NODE_H_