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

Side by Side Diff: src/DefaultFileSystem.h

Issue 29533641: Issue 5569 - add the possibility to use synchronous WebRequest and base path in File System (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created Sept. 1, 2017, 3:32 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/AdblockPlus/Platform.h ('k') | src/DefaultFileSystem.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 20 matching lines...) Expand all
31 { 31 {
32 /** 32 /**
33 * File system implementation that interacts directly with the operating 33 * File system implementation that interacts directly with the operating
34 * system's file system. 34 * system's file system.
35 * All paths are considered relative to the base path, or to the current 35 * All paths are considered relative to the base path, or to the current
36 * working directory if no base path is set (see `SetBasePath()`). 36 * working directory if no base path is set (see `SetBasePath()`).
37 */ 37 */
38 class DefaultFileSystemSync 38 class DefaultFileSystemSync
39 { 39 {
40 public: 40 public:
41 explicit DefaultFileSystemSync(const std::string& basePath);
41 IFileSystem::IOBuffer Read(const std::string& path) const; 42 IFileSystem::IOBuffer Read(const std::string& path) const;
42 void Write(const std::string& path, const IFileSystem::IOBuffer& data); 43 void Write(const std::string& path, const IFileSystem::IOBuffer& data);
43 void Move(const std::string& fromPath, const std::string& toPath); 44 void Move(const std::string& fromPath, const std::string& toPath);
44 void Remove(const std::string& path); 45 void Remove(const std::string& path);
45 IFileSystem::StatResult Stat(const std::string& path) const; 46 IFileSystem::StatResult Stat(const std::string& path) const;
46 std::string Resolve(const std::string& fileName) const; 47 std::string Resolve(const std::string& fileName) const;
47
48 /**
49 * Sets the base path, all paths are considered relative to it.
50 * @param path Base path.
51 */
52 void SetBasePath(const std::string& path);
53
54 protected: 48 protected:
55 std::string basePath; 49 std::string basePath;
56 }; 50 };
57 51
58 class DefaultFileSystem : public IFileSystem 52 class DefaultFileSystem : public IFileSystem
59 { 53 {
60 public: 54 public:
61 explicit DefaultFileSystem(const Scheduler& scheduler, std::unique_ptr<Defau ltFileSystemSync> syncImpl); 55 explicit DefaultFileSystem(const Scheduler& scheduler, std::unique_ptr<Defau ltFileSystemSync> syncImpl);
62 void Read(const std::string& fileName, 56 void Read(const std::string& fileName,
63 const ReadCallback& callback) const override; 57 const ReadCallback& callback) const override;
64 void Write(const std::string& fileName, 58 void Write(const std::string& fileName,
65 const IOBuffer& data, 59 const IOBuffer& data,
66 const Callback& callback) override; 60 const Callback& callback) override;
67 void Move(const std::string& fromFileName, 61 void Move(const std::string& fromFileName,
68 const std::string& toFileName, 62 const std::string& toFileName,
69 const Callback& callback) override; 63 const Callback& callback) override;
70 void Remove(const std::string& fileName, const Callback& callback) override; 64 void Remove(const std::string& fileName, const Callback& callback) override;
71 void Stat(const std::string& fileName, 65 void Stat(const std::string& fileName,
72 const StatCallback& callback) const override; 66 const StatCallback& callback) const override;
73 67
74 private: 68 private:
75 // Returns the absolute path to a file. 69 // Returns the absolute path to a file.
76 std::string Resolve(const std::string& fileName) const; 70 std::string Resolve(const std::string& fileName) const;
77 Scheduler scheduler; 71 Scheduler scheduler;
78 std::unique_ptr<DefaultFileSystemSync> syncImpl; 72 std::unique_ptr<DefaultFileSystemSync> syncImpl;
79 }; 73 };
80 } 74 }
81 75
82 #endif 76 #endif
OLDNEW
« no previous file with comments | « include/AdblockPlus/Platform.h ('k') | src/DefaultFileSystem.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld