OLD | NEW |
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 65 } |
66 catch (std::exception& e) | 66 catch (std::exception& e) |
67 { | 67 { |
68 error = e.what(); | 68 error = e.what(); |
69 } | 69 } |
70 catch (...) | 70 catch (...) |
71 { | 71 { |
72 error = "Unknown error while reading from " + path; | 72 error = "Unknown error while reading from " + path; |
73 } | 73 } |
74 | 74 |
75 const JsContext context(jsEngine); | 75 const JsContext context(*jsEngine); |
76 auto result = jsEngine->NewObject(); | 76 auto result = jsEngine->NewObject(); |
77 result.SetProperty("content", content); | 77 result.SetProperty("content", content); |
78 result.SetProperty("error", error); | 78 result.SetProperty("error", error); |
79 JsValueList params; | 79 JsValueList params; |
80 params.push_back(result); | 80 params.push_back(result); |
81 callback.Call(params); | 81 callback.Call(params); |
82 } | 82 } |
83 | 83 |
84 private: | 84 private: |
85 std::string path; | 85 std::string path; |
(...skipping 19 matching lines...) Expand all Loading... |
105 } | 105 } |
106 catch (std::exception& e) | 106 catch (std::exception& e) |
107 { | 107 { |
108 error = e.what(); | 108 error = e.what(); |
109 } | 109 } |
110 catch (...) | 110 catch (...) |
111 { | 111 { |
112 error = "Unknown error while writing to " + path; | 112 error = "Unknown error while writing to " + path; |
113 } | 113 } |
114 | 114 |
115 const JsContext context(jsEngine); | 115 const JsContext context(*jsEngine); |
116 auto errorValue = jsEngine->NewValue(error); | 116 auto errorValue = jsEngine->NewValue(error); |
117 JsValueList params; | 117 JsValueList params; |
118 params.push_back(errorValue); | 118 params.push_back(errorValue); |
119 callback.Call(params); | 119 callback.Call(params); |
120 } | 120 } |
121 | 121 |
122 private: | 122 private: |
123 std::string path; | 123 std::string path; |
124 std::string content; | 124 std::string content; |
125 }; | 125 }; |
(...skipping 16 matching lines...) Expand all Loading... |
142 } | 142 } |
143 catch (std::exception& e) | 143 catch (std::exception& e) |
144 { | 144 { |
145 error = e.what(); | 145 error = e.what(); |
146 } | 146 } |
147 catch (...) | 147 catch (...) |
148 { | 148 { |
149 error = "Unknown error while moving " + fromPath + " to " + toPath; | 149 error = "Unknown error while moving " + fromPath + " to " + toPath; |
150 } | 150 } |
151 | 151 |
152 const JsContext context(jsEngine); | 152 const JsContext context(*jsEngine); |
153 auto errorValue = jsEngine->NewValue(error); | 153 auto errorValue = jsEngine->NewValue(error); |
154 JsValueList params; | 154 JsValueList params; |
155 params.push_back(errorValue); | 155 params.push_back(errorValue); |
156 callback.Call(params); | 156 callback.Call(params); |
157 } | 157 } |
158 | 158 |
159 private: | 159 private: |
160 std::string fromPath; | 160 std::string fromPath; |
161 std::string toPath; | 161 std::string toPath; |
162 }; | 162 }; |
(...skipping 16 matching lines...) Expand all Loading... |
179 } | 179 } |
180 catch (std::exception& e) | 180 catch (std::exception& e) |
181 { | 181 { |
182 error = e.what(); | 182 error = e.what(); |
183 } | 183 } |
184 catch (...) | 184 catch (...) |
185 { | 185 { |
186 error = "Unknown error while removing " + path; | 186 error = "Unknown error while removing " + path; |
187 } | 187 } |
188 | 188 |
189 const JsContext context(jsEngine); | 189 const JsContext context(*jsEngine); |
190 auto errorValue = jsEngine->NewValue(error); | 190 auto errorValue = jsEngine->NewValue(error); |
191 JsValueList params; | 191 JsValueList params; |
192 params.push_back(errorValue); | 192 params.push_back(errorValue); |
193 callback.Call(params); | 193 callback.Call(params); |
194 } | 194 } |
195 | 195 |
196 private: | 196 private: |
197 std::string path; | 197 std::string path; |
198 }; | 198 }; |
199 | 199 |
(...skipping 17 matching lines...) Expand all Loading... |
217 } | 217 } |
218 catch (std::exception& e) | 218 catch (std::exception& e) |
219 { | 219 { |
220 error = e.what(); | 220 error = e.what(); |
221 } | 221 } |
222 catch (...) | 222 catch (...) |
223 { | 223 { |
224 error = "Unknown error while calling stat on " + path; | 224 error = "Unknown error while calling stat on " + path; |
225 } | 225 } |
226 | 226 |
227 const JsContext context(jsEngine); | 227 const JsContext context(*jsEngine); |
228 auto result = jsEngine->NewObject(); | 228 auto result = jsEngine->NewObject(); |
229 result.SetProperty("exists", statResult.exists); | 229 result.SetProperty("exists", statResult.exists); |
230 result.SetProperty("isFile", statResult.isFile); | 230 result.SetProperty("isFile", statResult.isFile); |
231 result.SetProperty("isDirectory", statResult.isDirectory); | 231 result.SetProperty("isDirectory", statResult.isDirectory); |
232 result.SetProperty("lastModified", statResult.lastModified); | 232 result.SetProperty("lastModified", statResult.lastModified); |
233 result.SetProperty("error", error); | 233 result.SetProperty("error", error); |
234 | 234 |
235 JsValueList params; | 235 JsValueList params; |
236 params.push_back(result); | 236 params.push_back(result); |
237 callback.Call(params); | 237 callback.Call(params); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 JsValue& FileSystemJsObject::Setup(JsEngine& jsEngine, JsValue& obj) | 352 JsValue& FileSystemJsObject::Setup(JsEngine& jsEngine, JsValue& obj) |
353 { | 353 { |
354 obj.SetProperty("read", jsEngine.NewCallback(::ReadCallback)); | 354 obj.SetProperty("read", jsEngine.NewCallback(::ReadCallback)); |
355 obj.SetProperty("write", jsEngine.NewCallback(::WriteCallback)); | 355 obj.SetProperty("write", jsEngine.NewCallback(::WriteCallback)); |
356 obj.SetProperty("move", jsEngine.NewCallback(::MoveCallback)); | 356 obj.SetProperty("move", jsEngine.NewCallback(::MoveCallback)); |
357 obj.SetProperty("remove", jsEngine.NewCallback(::RemoveCallback)); | 357 obj.SetProperty("remove", jsEngine.NewCallback(::RemoveCallback)); |
358 obj.SetProperty("stat", jsEngine.NewCallback(::StatCallback)); | 358 obj.SetProperty("stat", jsEngine.NewCallback(::StatCallback)); |
359 obj.SetProperty("resolve", jsEngine.NewCallback(::ResolveCallback)); | 359 obj.SetProperty("resolve", jsEngine.NewCallback(::ResolveCallback)); |
360 return obj; | 360 return obj; |
361 } | 361 } |
OLD | NEW |