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

Side by Side Diff: ppapi/examples/filesystem_provider/inode.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 INODE_H_
6 #define INODE_H_
7
8 #include <map>
9 #include <string>
10 #include <vector>
11
12 namespace filesystem{
13 //"Thu Apr 24 00:46:52 UTC 2014"
14 class BookKeeper;
15
16 class Inode{
17 public:
18 typedef enum{
19 FILE_TYPE_UNKNOWN = 0,
20 FILE_TYPE_FILE,
21 FILE_TYPE_DIR,
22 }FILE_TYPE;
23 typedef enum{
24 NO_INODE = 0
25 }Inode_Type;
26 Inode(
27 unsigned long long appointed_inode, int file_type,
28 const std::string& inode_modified = "",const std::string& file_modified="",
29 const std::string& file_access="");
30 virtual ~Inode();
31 // Accessors and mutators
32 void set_inode_number( unsigned long long inode );
33 unsigned long long inode_number() const;
34 void set_file_type(int type);
35 int file_type() const;
36 void set_file_access(const std::string& file_access = "");
37 std::string file_access() const;
38 void set_file_modified(const std::string& file_modified = "");
39 std::string file_modified() const;
40 void set_inode_modified(const std::string& inode_modified = "");
41 std::string inode_modified() const;
42 virtual unsigned long long size() const { return 0; }
43 static std::string CurentTime();
44 protected:
45 // Unique ID for the inode
46 unsigned long long inode_number_;
47 // One of the FILE_TYPE enum
48 int file_type_;
49 // Containers for timestamps
50 std::string file_access_;
51 std::string file_modified_;
52 std::string inode_modified_;
53 };
54
55 class InodeFile : public Inode{
56 public:
57 InodeFile(
58 unsigned long long appointed_inode,
59 std::string inode_modified = "",
60 std::string file_modified = "",
61 std::string file_access = "");
62 virtual ~InodeFile();
63 virtual unsigned long long size() const { return data_.size(); }
64 bool Truncate(const size_t length );
65 bool Write(const char *data, uint64_t offset, uint64_t dataSize );
66 bool Read(size_t offset, size_t* inOutLen, const char** outData ) const ;
67 protected:
68 // Payload holder
69 std::string data_;
70 };
71
72 class InodeDirectory : public Inode{
73 public:
74 typedef std::pair< std::string, unsigned long long > EntryPair;
75 // Operations that manipulate
76 // entries_ list.
77 unsigned long long GetInodeFromName(const std::string& name);
78 void AddEntry(const std::string& name, unsigned long long inode);
79 void DeleteEntry(const std::string& name, unsigned long long inode);
80 // Gets all inodes from entries_
81 void GetAllInodes(std::vector<EntryPair>& inodes) ;
82 virtual unsigned long long size() const { return 0; }
83
84 InodeDirectory(
85 BookKeeper* bookKeeper,
86 unsigned long long appointed_inode,
87 std::string inode_modified = "", std::string file_modified = "",
88 std::string file_access = "");
89
90 virtual ~InodeDirectory();
91 protected:
92 typedef std::map< std::string, unsigned long long > ListOfEntries;
93 typedef ListOfEntries::iterator ListOfEntriesIterator;
94 ListOfEntries entries_;
95 BookKeeper *book_keeper_;
96
97 };
98
99 }// namespace filesystem
100
101 #endif // INODE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698