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: Created July 6, 2017, 9:19 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
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
76 Read(const std::string& path) const = 0; 78 Read(const std::string& path) const = 0;
sergei 2017/07/07 07:27:36 I think it should be one line
hub 2017/07/07 12:51:00 Acknowledged.
77 79
78 /** 80 /**
79 * Writes to a file. 81 * Writes to a file.
80 * @param path File path. 82 * @param path File path.
81 * @param data Input stream with the data to write. 83 * @param data Buffer with the data to write.
82 */ 84 */
83 virtual void Write(const std::string& path, 85 virtual void Write(const std::string& path,
84 std::istream& data) = 0; 86 const IOBuffer& data) = 0;
85 87
86 /** 88 /**
87 * Moves a file (i.e.\ renames it). 89 * Moves a file (i.e.\ renames it).
88 * @param fromPath Current path to the file. 90 * @param fromPath Current path to the file.
89 * @param toPath New path to the file. 91 * @param toPath New path to the file.
90 */ 92 */
91 virtual void Move(const std::string& fromPath, 93 virtual void Move(const std::string& fromPath,
92 const std::string& toPath) = 0; 94 const std::string& toPath) = 0;
93 95
94 /** 96 /**
(...skipping 17 matching lines...) Expand all
112 virtual std::string Resolve(const std::string& path) const = 0; 114 virtual std::string Resolve(const std::string& path) const = 0;
113 }; 115 };
114 116
115 /** 117 /**
116 * Shared smart pointer to a `FileSystem` instance. 118 * Shared smart pointer to a `FileSystem` instance.
117 */ 119 */
118 typedef std::shared_ptr<FileSystem> FileSystemPtr; 120 typedef std::shared_ptr<FileSystem> FileSystemPtr;
119 } 121 }
120 122
121 #endif 123 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld