| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | |
| 3 * Copyright (C) 2006-2017 eyeo GmbH | |
| 4 * | |
| 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 | |
| 7 * published by the Free Software Foundation. | |
| 8 * | |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 * GNU General Public License for more details. | |
| 13 * | |
| 14 * You should have received a copy of the GNU General Public License | |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | |
| 16 */ | |
| 17 | |
| 18 #ifndef ADBLOCK_PLUS_FILE_SYSTEM_H | |
| 19 #define ADBLOCK_PLUS_FILE_SYSTEM_H | |
| 20 | |
| 21 #include <istream> | |
| 22 #include <stdint.h> | |
| 23 #include <string> | |
| 24 #include <memory> | |
| 25 | |
| 26 #include "IFileSystem.h" | |
| 27 | |
| 28 namespace AdblockPlus | |
| 29 { | |
| 30 /** | |
| 31 * File system interface. | |
| 32 */ | |
| 33 class FileSystem | |
| 34 { | |
| 35 public: | |
| 36 virtual ~FileSystem() {} | |
| 37 | |
| 38 /** | |
| 39 * Reads from a file. | |
| 40 * @param path File path. | |
| 41 * @return Buffer with the file content. | |
| 42 */ | |
| 43 virtual IFileSystem::IOBuffer Read(const std::string& path) const = 0; | |
| 44 | |
| 45 /** | |
| 46 * Writes to a file. | |
| 47 * @param path File path. | |
| 48 * @param data Buffer with the data to write. | |
| 49 */ | |
| 50 virtual void Write(const std::string& path, | |
| 51 const IFileSystem::IOBuffer& data) = 0; | |
| 52 | |
| 53 /** | |
| 54 * Moves a file (i.e.\ renames it). | |
| 55 * @param fromPath Current path to the file. | |
| 56 * @param toPath New path to the file. | |
| 57 */ | |
| 58 virtual void Move(const std::string& fromPath, | |
| 59 const std::string& toPath) = 0; | |
| 60 | |
| 61 /** | |
| 62 * Removes a file. | |
| 63 * @param path File path. | |
| 64 */ | |
| 65 virtual void Remove(const std::string& path) = 0; | |
| 66 | |
| 67 /** | |
| 68 * Retrieves information about a file. | |
| 69 * @param path File path. | |
| 70 * @return File information. | |
| 71 */ | |
| 72 virtual IFileSystem::StatResult Stat(const std::string& path) const = 0; | |
| 73 | |
| 74 /** | |
| 75 * Returns the absolute path to a file. | |
| 76 * @param path File path (can be relative or absolute). | |
| 77 * @return Absolute file path. | |
| 78 */ | |
| 79 virtual std::string Resolve(const std::string& path) const = 0; | |
| 80 }; | |
| 81 | |
| 82 /** | |
| 83 * Shared smart pointer to a `FileSystem` instance. | |
| 84 */ | |
| 85 typedef std::shared_ptr<FileSystem> FileSystemSyncPtr; | |
| 86 } | |
| 87 | |
| 88 #endif | |
| OLD | NEW |