OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "chrome/test/chromedriver/util.h" | 5 #include "chrome/test/chromedriver/util.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file_enumerator.h" |
9 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
10 #include "base/format_macros.h" | 11 #include "base/format_macros.h" |
11 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
12 #include "base/string16.h" | 13 #include "base/string16.h" |
13 #include "base/string_util.h" | 14 #include "base/string_util.h" |
14 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
15 #include "base/third_party/icu/icu_utf.h" | 16 #include "base/third_party/icu/icu_utf.h" |
16 #include "base/values.h" | 17 #include "base/values.h" |
17 #include "chrome/test/chromedriver/chrome/status.h" | 18 #include "chrome/test/chromedriver/chrome/status.h" |
18 #include "chrome/test/chromedriver/chrome/ui_events.h" | 19 #include "chrome/test/chromedriver/chrome/ui_events.h" |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 Status status = UnzipArchive(unzip_dir, bytes); | 377 Status status = UnzipArchive(unzip_dir, bytes); |
377 if (status.IsError()) { | 378 if (status.IsError()) { |
378 Status entry_status = UnzipEntry(unzip_dir, bytes); | 379 Status entry_status = UnzipEntry(unzip_dir, bytes); |
379 if (entry_status.IsError()) { | 380 if (entry_status.IsError()) { |
380 return Status(kUnknownError, base::StringPrintf( | 381 return Status(kUnknownError, base::StringPrintf( |
381 "archive error: (%s), entry error: (%s)", | 382 "archive error: (%s), entry error: (%s)", |
382 status.message().c_str(), entry_status.message().c_str())); | 383 status.message().c_str(), entry_status.message().c_str())); |
383 } | 384 } |
384 } | 385 } |
385 | 386 |
386 file_util::FileEnumerator enumerator(unzip_dir, false /* recursive */, | 387 base::FileEnumerator enumerator(unzip_dir, false /* recursive */, |
387 file_util::FileEnumerator::FILES | | 388 base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); |
388 file_util::FileEnumerator::DIRECTORIES); | |
389 base::FilePath first_file = enumerator.Next(); | 389 base::FilePath first_file = enumerator.Next(); |
390 if (first_file.empty()) | 390 if (first_file.empty()) |
391 return Status(kUnknownError, "contained 0 files"); | 391 return Status(kUnknownError, "contained 0 files"); |
392 | 392 |
393 base::FilePath second_file = enumerator.Next(); | 393 base::FilePath second_file = enumerator.Next(); |
394 if (!second_file.empty()) | 394 if (!second_file.empty()) |
395 return Status(kUnknownError, "contained multiple files"); | 395 return Status(kUnknownError, "contained multiple files"); |
396 | 396 |
397 *file = first_file; | 397 *file = first_file; |
398 return Status(kOk); | 398 return Status(kOk); |
399 } | 399 } |
OLD | NEW |