| 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 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 std::string ErrnoNumberAsString(int err); | 53 std::string ErrnoNumberAsString(int err); |
| 54 | 54 |
| 55 // Strips duplicate slashes, and optionally removes all trailing slashes. | 55 // Strips duplicate slashes, and optionally removes all trailing slashes. |
| 56 // Does not compact /./ or /../. | 56 // Does not compact /./ or /../. |
| 57 std::string NormalizePath(const std::string& path, bool strip_trailing_slash); | 57 std::string NormalizePath(const std::string& path, bool strip_trailing_slash); |
| 58 | 58 |
| 59 // Returns true if the file exists for sure. Returns false if it doesn't exist, | 59 // Returns true if the file exists for sure. Returns false if it doesn't exist, |
| 60 // or an error occurs. | 60 // or an error occurs. |
| 61 bool FileExists(const char* path); | 61 bool FileExists(const char* path); |
| 62 | 62 |
| 63 // Returns true if |path| exists and is a symbolic link. |
| 64 bool IsSymlink(const char* path); |
| 65 |
| 63 // The last 6 chars of path must be XXXXXX. They will be randomly changed | 66 // The last 6 chars of path must be XXXXXX. They will be randomly changed |
| 64 // and a non-existent path will be returned. Intentionally makes a copy | 67 // and a non-existent path will be returned. Intentionally makes a copy |
| 65 // of the string passed in. | 68 // of the string passed in. |
| 66 // NEVER CALL THIS FUNCTION UNLESS YOU ARE SURE | 69 // NEVER CALL THIS FUNCTION UNLESS YOU ARE SURE |
| 67 // THAT YOUR PROCESS WILL BE THE ONLY THING WRITING FILES IN THIS DIRECTORY. | 70 // THAT YOUR PROCESS WILL BE THE ONLY THING WRITING FILES IN THIS DIRECTORY. |
| 68 std::string TempFilename(std::string path); | 71 std::string TempFilename(std::string path); |
| 69 | 72 |
| 70 // Calls mkstemp() with the template passed. Returns the filename in the | 73 // Calls mkstemp() with the template passed. Returns the filename in the |
| 71 // out param filename. If fd is non-NULL, the file fd returned by mkstemp | 74 // out param filename. If fd is non-NULL, the file fd returned by mkstemp |
| 72 // is not close()d and is returned in the out param 'fd'. However, if | 75 // is not close()d and is returned in the out param 'fd'. However, if |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 bool _success = (_x); \ | 385 bool _success = (_x); \ |
| 383 if (!_success) { \ | 386 if (!_success) { \ |
| 384 LOG(ERROR) << #_x " failed."; \ | 387 LOG(ERROR) << #_x " failed."; \ |
| 385 return; \ | 388 return; \ |
| 386 } \ | 389 } \ |
| 387 } while (0) | 390 } while (0) |
| 388 | 391 |
| 389 | 392 |
| 390 | 393 |
| 391 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ | 394 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ |
| OLD | NEW |