| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "update_engine/utils.h" | 5 #include "update_engine/utils.h" |
| 6 | 6 |
| 7 #include <sys/mount.h> | 7 #include <sys/mount.h> |
| 8 #include <sys/resource.h> | 8 #include <sys/resource.h> |
| 9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
| 10 #include <sys/types.h> | 10 #include <sys/types.h> |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 } | 294 } |
| 295 } | 295 } |
| 296 return ret; | 296 return ret; |
| 297 } | 297 } |
| 298 | 298 |
| 299 bool FileExists(const char* path) { | 299 bool FileExists(const char* path) { |
| 300 struct stat stbuf; | 300 struct stat stbuf; |
| 301 return 0 == lstat(path, &stbuf); | 301 return 0 == lstat(path, &stbuf); |
| 302 } | 302 } |
| 303 | 303 |
| 304 bool IsSymlink(const char* path) { |
| 305 struct stat stbuf; |
| 306 return lstat(path, &stbuf) == 0 && S_ISLNK(stbuf.st_mode) != 0; |
| 307 } |
| 308 |
| 304 std::string TempFilename(string path) { | 309 std::string TempFilename(string path) { |
| 305 static const string suffix("XXXXXX"); | 310 static const string suffix("XXXXXX"); |
| 306 CHECK(StringHasSuffix(path, suffix)); | 311 CHECK(StringHasSuffix(path, suffix)); |
| 307 do { | 312 do { |
| 308 string new_suffix; | 313 string new_suffix; |
| 309 for (unsigned int i = 0; i < suffix.size(); i++) { | 314 for (unsigned int i = 0; i < suffix.size(); i++) { |
| 310 int r = rand() % (26 * 2 + 10); // [a-zA-Z0-9] | 315 int r = rand() % (26 * 2 + 10); // [a-zA-Z0-9] |
| 311 if (r < 26) | 316 if (r < 26) |
| 312 new_suffix.append(1, 'a' + r); | 317 new_suffix.append(1, 'a' + r); |
| 313 else if (r < (26 * 2)) | 318 else if (r < (26 * 2)) |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 int min = value - range / 2; | 517 int min = value - range / 2; |
| 513 int max = value + range - range / 2; | 518 int max = value + range - range / 2; |
| 514 return base::RandInt(min, max); | 519 return base::RandInt(min, max); |
| 515 } | 520 } |
| 516 | 521 |
| 517 const char* const kStatefulPartition = "/mnt/stateful_partition"; | 522 const char* const kStatefulPartition = "/mnt/stateful_partition"; |
| 518 | 523 |
| 519 } // namespace utils | 524 } // namespace utils |
| 520 | 525 |
| 521 } // namespace chromeos_update_engine | 526 } // namespace chromeos_update_engine |
| OLD | NEW |