| Index: ppapi/examples/filesystem_provider/inode.h
|
| diff --git a/ppapi/examples/filesystem_provider/inode.h b/ppapi/examples/filesystem_provider/inode.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6c0b4bf40b1203fab9ccb560670c04222b31e18a
|
| --- /dev/null
|
| +++ b/ppapi/examples/filesystem_provider/inode.h
|
| @@ -0,0 +1,101 @@
|
| +// 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 INODE_H_
|
| +#define INODE_H_
|
| +
|
| +#include <map>
|
| +#include <string>
|
| +#include <vector>
|
| +
|
| +namespace filesystem{
|
| +//"Thu Apr 24 00:46:52 UTC 2014"
|
| +class BookKeeper;
|
| +
|
| +class Inode{
|
| +public:
|
| + typedef enum{
|
| + FILE_TYPE_UNKNOWN = 0,
|
| + FILE_TYPE_FILE,
|
| + FILE_TYPE_DIR,
|
| + }FILE_TYPE;
|
| + typedef enum{
|
| + NO_INODE = 0
|
| + }Inode_Type;
|
| + Inode(
|
| + unsigned long long appointed_inode, int file_type,
|
| + const std::string& inode_modified = "",const std::string& file_modified="",
|
| + const std::string& file_access="");
|
| + virtual ~Inode();
|
| + // Accessors and mutators
|
| + void set_inode_number( unsigned long long inode );
|
| + unsigned long long inode_number() const;
|
| + void set_file_type(int type);
|
| + int file_type() const;
|
| + void set_file_access(const std::string& file_access = "");
|
| + std::string file_access() const;
|
| + void set_file_modified(const std::string& file_modified = "");
|
| + std::string file_modified() const;
|
| + void set_inode_modified(const std::string& inode_modified = "");
|
| + std::string inode_modified() const;
|
| + virtual unsigned long long size() const { return 0; }
|
| + static std::string CurentTime();
|
| +protected:
|
| + // Unique ID for the inode
|
| + unsigned long long inode_number_;
|
| + // One of the FILE_TYPE enum
|
| + int file_type_;
|
| + // Containers for timestamps
|
| + std::string file_access_;
|
| + std::string file_modified_;
|
| + std::string inode_modified_;
|
| +};
|
| +
|
| +class InodeFile : public Inode{
|
| + public:
|
| + InodeFile(
|
| + unsigned long long appointed_inode,
|
| + std::string inode_modified = "",
|
| + std::string file_modified = "",
|
| + std::string file_access = "");
|
| + virtual ~InodeFile();
|
| + virtual unsigned long long size() const { return data_.size(); }
|
| + bool Truncate(const size_t length );
|
| + bool Write(const char *data, uint64_t offset, uint64_t dataSize );
|
| + bool Read(size_t offset, size_t* inOutLen, const char** outData ) const ;
|
| + protected:
|
| + // Payload holder
|
| + std::string data_;
|
| +};
|
| +
|
| +class InodeDirectory : public Inode{
|
| + public:
|
| + typedef std::pair< std::string, unsigned long long > EntryPair;
|
| + // Operations that manipulate
|
| + // entries_ list.
|
| + unsigned long long GetInodeFromName(const std::string& name);
|
| + void AddEntry(const std::string& name, unsigned long long inode);
|
| + void DeleteEntry(const std::string& name, unsigned long long inode);
|
| + // Gets all inodes from entries_
|
| + void GetAllInodes(std::vector<EntryPair>& inodes) ;
|
| + virtual unsigned long long size() const { return 0; }
|
| +
|
| + InodeDirectory(
|
| + BookKeeper* bookKeeper,
|
| + unsigned long long appointed_inode,
|
| + std::string inode_modified = "", std::string file_modified = "",
|
| + std::string file_access = "");
|
| +
|
| + virtual ~InodeDirectory();
|
| + protected:
|
| + typedef std::map< std::string, unsigned long long > ListOfEntries;
|
| + typedef ListOfEntries::iterator ListOfEntriesIterator;
|
| + ListOfEntries entries_;
|
| + BookKeeper *book_keeper_;
|
| +
|
| +};
|
| +
|
| +}// namespace filesystem
|
| +
|
| +#endif // INODE_H_
|
|
|