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

Side by Side Diff: src/DefaultFileSystem.cpp

Issue 29409580: Issue 5013 - Make parameter const ref when applicable. (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Created April 11, 2017, 1:58 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 std::shared_ptr<std::istream> 69 std::shared_ptr<std::istream>
70 DefaultFileSystem::Read(const std::string& path) const 70 DefaultFileSystem::Read(const std::string& path) const
71 { 71 {
72 std::shared_ptr<std::istream> result(new std::ifstream(NormalizePath(path).c_s tr())); 72 std::shared_ptr<std::istream> result(new std::ifstream(NormalizePath(path).c_s tr()));
73 if (result->fail()) 73 if (result->fail())
74 throw RuntimeErrorWithErrno("Failed to open " + path); 74 throw RuntimeErrorWithErrno("Failed to open " + path);
75 return result; 75 return result;
76 } 76 }
77 77
78 void DefaultFileSystem::Write(const std::string& path, 78 void DefaultFileSystem::Write(const std::string& path,
79 std::shared_ptr<std::istream> data) 79 const std::shared_ptr<std::istream>& data)
80 { 80 {
81 std::ofstream file(NormalizePath(path).c_str(), std::ios_base::out | std::ios_ base::binary); 81 std::ofstream file(NormalizePath(path).c_str(), std::ios_base::out | std::ios_ base::binary);
82 file << Utils::Slurp(*data); 82 file << Utils::Slurp(*data);
83 } 83 }
84 84
85 void DefaultFileSystem::Move(const std::string& fromPath, 85 void DefaultFileSystem::Move(const std::string& fromPath,
86 const std::string& toPath) 86 const std::string& toPath)
87 { 87 {
88 if (rename(NormalizePath(fromPath).c_str(), NormalizePath(toPath).c_str())) 88 if (rename(NormalizePath(fromPath).c_str(), NormalizePath(toPath).c_str()))
89 throw RuntimeErrorWithErrno("Failed to move " + fromPath + " to " + toPath); 89 throw RuntimeErrorWithErrno("Failed to move " + fromPath + " to " + toPath);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 void DefaultFileSystem::SetBasePath(const std::string& path) 187 void DefaultFileSystem::SetBasePath(const std::string& path)
188 { 188 {
189 basePath = path; 189 basePath = path;
190 190
191 if (*basePath.rbegin() == PATH_SEPARATOR) 191 if (*basePath.rbegin() == PATH_SEPARATOR)
192 { 192 {
193 basePath.resize(basePath.size() - 1); 193 basePath.resize(basePath.size() - 1);
194 } 194 }
195 } 195 }
196 196
OLDNEW

Powered by Google App Engine
This is Rietveld