Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(490)

Side by Side Diff: tools/android/md5sum/md5sum.cc

Issue 12217101: Replace FilePath with base::FilePath in some more top level directories. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // Md5sum implementation for Android. This version handles files as well as 5 // Md5sum implementation for Android. This version handles files as well as
6 // directories. Its output is sorted by file path. 6 // directories. Its output is sorted by file path.
7 7
8 #include <fstream> 8 #include <fstream>
9 #include <iostream> 9 #include <iostream>
10 #include <set> 10 #include <set>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 *digest_string = base::MD5DigestToBase16(digest); 44 *digest_string = base::MD5DigestToBase16(digest);
45 return true; 45 return true;
46 } 46 }
47 47
48 // Returns the set of all files contained in |files|. This handles directories 48 // Returns the set of all files contained in |files|. This handles directories
49 // by walking them recursively. Excludes, .svn directories and file under them. 49 // by walking them recursively. Excludes, .svn directories and file under them.
50 std::set<std::string> MakeFileSet(const char** files) { 50 std::set<std::string> MakeFileSet(const char** files) {
51 const std::string svn_dir_component = FILE_PATH_LITERAL("/.svn/"); 51 const std::string svn_dir_component = FILE_PATH_LITERAL("/.svn/");
52 std::set<std::string> file_set; 52 std::set<std::string> file_set;
53 for (const char** file = files; *file; ++file) { 53 for (const char** file = files; *file; ++file) {
54 FilePath file_path(*file); 54 base::FilePath file_path(*file);
55 if (file_util::DirectoryExists(file_path)) { 55 if (file_util::DirectoryExists(file_path)) {
56 file_util::FileEnumerator file_enumerator( 56 file_util::FileEnumerator file_enumerator(
57 file_path, true /* recurse */, file_util::FileEnumerator::FILES); 57 file_path, true /* recurse */, file_util::FileEnumerator::FILES);
58 for (FilePath child, empty; (child = file_enumerator.Next()) != empty; ) { 58 for (base::FilePath child, empty;
59 (child = file_enumerator.Next()) != empty; ) {
59 // If the path contains /.svn/, ignore it. 60 // If the path contains /.svn/, ignore it.
60 if (child.value().find(svn_dir_component) == std::string::npos) { 61 if (child.value().find(svn_dir_component) == std::string::npos) {
61 file_util::AbsolutePath(&child); 62 file_util::AbsolutePath(&child);
62 file_set.insert(child.value()); 63 file_set.insert(child.value());
63 } 64 }
64 } 65 }
65 } else { 66 } else {
66 file_set.insert(*file); 67 file_set.insert(*file);
67 } 68 }
68 } 69 }
69 return file_set; 70 return file_set;
70 } 71 }
71 72
72 } // namespace 73 } // namespace
73 74
74 int main(int argc, const char* argv[]) { 75 int main(int argc, const char* argv[]) {
75 if (argc < 2) { 76 if (argc < 2) {
76 LOG(ERROR) << "Usage: md5sum <path/to/file_or_dir>..."; 77 LOG(ERROR) << "Usage: md5sum <path/to/file_or_dir>...";
77 return 1; 78 return 1;
78 } 79 }
79 const std::set<std::string> files = MakeFileSet(argv + 1); 80 const std::set<std::string> files = MakeFileSet(argv + 1);
80 bool failed = false; 81 bool failed = false;
81 std::string digest; 82 std::string digest;
82 for (std::set<std::string>::const_iterator it = files.begin(); 83 for (std::set<std::string>::const_iterator it = files.begin();
83 it != files.end(); ++it) { 84 it != files.end(); ++it) {
84 if (!MD5Sum(it->c_str(), &digest)) 85 if (!MD5Sum(it->c_str(), &digest))
85 failed = true; 86 failed = true;
86 FilePath file_path(*it); 87 base::FilePath file_path(*it);
87 file_util::AbsolutePath(&file_path); 88 file_util::AbsolutePath(&file_path);
88 std::cout << digest << " " << file_path.value() << std::endl; 89 std::cout << digest << " " << file_path.value() << std::endl;
89 } 90 }
90 return failed; 91 return failed;
91 } 92 }
OLDNEW
« no previous file with comments | « tools/android/device_stats_monitor/device_stats_monitor.cc ('k') | tools/generate_library_loader/generate_library_loader.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698