Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Side by Side Diff: ppapi/examples/filesystem_provider/memfilesystem.h

Issue 1093383002: [WIP] Provided file system from NACL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Various cleanups Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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 MEMFILESYSTEM_H_
6 #define MEMFILESYSTEM_H_
7
8 #include "inode.h"
9
10 namespace filesystem{
11
12 // The filesystem Inode reference counter
13 class BookKeeper{
14 public:
15 virtual void AddLink(unsigned long long)=0;
16 virtual void RemoveLink(unsigned long long)=0;
17 };
18
19
20 class Filesystem : public BookKeeper{
21 public:
22 Filesystem();
23 virtual ~Filesystem();
24
25 typedef enum{
26 File_System_Error_NONE,
27 File_System_Error_NOT_FOUND,
28 File_System_Error_EXISTS,
29 File_System_Error_FAILED,
30 File_System_Error_UNKNOWN
31 }File_System_Errors;
32 typedef std::pair< std::string, Inode* > NameInodePair;
33 // The meta param contains a pointer to an Inode which is
34 // not owned
35 int GetMetadata(const std::string& path, NameInodePair& meta);
36 int CreateDirectory(const std::string& path, bool recursive);
37 // The same Inode is used, references are modified
38 int MoveEntry(const std::string& source_path, const std::string& target_path);
39 // Copies an entry to another location by adding references to
40 // the underlying Inodes
41 int CopyEntry(const std::string& source_path,const std::string& target_path);
42 // Deletes entries and decrements references
43 int DeleteEntry(const std::string& path, bool recursive);
44 // The vector of metas contains an array of NameInodePair encapsulating
45 // not owned pointers
46 int ReadDirectory(const std::string& path, std::vector<NameInodePair>& metas);
47 // File operations that are delegated to a specific
48 // InodeFile based on path
49 int CreateFile(const std::string& file_path);
50 int Truncate(const std::string& file_path, size_t length);
51 int WriteToFile(
52 const std::string& file_path,
53 size_t offset,
54 size_t data_size,
55 const char* data );
56 int ReadFromFile(
57 const std::string &file_path,
58 size_t offset,
59 size_t* int_out_length,
60 const char** out_data);
61 // Inode management
62 virtual void AddLink(unsigned long long);
63 virtual void RemoveLink(unsigned long long);
64 protected:
65 // Internal function for Inode management
66 Inode* GetInode(unsigned long long);
67 void PutInode(unsigned long long inode_number, Inode*);
68 void RemoveInode(unsigned long long);
69 unsigned long long GetInodeFromPath(const std::string& path);
70
71 unsigned long long GetNextInodeNumber();
72 // Inode index
73 unsigned long long currentInode_;
74 // "Must have" entry of the filesystem
75 const std::string root_path;
76 unsigned long long root_inode;
77
78 // A pair composed of a ref counter and an owned pointer
79 typedef std::pair< int, Inode*> InodePair;
80 typedef std::map<unsigned long long, InodePair> ListOfInodes;
81 typedef ListOfInodes::iterator ListOfInodesIterator;
82 ListOfInodes inodesList_;
83 };
84
85 }// namespace filesystem
86
87 #endif // MEMFILESYSTEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698