| Index: ppapi/examples/filesystem_provider/memfilesystem.h
|
| diff --git a/ppapi/examples/filesystem_provider/memfilesystem.h b/ppapi/examples/filesystem_provider/memfilesystem.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..57884985fd83aeb98f41c34924a5f98e1c086aab
|
| --- /dev/null
|
| +++ b/ppapi/examples/filesystem_provider/memfilesystem.h
|
| @@ -0,0 +1,87 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef MEMFILESYSTEM_H_
|
| +#define MEMFILESYSTEM_H_
|
| +
|
| +#include "inode.h"
|
| +
|
| +namespace filesystem{
|
| +
|
| +// The filesystem Inode reference counter
|
| +class BookKeeper{
|
| +public:
|
| + virtual void AddLink(unsigned long long)=0;
|
| + virtual void RemoveLink(unsigned long long)=0;
|
| +};
|
| +
|
| +
|
| +class Filesystem : public BookKeeper{
|
| + public:
|
| + Filesystem();
|
| + virtual ~Filesystem();
|
| +
|
| + typedef enum{
|
| + File_System_Error_NONE,
|
| + File_System_Error_NOT_FOUND,
|
| + File_System_Error_EXISTS,
|
| + File_System_Error_FAILED,
|
| + File_System_Error_UNKNOWN
|
| + }File_System_Errors;
|
| + typedef std::pair< std::string, Inode* > NameInodePair;
|
| + // The meta param contains a pointer to an Inode which is
|
| + // not owned
|
| + int GetMetadata(const std::string& path, NameInodePair& meta);
|
| + int CreateDirectory(const std::string& path, bool recursive);
|
| + // The same Inode is used, references are modified
|
| + int MoveEntry(const std::string& source_path, const std::string& target_path);
|
| + // Copies an entry to another location by adding references to
|
| + // the underlying Inodes
|
| + int CopyEntry(const std::string& source_path,const std::string& target_path);
|
| + // Deletes entries and decrements references
|
| + int DeleteEntry(const std::string& path, bool recursive);
|
| + // The vector of metas contains an array of NameInodePair encapsulating
|
| + // not owned pointers
|
| + int ReadDirectory(const std::string& path, std::vector<NameInodePair>& metas);
|
| + // File operations that are delegated to a specific
|
| + // InodeFile based on path
|
| + int CreateFile(const std::string& file_path);
|
| + int Truncate(const std::string& file_path, size_t length);
|
| + int WriteToFile(
|
| + const std::string& file_path,
|
| + size_t offset,
|
| + size_t data_size,
|
| + const char* data );
|
| + int ReadFromFile(
|
| + const std::string &file_path,
|
| + size_t offset,
|
| + size_t* int_out_length,
|
| + const char** out_data);
|
| + // Inode management
|
| + virtual void AddLink(unsigned long long);
|
| + virtual void RemoveLink(unsigned long long);
|
| + protected:
|
| + // Internal function for Inode management
|
| + Inode* GetInode(unsigned long long);
|
| + void PutInode(unsigned long long inode_number, Inode*);
|
| + void RemoveInode(unsigned long long);
|
| + unsigned long long GetInodeFromPath(const std::string& path);
|
| +
|
| + unsigned long long GetNextInodeNumber();
|
| + // Inode index
|
| + unsigned long long currentInode_;
|
| + // "Must have" entry of the filesystem
|
| + const std::string root_path;
|
| + unsigned long long root_inode;
|
| +
|
| + // A pair composed of a ref counter and an owned pointer
|
| + typedef std::pair< int, Inode*> InodePair;
|
| + typedef std::map<unsigned long long, InodePair> ListOfInodes;
|
| + typedef ListOfInodes::iterator ListOfInodesIterator;
|
| + ListOfInodes inodesList_;
|
| +};
|
| +
|
| +}// namespace filesystem
|
| +
|
| +#endif // MEMFILESYSTEM_H_
|
|
|