Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: include/AdblockPlus/FileSystem.h

Issue 5163715573841920: Issue 768 - Switch from TR1 to C++11 (Closed)
Left Patch Set: Created July 11, 2014, 2:24 p.m.
Right Patch Set: fix including of <memory> Created Aug. 7, 2015, 6:07 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « include/AdblockPlus/DefaultFileSystem.h ('k') | include/AdblockPlus/FilterEngine.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #ifndef ADBLOCK_PLUS_FILE_SYSTEM_H 18 #ifndef ADBLOCK_PLUS_FILE_SYSTEM_H
19 #define ADBLOCK_PLUS_FILE_SYSTEM_H 19 #define ADBLOCK_PLUS_FILE_SYSTEM_H
20 20
21 #include <istream> 21 #include <istream>
22 #include <memory>
23 #include <stdint.h> 22 #include <stdint.h>
24 #include <string> 23 #include <string>
24 #include <memory>
25 25
26 namespace AdblockPlus 26 namespace AdblockPlus
27 { 27 {
28 /**
29 * File system interface.
30 */
28 class FileSystem 31 class FileSystem
29 { 32 {
30 public: 33 public:
34 /**
35 * Result of a stat operation, i.e.\ information about a file.
36 */
31 struct StatResult 37 struct StatResult
32 { 38 {
33 StatResult() 39 StatResult()
34 { 40 {
35 exists = false; 41 exists = false;
36 isDirectory = false; 42 isDirectory = false;
37 isFile = false; 43 isFile = false;
38 lastModified = 0; 44 lastModified = 0;
39 } 45 }
40 46
47 /**
48 * File exists.
49 */
41 bool exists; 50 bool exists;
51
52 /**
53 * File is a directory.
54 */
42 bool isDirectory; 55 bool isDirectory;
56
57 /**
58 * File is a regular file.
59 */
43 bool isFile; 60 bool isFile;
61
62 /**
63 * POSIX time of the last modification.
64 */
44 int64_t lastModified; 65 int64_t lastModified;
45 }; 66 };
46 67
47 virtual ~FileSystem() {} 68 virtual ~FileSystem() {}
69
70 /**
71 * Reads from a file.
72 * @param path File path.
73 * @return Input stream with the file's contents.
74 */
48 virtual std::shared_ptr<std::istream> 75 virtual std::shared_ptr<std::istream>
49 Read(const std::string& path) const = 0; 76 Read(const std::string& path) const = 0;
77
78 /**
79 * Writes to a file.
80 * @param path File path.
81 * @param data Input stream with the data to write.
82 */
50 virtual void Write(const std::string& path, 83 virtual void Write(const std::string& path,
51 std::shared_ptr<std::istream> data) = 0; 84 std::shared_ptr<std::istream> data) = 0;
85
86 /**
87 * Moves a file (i.e.\ renames it).
88 * @param fromPath Current path to the file.
89 * @param toPath New path to the file.
90 */
52 virtual void Move(const std::string& fromPath, 91 virtual void Move(const std::string& fromPath,
53 const std::string& toPath) = 0; 92 const std::string& toPath) = 0;
93
94 /**
95 * Removes a file.
96 * @param path File path.
97 */
54 virtual void Remove(const std::string& path) = 0; 98 virtual void Remove(const std::string& path) = 0;
99
100 /**
101 * Retrieves information about a file.
102 * @param path File path.
103 * @return File information.
104 */
55 virtual StatResult Stat(const std::string& path) const = 0; 105 virtual StatResult Stat(const std::string& path) const = 0;
106
107 /**
108 * Returns the absolute path to a file.
109 * @param path File path (can be relative or absolute).
110 * @return Absolute file path.
111 */
56 virtual std::string Resolve(const std::string& path) const = 0; 112 virtual std::string Resolve(const std::string& path) const = 0;
57 }; 113 };
58 114
115 /**
116 * Shared smart pointer to a `FileSystem` instance.
117 */
59 typedef std::shared_ptr<FileSystem> FileSystemPtr; 118 typedef std::shared_ptr<FileSystem> FileSystemPtr;
60 } 119 }
61 120
62 #endif 121 #endif
LEFTRIGHT

Powered by Google App Engine
This is Rietveld