| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 <errno.h> | 8 #include <errno.h> |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 #include <glib.h> | 13 #include <glib.h> |
| 14 #include "update_engine/action.h" | 14 #include "update_engine/action.h" |
| 15 #include "update_engine/action_processor.h" | 15 #include "update_engine/action_processor.h" |
| 16 | 16 |
| 17 namespace chromeos_update_engine { | 17 namespace chromeos_update_engine { |
| 18 | 18 |
| 19 namespace utils { | 19 namespace utils { |
| 20 | 20 |
| 21 // Returns true if this is an official Chrome OS build, false |
| 22 // otherwise. Currently, this routine errs on the official build side |
| 23 // -- if it doesn't recognize the update track as non-official, it |
| 24 // assumes the build is official. |
| 25 bool IsOfficialBuild(); |
| 26 |
| 21 // Writes the data passed to path. The file at path will be overwritten if it | 27 // Writes the data passed to path. The file at path will be overwritten if it |
| 22 // exists. Returns true on success, false otherwise. | 28 // exists. Returns true on success, false otherwise. |
| 23 bool WriteFile(const char* path, const char* data, int data_len); | 29 bool WriteFile(const char* path, const char* data, int data_len); |
| 24 | 30 |
| 25 // Calls write() or pwrite() repeatedly until all count bytes at buf are | 31 // Calls write() or pwrite() repeatedly until all count bytes at buf are |
| 26 // written to fd or an error occurs. Returns true on success. | 32 // written to fd or an error occurs. Returns true on success. |
| 27 bool WriteAll(int fd, const void* buf, size_t count); | 33 bool WriteAll(int fd, const void* buf, size_t count); |
| 28 bool PWriteAll(int fd, const void* buf, size_t count, off_t offset); | 34 bool PWriteAll(int fd, const void* buf, size_t count, off_t offset); |
| 29 | 35 |
| 30 // Calls pread() repeatedly until count bytes are read, or EOF is reached. | 36 // Calls pread() repeatedly until count bytes are read, or EOF is reached. |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 bool _success = (_x); \ | 300 bool _success = (_x); \ |
| 295 if (!_success) { \ | 301 if (!_success) { \ |
| 296 LOG(ERROR) << #_x " failed."; \ | 302 LOG(ERROR) << #_x " failed."; \ |
| 297 return; \ | 303 return; \ |
| 298 } \ | 304 } \ |
| 299 } while (0) | 305 } while (0) |
| 300 | 306 |
| 301 | 307 |
| 302 | 308 |
| 303 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ | 309 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ |
| OLD | NEW |