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: Rebased. Corrected most of the review issues. Created July 4, 2017, 7:57 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&&,
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 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 const std::string& 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
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
LEFTRIGHT

Powered by Google App Engine
This is Rietveld