Home | History | Annotate | Download | only in html5fs
      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_instance.h>
      9 #include <ppapi/c/pp_resource.h>
     10 #include "nacl_io/node.h"
     11 
     12 namespace nacl_io {
     13 
     14 class Html5Fs;
     15 class FileIoInterface;
     16 class FileRefInterface;
     17 class VarInterface;
     18 
     19 class Html5FsNode : public Node {
     20  public:
     21   // Normal OS operations on a node (file), can be called by the kernel
     22   // directly so it must lock and unlock appropriately.  These functions
     23   // must not be called by the filesystem.
     24   virtual Error FSync();
     25   virtual Error GetDents(size_t offs,
     26                          struct dirent* pdir,
     27                          size_t count,
     28                          int* out_bytes);
     29   virtual Error GetStat(struct stat* stat);
     30   virtual Error Read(const HandleAttr& attr,
     31                      void* buf,
     32                      size_t count,
     33                      int* out_bytes);
     34   virtual Error FTruncate(off_t size);
     35   virtual Error Write(const HandleAttr& attr,
     36                       const void* buf,
     37                       size_t count,
     38                       int* out_bytes);
     39 
     40   virtual int GetType();
     41   virtual Error GetSize(off_t* out_size);
     42 
     43  protected:
     44   Html5FsNode(Filesystem* filesystem, PP_Resource fileref);
     45 
     46   // Init with standard open flags
     47   virtual Error Init(int open_flags);
     48   virtual void Destroy();
     49 
     50  private:
     51   FileIoInterface* file_io_iface_;
     52   FileRefInterface* file_ref_iface_;
     53   VarInterface* var_iface_;
     54   PP_Resource fileref_resource_;
     55   PP_Resource fileio_resource_;  // 0 if the file is a directory.
     56 
     57   friend class Html5Fs;
     58 };
     59 
     60 }  // namespace nacl_io
     61 
     62 #endif  // LIBRARIES_NACL_IO_HTML5FS_HTML5_FS_NODE_H_
     63