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

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

Issue 29449592: Issue 5183 - Provide async interface for FileSystem (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Left Patch Set: Remove a #include Utils.h from test. Created June 2, 2017, 7:38 p.m.
Right Patch Set: Rebase on master. Last changes. Created July 7, 2017, 1:36 p.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/FileSystem.h ('k') | include/AdblockPlus/JsEngine.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 <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
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&&,
sergei 2017/06/16 15:05:54 I think that the data type for the read data shoul
hub 2017/06/16 21:52:53 I don't think it is better since further down in t
sergei 2017/07/03 09:25:53 I think we can have it but in general I disagree w
hub 2017/07/04 21:20:14 IMHO the C++ iostream interface isn't really conve
sergei 2017/07/05 10:03:20 It's not actually difficult, one has to firstly ob
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,
sergei 2017/06/16 15:05:54 Instead of `std::shared_ptr<std::istream>` it woul
hub 2017/06/16 21:52:54 I'd rather use std::string for the same reason as
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 24 matching lines...) Expand all
134 * Returns the absolute path to a file. 138 * Returns the absolute path to a file.
135 * @param path File path (can be relative or absolute). 139 * @param path File path (can be relative or absolute).
136 * @return Absolute file path. 140 * @return Absolute file path.
137 */ 141 */
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;
sergei 2017/06/16 15:05:54 OK now, but in future I think it should be std::un
hub 2017/06/16 21:52:53 Acknowledged.
145 } 149 }
146 150
147 #endif 151 #endif
LEFTRIGHT

Powered by Google App Engine
This is Rietveld