LEFT | RIGHT |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 bool isFile; | 61 bool isFile; |
62 | 62 |
63 /** | 63 /** |
64 * POSIX time of the last modification. | 64 * POSIX time of the last modification. |
65 */ | 65 */ |
66 int64_t lastModified; | 66 int64_t lastModified; |
67 }; | 67 }; |
68 | 68 |
69 virtual ~IFileSystem() {} | 69 virtual ~IFileSystem() {} |
70 | 70 |
| 71 /** Type for the buffer used for IO */ |
| 72 typedef std::vector<uint8_t> IOBuffer; |
| 73 |
71 /** | 74 /** |
72 * Default callback type for asynchronous filesystem calls. | 75 * Default callback type for asynchronous filesystem calls. |
73 * @param An error string. Empty is success. | 76 * @param An error string. Empty is success. |
74 */ | 77 */ |
75 typedef std::function<void(const std::string&)> Callback; | 78 typedef std::function<void(const std::string&)> Callback; |
76 | 79 |
77 /** | 80 /** |
78 * Callback type for the asynchronous Read call. | 81 * Callback type for the asynchronous Read call. |
79 * @param Output char array with file content. | 82 * @param Output char array with file content. |
80 * @param An error string. Empty if success. | 83 * @param An error string. Empty if success. |
81 */ | 84 */ |
82 typedef std::function<void(std::string&&, const std::string&)> ReadCallback; | 85 typedef std::function<void(IOBuffer&&, |
| 86 const std::string&)> ReadCallback; |
83 | 87 |
84 /** | 88 /** |
85 * Reads from a file. | 89 * Reads from a file. |
86 * @param path File path. | 90 * @param path File path. |
87 * @param callback The function called on completion with the input data. | 91 * @param callback The function called on completion with the input data. |
88 */ | 92 */ |
89 virtual void Read(const std::string& path, | 93 virtual void Read(const std::string& path, |
90 const ReadCallback& callback) const = 0; | 94 const ReadCallback& callback) const = 0; |
91 | 95 |
92 /** | 96 /** |
93 * Writes to a file. | 97 * Writes to a file. |
94 * @param path File path. | 98 * @param path File path. |
95 * @param data Input stream with the data to write. | 99 * @param data The data to write. |
96 * @param callback The function called on completion. | 100 * @param callback The function called on completion. |
97 */ | 101 */ |
98 virtual void Write(const std::string& path, | 102 virtual void Write(const std::string& path, |
99 std::shared_ptr<std::istream> data, | 103 const IOBuffer& data, |
100 const Callback& callback) = 0; | 104 const Callback& callback) = 0; |
101 | 105 |
102 /** | 106 /** |
103 * Moves a file (i.e.\ renames it). | 107 * Moves a file (i.e.\ renames it). |
104 * @param fromPath Current path to the file. | 108 * @param fromPath Current path to the file. |
105 * @param toPath New path to the file. | 109 * @param toPath New path to the file. |
106 * @param callback The function called on completion. | 110 * @param callback The function called on completion. |
107 */ | 111 */ |
108 virtual void Move(const std::string& fromPath, const std::string& toPath, | 112 virtual void Move(const std::string& fromPath, const std::string& toPath, |
109 const Callback& callback) = 0; | 113 const Callback& callback) = 0; |
(...skipping 28 matching lines...) Expand all Loading... |
138 virtual std::string Resolve(const std::string& path) const = 0; | 142 virtual std::string Resolve(const std::string& path) const = 0; |
139 }; | 143 }; |
140 | 144 |
141 /** | 145 /** |
142 * Shared smart pointer to a `IFileSystem` instance. | 146 * Shared smart pointer to a `IFileSystem` instance. |
143 */ | 147 */ |
144 typedef std::shared_ptr<IFileSystem> FileSystemPtr; | 148 typedef std::shared_ptr<IFileSystem> FileSystemPtr; |
145 } | 149 } |
146 | 150 |
147 #endif | 151 #endif |
LEFT | RIGHT |