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

Side by Side Diff: src/DefaultFileSystem.cpp

Issue 10805001: Fixed: FileSystem;:Write should take an istream instance for input, not ostream (Closed)
Patch Set: Created May 24, 2013, 9:35 a.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/FileSystem.h ('k') | src/FileSystemJsObject.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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 #endif 66 #endif
67 } 67 }
68 68
69 std::tr1::shared_ptr<std::istream> 69 std::tr1::shared_ptr<std::istream>
70 DefaultFileSystem::Read(const std::string& path) const 70 DefaultFileSystem::Read(const std::string& path) const
71 { 71 {
72 return std::tr1::shared_ptr<std::istream>(new std::ifstream(NormalizePath(path ).c_str())); 72 return std::tr1::shared_ptr<std::istream>(new std::ifstream(NormalizePath(path ).c_str()));
73 } 73 }
74 74
75 void DefaultFileSystem::Write(const std::string& path, 75 void DefaultFileSystem::Write(const std::string& path,
76 std::tr1::shared_ptr<std::ostream> data) 76 std::tr1::shared_ptr<std::istream> data)
77 { 77 {
78 std::ofstream file(NormalizePath(path).c_str()); 78 std::ofstream file(NormalizePath(path).c_str());
79 file << Utils::Slurp(*data); 79 file << Utils::Slurp(*data);
80 } 80 }
81 81
82 void DefaultFileSystem::Move(const std::string& fromPath, 82 void DefaultFileSystem::Move(const std::string& fromPath,
83 const std::string& toPath) 83 const std::string& toPath)
84 { 84 {
85 if (rename(NormalizePath(fromPath).c_str(), NormalizePath(toPath).c_str())) 85 if (rename(NormalizePath(fromPath).c_str(), NormalizePath(toPath).c_str()))
86 throw RuntimeErrorWithErrno("Failed to move " + fromPath + " to " + toPath); 86 throw RuntimeErrorWithErrno("Failed to move " + fromPath + " to " + toPath);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 void DefaultFileSystem::SetBasePath(const std::string& path) 184 void DefaultFileSystem::SetBasePath(const std::string& path)
185 { 185 {
186 basePath = path; 186 basePath = path;
187 187
188 if (*basePath.rbegin() == PATH_SEPARATOR) 188 if (*basePath.rbegin() == PATH_SEPARATOR)
189 { 189 {
190 basePath.resize(basePath.size() - 1); 190 basePath.resize(basePath.size() - 1);
191 } 191 }
192 } 192 }
193 193
OLDNEW
« no previous file with comments | « include/AdblockPlus/FileSystem.h ('k') | src/FileSystemJsObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld