| Index: include/AdblockPlus/FileSystem.h |
| =================================================================== |
| --- a/include/AdblockPlus/FileSystem.h |
| +++ b/include/AdblockPlus/FileSystem.h |
| @@ -18,75 +18,43 @@ |
| #ifndef ADBLOCK_PLUS_FILE_SYSTEM_H |
| #define ADBLOCK_PLUS_FILE_SYSTEM_H |
| #include <istream> |
| #include <stdint.h> |
| #include <string> |
| #include <memory> |
| +#include "IFileSystem.h" |
| + |
| namespace AdblockPlus |
| { |
| /** |
| * File system interface. |
| */ |
| class FileSystem |
| { |
| public: |
| - /** |
| - * Result of a stat operation, i.e.\ information about a file. |
| - */ |
| - struct StatResult |
| - { |
| - StatResult() |
| - { |
| - exists = false; |
| - isDirectory = false; |
| - isFile = false; |
| - lastModified = 0; |
| - } |
| - |
| - /** |
| - * File exists. |
| - */ |
| - bool exists; |
| - |
| - /** |
| - * File is a directory. |
| - */ |
| - bool isDirectory; |
| - |
| - /** |
| - * File is a regular file. |
| - */ |
| - bool isFile; |
| - |
| - /** |
| - * POSIX time of the last modification. |
| - */ |
| - int64_t lastModified; |
| - }; |
| - |
| virtual ~FileSystem() {} |
| /** |
| * Reads from a file. |
| * @param path File path. |
| * @return Input stream with the file's contents. |
| */ |
| virtual std::shared_ptr<std::istream> |
| Read(const std::string& path) const = 0; |
| /** |
| * Writes to a file. |
| * @param path File path. |
| - * @param data Input stream with the data to write. |
| + * @param data Output stream with the data to write. |
| */ |
| virtual void Write(const std::string& path, |
| - std::istream& data) = 0; |
| + std::ostream& data) = 0; |
|
sergei
2017/07/06 14:14:04
What do you think about making it in a separate co
hub
2017/07/06 14:33:31
This is needed because we write to that stream buf
sergei
2017/07/06 14:53:33
I see, but if we changed either std::istream or st
hub
2017/07/06 21:24:29
See https://codereview.adblockplus.org/29481704
|
| /** |
| * Moves a file (i.e.\ renames it). |
| * @param fromPath Current path to the file. |
| * @param toPath New path to the file. |
| */ |
| virtual void Move(const std::string& fromPath, |
| const std::string& toPath) = 0; |
| @@ -97,25 +65,25 @@ |
| */ |
| virtual void Remove(const std::string& path) = 0; |
| /** |
| * Retrieves information about a file. |
| * @param path File path. |
| * @return File information. |
| */ |
| - virtual StatResult Stat(const std::string& path) const = 0; |
| + virtual IFileSystem::StatResult Stat(const std::string& path) const = 0; |
| /** |
| * Returns the absolute path to a file. |
| * @param path File path (can be relative or absolute). |
| * @return Absolute file path. |
| */ |
| virtual std::string Resolve(const std::string& path) const = 0; |
| }; |
| /** |
| * Shared smart pointer to a `FileSystem` instance. |
| */ |
| - typedef std::shared_ptr<FileSystem> FileSystemPtr; |
| + typedef std::shared_ptr<FileSystem> FileSystemSyncPtr; |
| } |
| #endif |