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 // 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 int main(int argc, const char* argv[]) { | 72 int main(int argc, const char* argv[]) { |
73 if (argc < 2) { | 73 if (argc < 2) { |
74 LOG(ERROR) << "Usage: md5sum <path/to/file_or_dir>..."; | 74 LOG(ERROR) << "Usage: md5sum <path/to/file_or_dir>..."; |
75 return 1; | 75 return 1; |
76 } | 76 } |
77 const std::set<std::string> files = MakeFileSet(argv + 1); | 77 const std::set<std::string> files = MakeFileSet(argv + 1); |
78 bool failed = false; | 78 bool failed = false; |
79 std::string digest; | 79 std::string digest; |
80 for (std::set<std::string>::const_iterator it = files.begin(); | 80 for (std::set<std::string>::const_iterator it = files.begin(); |
81 it != files.end(); ++it) { | 81 it != files.end(); ++it) { |
82 if (!MD5Sum(it->c_str(), &digest)) | 82 if (!MD5Sum(it->c_str(), &digest)) { |
83 failed = true; | 83 failed = true; |
84 base::FilePath file_path(*it); | 84 } else { |
85 std::cout << digest << " " | 85 base::FilePath file_path(*it); |
86 << base::MakeAbsoluteFilePath(file_path).value() << std::endl; | 86 std::cout << digest << " " |
| 87 << base::MakeAbsoluteFilePath(file_path).value() << std::endl; |
| 88 } |
87 } | 89 } |
88 return failed; | 90 return failed; |
89 } | 91 } |
OLD | NEW |