| 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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 : IoThread(jsEngine, callback), path(path) | 54 : IoThread(jsEngine, callback), path(path) |
| 55 { | 55 { |
| 56 } | 56 } |
| 57 | 57 |
| 58 void Run() | 58 void Run() |
| 59 { | 59 { |
| 60 std::string content; | 60 std::string content; |
| 61 std::string error; | 61 std::string error; |
| 62 try | 62 try |
| 63 { | 63 { |
| 64 std::tr1::shared_ptr<std::istream> stream = fileSystem->Read(path); | 64 std::shared_ptr<std::istream> stream = fileSystem->Read(path); |
| 65 content = Utils::Slurp(*stream); | 65 content = Utils::Slurp(*stream); |
| 66 } | 66 } |
| 67 catch (std::exception& e) | 67 catch (std::exception& e) |
| 68 { | 68 { |
| 69 error = e.what(); | 69 error = e.what(); |
| 70 } | 70 } |
| 71 catch (...) | 71 catch (...) |
| 72 { | 72 { |
| 73 error = "Unknown error while reading from " + path; | 73 error = "Unknown error while reading from " + path; |
| 74 } | 74 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 94 const std::string& path, const std::string& content) | 94 const std::string& path, const std::string& content) |
| 95 : IoThread(jsEngine, callback), path(path), content(content) | 95 : IoThread(jsEngine, callback), path(path), content(content) |
| 96 { | 96 { |
| 97 } | 97 } |
| 98 | 98 |
| 99 void Run() | 99 void Run() |
| 100 { | 100 { |
| 101 std::string error; | 101 std::string error; |
| 102 try | 102 try |
| 103 { | 103 { |
| 104 std::tr1::shared_ptr<std::iostream> stream(new std::stringstream); | 104 std::shared_ptr<std::iostream> stream(new std::stringstream); |
| 105 *stream << content; | 105 *stream << content; |
| 106 fileSystem->Write(path, stream); | 106 fileSystem->Write(path, stream); |
| 107 } | 107 } |
| 108 catch (std::exception& e) | 108 catch (std::exception& e) |
| 109 { | 109 { |
| 110 error = e.what(); | 110 error = e.what(); |
| 111 } | 111 } |
| 112 catch (...) | 112 catch (...) |
| 113 { | 113 { |
| 114 error = "Unknown error while writing to " + path; | 114 error = "Unknown error while writing to " + path; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 JsValuePtr FileSystemJsObject::Setup(JsEnginePtr jsEngine, JsValuePtr obj) | 340 JsValuePtr FileSystemJsObject::Setup(JsEnginePtr jsEngine, JsValuePtr obj) |
| 341 { | 341 { |
| 342 obj->SetProperty("read", jsEngine->NewCallback(::ReadCallback)); | 342 obj->SetProperty("read", jsEngine->NewCallback(::ReadCallback)); |
| 343 obj->SetProperty("write", jsEngine->NewCallback(::WriteCallback)); | 343 obj->SetProperty("write", jsEngine->NewCallback(::WriteCallback)); |
| 344 obj->SetProperty("move", jsEngine->NewCallback(::MoveCallback)); | 344 obj->SetProperty("move", jsEngine->NewCallback(::MoveCallback)); |
| 345 obj->SetProperty("remove", jsEngine->NewCallback(::RemoveCallback)); | 345 obj->SetProperty("remove", jsEngine->NewCallback(::RemoveCallback)); |
| 346 obj->SetProperty("stat", jsEngine->NewCallback(::StatCallback)); | 346 obj->SetProperty("stat", jsEngine->NewCallback(::StatCallback)); |
| 347 obj->SetProperty("resolve", jsEngine->NewCallback(::ResolveCallback)); | 347 obj->SetProperty("resolve", jsEngine->NewCallback(::ResolveCallback)); |
| 348 return obj; | 348 return obj; |
| 349 } | 349 } |
| LEFT | RIGHT |