Home | History | Annotate | Download | only in nacl_io
      1 // Copyright (c) 2012 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_MOUNT_HTML5FS_NODE_H_
      6 #define LIBRARIES_NACL_IO_MOUNT_HTML5FS_NODE_H_
      7 
      8 #include <ppapi/c/pp_resource.h>
      9 #include "nacl_io/mount_node.h"
     10 
     11 namespace nacl_io {
     12 
     13 class MountHtml5Fs;
     14 
     15 class MountNodeHtml5Fs : public MountNode {
     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 mount.
     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(size_t offs, void* buf, size_t count, int* out_bytes);
     27   virtual Error FTruncate(off_t size);
     28   virtual Error Write(size_t offs,
     29                       const void* buf,
     30                       size_t count,
     31                       int* out_bytes);
     32 
     33   virtual Error GetSize(size_t *out_size);
     34 
     35  protected:
     36   MountNodeHtml5Fs(Mount* mount, PP_Resource fileref);
     37 
     38   // Init with standard open flags
     39   virtual Error Init(int o_mode);
     40   virtual void Destroy();
     41 
     42  private:
     43   PP_Resource fileref_resource_;
     44   PP_Resource fileio_resource_;  // 0 if the file is a directory.
     45 
     46   // Returns true if this node is a directory.
     47   bool IsDirectory() const {
     48     return !fileio_resource_;
     49   }
     50 
     51   friend class MountHtml5Fs;
     52 };
     53 
     54 }  // namespace nacl_io
     55 
     56 #endif  // LIBRARIES_NACL_IO_MOUNT_HTML5FS_NODE_H_
     57