Peter Qiu | 7751730 | 2015-01-08 16:22:16 -0800 | [diff] [blame^] | 1 | // Copyright 2015 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "apmanager/file_writer.h" |
| 6 | |
| 7 | #include <base/files/file_util.h> |
| 8 | |
| 9 | namespace apmanager { |
| 10 | |
| 11 | namespace { |
| 12 | |
| 13 | base::LazyInstance<FileWriter> g_file_writer |
| 14 | = LAZY_INSTANCE_INITIALIZER; |
| 15 | |
| 16 | } // namespace |
| 17 | |
| 18 | FileWriter::FileWriter() {} |
| 19 | FileWriter::~FileWriter() {} |
| 20 | |
| 21 | FileWriter* FileWriter::GetInstance() { |
| 22 | return g_file_writer.Pointer(); |
| 23 | } |
| 24 | |
| 25 | bool FileWriter::Write(const std::string& file_name, |
| 26 | const std::string& content) { |
| 27 | if (base::WriteFile(base::FilePath(file_name), |
| 28 | content.c_str(), |
| 29 | content.size()) == -1) { |
| 30 | return false; |
| 31 | } |
| 32 | return true; |
| 33 | } |
| 34 | |
| 35 | } // namespace apmanager |