Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: include/AdblockPlus/DefaultFileSystem.h

Issue 29449592: Issue 5183 - Provide async interface for FileSystem (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Left Patch Set: Rebased. Corrected most of the review issues. Created July 4, 2017, 7:57 p.m.
Right Patch Set: Rebase on master. Last changes. Created July 7, 2017, 1:36 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | include/AdblockPlus/FileSystem.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 19 matching lines...) Expand all
30 { 30 {
31 /** 31 /**
32 * `FileSystem` implementation that interacts directly with the operating 32 * `FileSystem` implementation that interacts directly with the operating
33 * system's file system. 33 * system's file system.
34 * All paths are considered relative to the base path, or to the current 34 * All paths are considered relative to the base path, or to the current
35 * working directory if no base path is set (see `SetBasePath()`). 35 * working directory if no base path is set (see `SetBasePath()`).
36 */ 36 */
37 class DefaultFileSystemSync : public FileSystem 37 class DefaultFileSystemSync : public FileSystem
38 { 38 {
39 public: 39 public:
40 std::shared_ptr<std::istream> Read(const std::string& path) const; 40 IFileSystem::IOBuffer Read(const std::string& path) const;
41 void Write(const std::string& path, std::istream& data); 41 void Write(const std::string& path, const IFileSystem::IOBuffer& data);
42 void Move(const std::string& fromPath, const std::string& toPath); 42 void Move(const std::string& fromPath, const std::string& toPath);
43 void Remove(const std::string& path); 43 void Remove(const std::string& path);
44 IFileSystem::StatResult Stat(const std::string& path) const; 44 IFileSystem::StatResult Stat(const std::string& path) const;
45 std::string Resolve(const std::string& path) const; 45 std::string Resolve(const std::string& path) const;
46 46
47 /** 47 /**
48 * Sets the base path, all paths are considered relative to it. 48 * Sets the base path, all paths are considered relative to it.
49 * @param path Base path. 49 * @param path Base path.
50 */ 50 */
51 void SetBasePath(const std::string& path); 51 void SetBasePath(const std::string& path);
52 52
53 protected: 53 protected:
54 std::string basePath; 54 std::string basePath;
55 }; 55 };
56 56
57 class DefaultFileSystem : public IFileSystem 57 class DefaultFileSystem : public IFileSystem
58 { 58 {
59 public: 59 public:
60 explicit DefaultFileSystem(const FileSystemSyncPtr& syncImpl); 60 explicit DefaultFileSystem(const FileSystemSyncPtr& syncImpl);
61 void Read(const std::string& path, 61 void Read(const std::string& path,
62 const ReadCallback& callback) const; 62 const ReadCallback& callback) const;
63 void Write(const std::string& path, 63 void Write(const std::string& path,
64 const std::string& data, 64 const IOBuffer& data,
65 const Callback& callback); 65 const Callback& callback);
66 void Move(const std::string& fromPath, 66 void Move(const std::string& fromPath,
67 const std::string& toPath, 67 const std::string& toPath,
68 const Callback& callback); 68 const Callback& callback);
69 void Remove(const std::string& path, const Callback& callback); 69 void Remove(const std::string& path, const Callback& callback);
70 void Stat(const std::string& path, 70 void Stat(const std::string& path,
71 const StatCallback& callback) const; 71 const StatCallback& callback) const;
72 72
73 std::string Resolve(const std::string& path) const; 73 std::string Resolve(const std::string& path) const;
74 private: 74 private:
75 FileSystemSyncPtr syncImpl; 75 FileSystemSyncPtr syncImpl;
76 }; 76 };
77 } 77 }
78 78
79 #endif 79 #endif
LEFTRIGHT

Powered by Google App Engine
This is Rietveld