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

Side by Side Diff: include/AdblockPlus/FileSystem.h

Issue 5728380594946048: Issue 116 - Document the libadblockplus API (Closed)
Patch Set: Fix the broken sentence properly Created Sept. 2, 2014, 1:23 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/AdblockPlus/DefaultWebRequest.h ('k') | include/AdblockPlus/FilterEngine.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 <stdint.h> 22 #include <stdint.h>
23 #include <string> 23 #include <string>
24 24
25 #include "tr1_memory.h" 25 #include "tr1_memory.h"
26 26
27 namespace AdblockPlus 27 namespace AdblockPlus
28 { 28 {
29 /**
30 * File system interface.
31 */
29 class FileSystem 32 class FileSystem
30 { 33 {
31 public: 34 public:
35 /**
36 * Result of a stat operation, i.e.\ information about a file.
37 */
32 struct StatResult 38 struct StatResult
33 { 39 {
34 StatResult() 40 StatResult()
35 { 41 {
36 exists = false; 42 exists = false;
37 isDirectory = false; 43 isDirectory = false;
38 isFile = false; 44 isFile = false;
39 lastModified = 0; 45 lastModified = 0;
40 } 46 }
41 47
48 /**
49 * File exists.
50 */
42 bool exists; 51 bool exists;
52
53 /**
54 * File is a directory.
55 */
43 bool isDirectory; 56 bool isDirectory;
57
58 /**
59 * File is a regular file.
60 */
44 bool isFile; 61 bool isFile;
62
63 /**
64 * POSIX time of the last modification.
65 */
45 int64_t lastModified; 66 int64_t lastModified;
46 }; 67 };
47 68
48 virtual ~FileSystem() {} 69 virtual ~FileSystem() {}
70
71 /**
72 * Reads from a file.
73 * @param path File path.
74 * @return Input stream with the file's contents.
75 */
49 virtual std::tr1::shared_ptr<std::istream> 76 virtual std::tr1::shared_ptr<std::istream>
50 Read(const std::string& path) const = 0; 77 Read(const std::string& path) const = 0;
78
79 /**
80 * Writes to a file.
81 * @param path File path.
82 * @param data Input stream with the data to write.
83 */
51 virtual void Write(const std::string& path, 84 virtual void Write(const std::string& path,
52 std::tr1::shared_ptr<std::istream> data) = 0; 85 std::tr1::shared_ptr<std::istream> data) = 0;
86
87 /**
88 * Moves a file (i.e.\ renames it).
89 * @param fromPath Current path to the file.
90 * @param toPath New path to the file.
91 */
53 virtual void Move(const std::string& fromPath, 92 virtual void Move(const std::string& fromPath,
54 const std::string& toPath) = 0; 93 const std::string& toPath) = 0;
94
95 /**
96 * Removes a file.
97 * @param path File path.
98 */
55 virtual void Remove(const std::string& path) = 0; 99 virtual void Remove(const std::string& path) = 0;
100
101 /**
102 * Retrieves information about a file.
103 * @param path File path.
104 * @return File information.
105 */
56 virtual StatResult Stat(const std::string& path) const = 0; 106 virtual StatResult Stat(const std::string& path) const = 0;
107
108 /**
109 * Returns the absolute path to a file.
110 * @param path File path (can be relative or absolute).
111 * @return Absolute file path.
112 */
57 virtual std::string Resolve(const std::string& path) const = 0; 113 virtual std::string Resolve(const std::string& path) const = 0;
58 }; 114 };
59 115
116 /**
117 * Shared smart pointer to a `FileSystem` instance.
118 */
60 typedef std::tr1::shared_ptr<FileSystem> FileSystemPtr; 119 typedef std::tr1::shared_ptr<FileSystem> FileSystemPtr;
61 } 120 }
62 121
63 #endif 122 #endif
OLDNEW
« no previous file with comments | « include/AdblockPlus/DefaultWebRequest.h ('k') | include/AdblockPlus/FilterEngine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld