| 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 | 
| 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
| 34   { | 34   { | 
| 35   public: | 35   public: | 
| 36     /** | 36     /** | 
| 37      * Result of a stat operation, i.e.\ information about a file. | 37      * Result of a stat operation, i.e.\ information about a file. | 
| 38      */ | 38      */ | 
| 39     struct StatResult | 39     struct StatResult | 
| 40     { | 40     { | 
| 41       StatResult() | 41       StatResult() | 
| 42       { | 42       { | 
| 43         exists = false; | 43         exists = false; | 
| 44         isDirectory = false; |  | 
| 45         isFile = false; |  | 
| 46         lastModified = 0; | 44         lastModified = 0; | 
| 47       } | 45       } | 
| 48 | 46 | 
| 49       /** | 47       /** | 
| 50        * File exists. | 48        * File exists. | 
| 51        */ | 49        */ | 
| 52       bool exists; | 50       bool exists; | 
| 53 | 51 | 
| 54       /** | 52       /** | 
| 55        * File is a directory. |  | 
| 56        */ |  | 
| 57       bool isDirectory; |  | 
| 58 |  | 
| 59       /** |  | 
| 60        * File is a regular file. |  | 
| 61        */ |  | 
| 62       bool isFile; |  | 
| 63 |  | 
| 64       /** |  | 
| 65        * POSIX time of the last modification. | 53        * POSIX time of the last modification. | 
| 66        */ | 54        */ | 
| 67       int64_t lastModified; | 55       int64_t lastModified; | 
| 68     }; | 56     }; | 
| 69 | 57 | 
| 70     virtual ~IFileSystem() {} | 58     virtual ~IFileSystem() {} | 
| 71 | 59 | 
| 72     /** Type for the buffer used for IO */ | 60     /** Type for the buffer used for IO */ | 
| 73     typedef std::vector<uint8_t> IOBuffer; | 61     typedef std::vector<uint8_t> IOBuffer; | 
| 74 | 62 | 
| 75     /** | 63     /** | 
| 76      * Default callback type for asynchronous filesystem calls. | 64      * Default callback type for asynchronous filesystem calls. | 
| 77      * @param An error string. Empty is success. | 65      * @param An error string. Empty is success. | 
| 78      */ | 66      */ | 
| 79     typedef std::function<void(const std::string&)> Callback; | 67     typedef std::function<void(const std::string&)> Callback; | 
| 80 | 68 | 
| 81     /** | 69     /** | 
| 82      * Callback type for the asynchronous Read call. | 70      * Callback type for the asynchronous Read call. | 
| 83      * @param Output char array with file content. | 71      * @param Output char array with file content. | 
| 84      * @param An error string. Empty if success. | 72      * @param An error string. Empty if success. | 
| 85      */ | 73      */ | 
| 86     typedef std::function<void(IOBuffer&&, | 74     typedef std::function<void(IOBuffer&&, | 
| 87                                const std::string&)> ReadCallback; | 75                                const std::string&)> ReadCallback; | 
| 88 | 76 | 
| 89     /** | 77     /** | 
| 90      * Reads from a file. | 78      * Reads from a file. | 
| 91      * @param path File path. | 79      * @param fileName File name. | 
| 92      * @param callback The function called on completion with the input data. | 80      * @param callback The function called on completion with the input data. | 
| 93      */ | 81      */ | 
| 94     virtual void Read(const std::string& path, | 82     virtual void Read(const std::string& fileName, | 
| 95                       const ReadCallback& callback) const = 0; | 83                       const ReadCallback& callback) const = 0; | 
| 96 | 84 | 
| 97     /** | 85     /** | 
| 98      * Writes to a file. | 86      * Writes to a file. | 
| 99      * @param path File path. | 87      * @param fileName File name. | 
| 100      * @param data The data to write. | 88      * @param data The data to write. | 
| 101      * @param callback The function called on completion. | 89      * @param callback The function called on completion. | 
| 102      */ | 90      */ | 
| 103     virtual void Write(const std::string& path, | 91     virtual void Write(const std::string& fileName, | 
| 104                        const IOBuffer& data, | 92                        const IOBuffer& data, | 
| 105                        const Callback& callback) = 0; | 93                        const Callback& callback) = 0; | 
| 106 | 94 | 
| 107     /** | 95     /** | 
| 108      * Moves a file (i.e.\ renames it). | 96      * Moves a file (i.e.\ renames it). | 
| 109      * @param fromPath Current path to the file. | 97      * @param fromFileName Current file name. | 
| 110      * @param toPath New path to the file. | 98      * @param toFileName New file name. | 
| 111      * @param callback The function called on completion. | 99      * @param callback The function called on completion. | 
| 112      */ | 100      */ | 
| 113     virtual void Move(const std::string& fromPath, const std::string& toPath, | 101     virtual void Move(const std::string& fromFileName, const std::string& toFile
     Name, | 
| 114                       const Callback& callback) = 0; | 102                       const Callback& callback) = 0; | 
| 115 | 103 | 
| 116     /** | 104     /** | 
| 117      * Removes a file. | 105      * Removes a file. | 
| 118      * @param path File path. | 106      * @param fileName File name. | 
| 119      * @param callback The function called on completion. | 107      * @param callback The function called on completion. | 
| 120      */ | 108      */ | 
| 121     virtual void Remove(const std::string& path, const Callback& callback) = 0; | 109     virtual void Remove(const std::string& fileName, const Callback& callback) =
      0; | 
| 122 | 110 | 
| 123     /** | 111     /** | 
| 124      * Callback type for the asynchronous Stat call. | 112      * Callback type for the asynchronous Stat call. | 
| 125      * @param the StatResult data. | 113      * @param the StatResult data. | 
| 126      * @param an error string. Empty if no error. | 114      * @param an error string. Empty if no error. | 
| 127      */ | 115      */ | 
| 128     typedef std::function<void(const StatResult&, const std::string&)> StatCallb
     ack; | 116     typedef std::function<void(const StatResult&, const std::string&)> StatCallb
     ack; | 
| 129 | 117 | 
| 130     /** | 118     /** | 
| 131      * Retrieves information about a file. | 119      * Retrieves information about a file. | 
| 132      * @param path File path. | 120      * @param fileName File name. | 
| 133      * @param callback The function called on completion. | 121      * @param callback The function called on completion. | 
| 134      */ | 122      */ | 
| 135     virtual void Stat(const std::string& path, | 123     virtual void Stat(const std::string& fileName, | 
| 136                       const StatCallback& callback) const = 0; | 124                       const StatCallback& callback) const = 0; | 
| 137 |  | 
| 138     /** |  | 
| 139      * Returns the absolute path to a file. |  | 
| 140      * @param path File path (can be relative or absolute). |  | 
| 141      * @return Absolute file path. |  | 
| 142      */ |  | 
| 143     virtual std::string Resolve(const std::string& path) const = 0; |  | 
| 144   }; | 125   }; | 
| 145 | 126 | 
| 146   /** | 127   /** | 
| 147    * Shared smart pointer to a `IFileSystem` instance. | 128    * Shared smart pointer to a `IFileSystem` instance. | 
| 148    */ | 129    */ | 
| 149   typedef std::shared_ptr<IFileSystem> FileSystemPtr; | 130   typedef std::shared_ptr<IFileSystem> FileSystemPtr; | 
| 150 } | 131 } | 
| 151 | 132 | 
| 152 #endif | 133 #endif | 
| OLD | NEW | 
|---|