Left: | ||
Right: |
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::vector<char>&&, | 85 typedef std::function<void(IOBuffer&&, |
sergei
2017/07/06 14:14:05
Since it's for bytes, I would rather prefer an uns
hub
2017/07/06 14:33:31
But iostream and making it harder. If I use std::v
sergei
2017/07/06 14:53:33
I think we should simply cast to `const char*` or
hub
2017/07/06 21:24:30
fair enough.
| |
83 const std::string&)> ReadCallback; | 86 const std::string&)> ReadCallback; |
84 | 87 |
85 /** | 88 /** |
86 * Reads from a file. | 89 * Reads from a file. |
87 * @param path File path. | 90 * @param path File path. |
88 * @param callback The function called on completion with the input data. | 91 * @param callback The function called on completion with the input data. |
89 */ | 92 */ |
90 virtual void Read(const std::string& path, | 93 virtual void Read(const std::string& path, |
91 const ReadCallback& callback) const = 0; | 94 const ReadCallback& callback) const = 0; |
92 | 95 |
93 /** | 96 /** |
94 * Writes to a file. | 97 * Writes to a file. |
95 * @param path File path. | 98 * @param path File path. |
96 * @param data The data to write. | 99 * @param data The data to write. |
97 * @param callback The function called on completion. | 100 * @param callback The function called on completion. |
98 */ | 101 */ |
99 virtual void Write(const std::string& path, | 102 virtual void Write(const std::string& path, |
100 const std::vector<char>& data, | 103 const IOBuffer& data, |
101 const Callback& callback) = 0; | 104 const Callback& callback) = 0; |
102 | 105 |
103 /** | 106 /** |
104 * Moves a file (i.e.\ renames it). | 107 * Moves a file (i.e.\ renames it). |
105 * @param fromPath Current path to the file. | 108 * @param fromPath Current path to the file. |
106 * @param toPath New path to the file. | 109 * @param toPath New path to the file. |
107 * @param callback The function called on completion. | 110 * @param callback The function called on completion. |
108 */ | 111 */ |
109 virtual void Move(const std::string& fromPath, const std::string& toPath, | 112 virtual void Move(const std::string& fromPath, const std::string& toPath, |
110 const Callback& callback) = 0; | 113 const Callback& callback) = 0; |
(...skipping 28 matching lines...) Expand all Loading... | |
139 virtual std::string Resolve(const std::string& path) const = 0; | 142 virtual std::string Resolve(const std::string& path) const = 0; |
140 }; | 143 }; |
141 | 144 |
142 /** | 145 /** |
143 * Shared smart pointer to a `IFileSystem` instance. | 146 * Shared smart pointer to a `IFileSystem` instance. |
144 */ | 147 */ |
145 typedef std::shared_ptr<IFileSystem> FileSystemPtr; | 148 typedef std::shared_ptr<IFileSystem> FileSystemPtr; |
146 } | 149 } |
147 | 150 |
148 #endif | 151 #endif |
LEFT | RIGHT |