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> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/file_util.h" | |
14 #include "base/files/file_enumerator.h" | 13 #include "base/files/file_enumerator.h" |
15 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/files/file_util.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/md5.h" | 17 #include "base/md5.h" |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 const int kBufferSize = 1024; | 21 const int kBufferSize = 1024; |
22 | 22 |
23 // Returns whether |path|'s MD5 was successfully written to |digest_string|. | 23 // Returns whether |path|'s MD5 was successfully written to |digest_string|. |
24 bool MD5Sum(const char* path, std::string* digest_string) { | 24 bool MD5Sum(const char* path, std::string* digest_string) { |
25 std::ifstream stream(path); | 25 std::ifstream stream(path); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 for (std::set<std::string>::const_iterator it = files.begin(); | 84 for (std::set<std::string>::const_iterator it = files.begin(); |
85 it != files.end(); ++it) { | 85 it != files.end(); ++it) { |
86 if (!MD5Sum(it->c_str(), &digest)) | 86 if (!MD5Sum(it->c_str(), &digest)) |
87 failed = true; | 87 failed = true; |
88 base::FilePath file_path(*it); | 88 base::FilePath file_path(*it); |
89 std::cout << digest << " " | 89 std::cout << digest << " " |
90 << base::MakeAbsoluteFilePath(file_path).value() << std::endl; | 90 << base::MakeAbsoluteFilePath(file_path).value() << std::endl; |
91 } | 91 } |
92 return failed; | 92 return failed; |
93 } | 93 } |
OLD | NEW |