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

Side by Side Diff: include/AdblockPlus/FileSystem.h

Issue 29481704: Noissue - Use buffer for FileSystem IO (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Nit addressed Created July 7, 2017, 12:50 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/DefaultFileSystem.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-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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 * File is a regular file. 58 * File is a regular file.
59 */ 59 */
60 bool isFile; 60 bool isFile;
61 61
62 /** 62 /**
63 * POSIX time of the last modification. 63 * POSIX time of the last modification.
64 */ 64 */
65 int64_t lastModified; 65 int64_t lastModified;
66 }; 66 };
67 67
68 typedef std::vector<uint8_t> IOBuffer;
69
68 virtual ~FileSystem() {} 70 virtual ~FileSystem() {}
69 71
70 /** 72 /**
71 * Reads from a file. 73 * Reads from a file.
72 * @param path File path. 74 * @param path File path.
73 * @return Input stream with the file's contents. 75 * @return Buffer with the file content.
74 */ 76 */
75 virtual std::shared_ptr<std::istream> 77 virtual IOBuffer Read(const std::string& path) const = 0;
76 Read(const std::string& path) const = 0;
77 78
78 /** 79 /**
79 * Writes to a file. 80 * Writes to a file.
80 * @param path File path. 81 * @param path File path.
81 * @param data Input stream with the data to write. 82 * @param data Buffer with the data to write.
82 */ 83 */
83 virtual void Write(const std::string& path, 84 virtual void Write(const std::string& path,
84 std::istream& data) = 0; 85 const IOBuffer& data) = 0;
85 86
86 /** 87 /**
87 * Moves a file (i.e.\ renames it). 88 * Moves a file (i.e.\ renames it).
88 * @param fromPath Current path to the file. 89 * @param fromPath Current path to the file.
89 * @param toPath New path to the file. 90 * @param toPath New path to the file.
90 */ 91 */
91 virtual void Move(const std::string& fromPath, 92 virtual void Move(const std::string& fromPath,
92 const std::string& toPath) = 0; 93 const std::string& toPath) = 0;
93 94
94 /** 95 /**
(...skipping 17 matching lines...) Expand all
112 virtual std::string Resolve(const std::string& path) const = 0; 113 virtual std::string Resolve(const std::string& path) const = 0;
113 }; 114 };
114 115
115 /** 116 /**
116 * Shared smart pointer to a `FileSystem` instance. 117 * Shared smart pointer to a `FileSystem` instance.
117 */ 118 */
118 typedef std::shared_ptr<FileSystem> FileSystemPtr; 119 typedef std::shared_ptr<FileSystem> FileSystemPtr;
119 } 120 }
120 121
121 #endif 122 #endif
OLDNEW
« no previous file with comments | « include/AdblockPlus/DefaultFileSystem.h ('k') | src/DefaultFileSystem.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld