| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/media_galleries/fileapi/native_media_file_util.h" | 5 #include "chrome/browser/media_galleries/fileapi/native_media_file_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 base::PlatformFileInfo* file_info, | 487 base::PlatformFileInfo* file_info, |
| 488 base::FilePath* platform_path) { | 488 base::FilePath* platform_path) { |
| 489 DCHECK(context); | 489 DCHECK(context); |
| 490 DCHECK(IsOnTaskRunnerThread(context)); | 490 DCHECK(IsOnTaskRunnerThread(context)); |
| 491 DCHECK(file_info); | 491 DCHECK(file_info); |
| 492 | 492 |
| 493 base::FilePath file_path; | 493 base::FilePath file_path; |
| 494 base::PlatformFileError error = GetLocalFilePath(context, url, &file_path); | 494 base::PlatformFileError error = GetLocalFilePath(context, url, &file_path); |
| 495 if (error != base::PLATFORM_FILE_OK) | 495 if (error != base::PLATFORM_FILE_OK) |
| 496 return error; | 496 return error; |
| 497 if (file_util::IsLink(file_path)) | 497 if (base::IsLink(file_path)) |
| 498 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 498 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 499 error = fileapi::NativeFileUtil::GetFileInfo(file_path, file_info); | 499 error = fileapi::NativeFileUtil::GetFileInfo(file_path, file_info); |
| 500 if (error != base::PLATFORM_FILE_OK) | 500 if (error != base::PLATFORM_FILE_OK) |
| 501 return error; | 501 return error; |
| 502 | 502 |
| 503 if (platform_path) | 503 if (platform_path) |
| 504 *platform_path = file_path; | 504 *platform_path = file_path; |
| 505 if (file_info->is_directory || | 505 if (file_info->is_directory || |
| 506 media_path_filter_->Match(file_path)) { | 506 media_path_filter_->Match(file_path)) { |
| 507 return base::PLATFORM_FILE_OK; | 507 return base::PLATFORM_FILE_OK; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY; | 542 return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY; |
| 543 | 543 |
| 544 base::FileEnumerator file_enum( | 544 base::FileEnumerator file_enum( |
| 545 dir_path, | 545 dir_path, |
| 546 false /* recursive */, | 546 false /* recursive */, |
| 547 base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); | 547 base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); |
| 548 for (base::FilePath enum_path = file_enum.Next(); | 548 for (base::FilePath enum_path = file_enum.Next(); |
| 549 !enum_path.empty(); | 549 !enum_path.empty(); |
| 550 enum_path = file_enum.Next()) { | 550 enum_path = file_enum.Next()) { |
| 551 // Skip symlinks. | 551 // Skip symlinks. |
| 552 if (file_util::IsLink(enum_path)) | 552 if (base::IsLink(enum_path)) |
| 553 continue; | 553 continue; |
| 554 | 554 |
| 555 base::FileEnumerator::FileInfo info = file_enum.GetInfo(); | 555 base::FileEnumerator::FileInfo info = file_enum.GetInfo(); |
| 556 | 556 |
| 557 // NativeMediaFileUtil skip criteria. | 557 // NativeMediaFileUtil skip criteria. |
| 558 if (ShouldSkip(enum_path)) | 558 if (ShouldSkip(enum_path)) |
| 559 continue; | 559 continue; |
| 560 if (!info.IsDirectory() && !media_path_filter_->Match(enum_path)) | 560 if (!info.IsDirectory() && !media_path_filter_->Match(enum_path)) |
| 561 continue; | 561 continue; |
| 562 | 562 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 DCHECK(IsOnTaskRunnerThread(context)); | 644 DCHECK(IsOnTaskRunnerThread(context)); |
| 645 base::FilePath file_path; | 645 base::FilePath file_path; |
| 646 base::PlatformFileError error = | 646 base::PlatformFileError error = |
| 647 GetLocalFilePath(context, file_system_url, &file_path); | 647 GetLocalFilePath(context, file_system_url, &file_path); |
| 648 if (error != base::PLATFORM_FILE_OK) | 648 if (error != base::PLATFORM_FILE_OK) |
| 649 return error; | 649 return error; |
| 650 | 650 |
| 651 if (!base::PathExists(file_path)) | 651 if (!base::PathExists(file_path)) |
| 652 return failure_error; | 652 return failure_error; |
| 653 base::PlatformFileInfo file_info; | 653 base::PlatformFileInfo file_info; |
| 654 if (!file_util::GetFileInfo(file_path, &file_info)) | 654 if (!base::GetFileInfo(file_path, &file_info)) |
| 655 return base::PLATFORM_FILE_ERROR_FAILED; | 655 return base::PLATFORM_FILE_ERROR_FAILED; |
| 656 | 656 |
| 657 if (!file_info.is_directory && | 657 if (!file_info.is_directory && |
| 658 !media_path_filter_->Match(file_path)) { | 658 !media_path_filter_->Match(file_path)) { |
| 659 return failure_error; | 659 return failure_error; |
| 660 } | 660 } |
| 661 | 661 |
| 662 *local_file_path = file_path; | 662 *local_file_path = file_path; |
| 663 return base::PLATFORM_FILE_OK; | 663 return base::PLATFORM_FILE_OK; |
| 664 } | 664 } |
| OLD | NEW |