| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ | 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ |
| 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ | 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 #include "update_engine/action.h" | 11 #include "update_engine/action.h" |
| 12 #include "update_engine/action_processor.h" | 12 #include "update_engine/action_processor.h" |
| 13 | 13 |
| 14 namespace chromeos_update_engine { | 14 namespace chromeos_update_engine { |
| 15 | 15 |
| 16 namespace utils { | 16 namespace utils { |
| 17 | 17 |
| 18 // Writes the data passed to path. The file at path will be overwritten if it |
| 19 // exists. Returns true on success, false otherwise. |
| 20 bool WriteFile(const char* path, const char* data, int data_len); |
| 21 |
| 18 // Returns the entire contents of the file at path. Returns true on success. | 22 // Returns the entire contents of the file at path. Returns true on success. |
| 19 bool ReadFile(const std::string& path, std::vector<char>* out); | 23 bool ReadFile(const std::string& path, std::vector<char>* out); |
| 20 bool ReadFileToString(const std::string& path, std::string* out); | 24 bool ReadFileToString(const std::string& path, std::string* out); |
| 21 | 25 |
| 22 std::string ErrnoNumberAsString(int err); | 26 std::string ErrnoNumberAsString(int err); |
| 23 | 27 |
| 24 // Strips duplicate slashes, and optionally removes all trailing slashes. | 28 // Strips duplicate slashes, and optionally removes all trailing slashes. |
| 25 // Does not compact /./ or /../. | 29 // Does not compact /./ or /../. |
| 26 std::string NormalizePath(const std::string& path, bool strip_trailing_slash); | 30 std::string NormalizePath(const std::string& path, bool strip_trailing_slash); |
| 27 | 31 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 bool _success = (_x); \ | 179 bool _success = (_x); \ |
| 176 if (!_success) { \ | 180 if (!_success) { \ |
| 177 LOG(ERROR) << #_x " failed."; \ | 181 LOG(ERROR) << #_x " failed."; \ |
| 178 return; \ | 182 return; \ |
| 179 } \ | 183 } \ |
| 180 } while (0) | 184 } while (0) |
| 181 | 185 |
| 182 | 186 |
| 183 | 187 |
| 184 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ | 188 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ |
| OLD | NEW |