#include <file_utility.h>
◆ ComputeBinaryMd5() [1/2]
void apollo::localization::msf::FileUtility::ComputeBinaryMd5 |
( |
const unsigned char * |
binary, |
|
|
size_t |
size, |
|
|
char |
res[kCharMd5Lenth] |
|
) |
| |
|
static |
在文件 file_utility.cc 第 107 行定义.
108 {
111 char tmp[3] = {'\0'};
112
114
116 snprintf(tmp, sizeof(tmp), "%02X", md[i]);
117 strncat(buf, tmp, sizeof(tmp));
118 }
119
120 memcpy(res, buf, sizeof(buf));
121}
static const size_t kCharMd5Lenth
static void ComputeBinaryMd5(const unsigned char *binary, size_t size, unsigned char res[kUcharMd5Length])
Compute file md5 given a binary chunk.
static const size_t kUcharMd5Length
◆ ComputeBinaryMd5() [2/2]
void apollo::localization::msf::FileUtility::ComputeBinaryMd5 |
( |
const unsigned char * |
binary, |
|
|
size_t |
size, |
|
|
unsigned char |
res[kUcharMd5Length] |
|
) |
| |
|
static |
Compute file md5 given a binary chunk.
在文件 file_utility.cc 第 96 行定义.
97 {
98 MD5 md5;
99 md5.init();
100 md5.update(binary, static_cast<unsigned int>(size));
101 md5.finalize();
103 res[i] = md5.digest[i];
104 }
105}
◆ ComputeFileMd5() [1/2]
void apollo::localization::msf::FileUtility::ComputeFileMd5 |
( |
const std::string & |
file_path, |
|
|
char |
res[kCharMd5Lenth] |
|
) |
| |
|
static |
在文件 file_utility.cc 第 67 行定义.
68 {
70 unsigned char *buf_pt = &buf[0];
71
72 FILE *file = fopen(file_path.c_str(), "rb");
73 size_t total_size = 0;
74 if (file) {
75 int count = 1;
76 while (!feof(file)) {
77 if (count > 1) {
79 buf_pt = &buf[count - 1];
80 }
81
82 size_t size = fread(buf_pt,
sizeof(
unsigned char),
kBufferSize, file);
83 total_size += size;
84
85 ++count;
86 }
87 } else {
88 AERROR <<
"Can't find the file: " << file_path;
89 return;
90 }
91
93 fclose(file);
94}
◆ ComputeFileMd5() [2/2]
void apollo::localization::msf::FileUtility::ComputeFileMd5 |
( |
const std::string & |
file_path, |
|
|
unsigned char |
res[kUcharMd5Length] |
|
) |
| |
|
static |
Compute file md5 given a file path.
在文件 file_utility.cc 第 38 行定义.
39 {
41 unsigned char *buf_pt = &buf[0];
42
43 FILE *file = fopen(file_path.c_str(), "rb");
44 size_t total_size = 0;
45 if (file) {
46 int count = 1;
47 while (!feof(file)) {
48 if (count > 1) {
50 buf_pt = &buf[count - 1];
51 }
52
53 size_t size = fread(buf_pt,
sizeof(
unsigned char),
kBufferSize, file);
54 total_size += size;
55
56 ++count;
57 }
58 } else {
59 AERROR <<
"Can't find the file: " << file_path;
60 return;
61 }
62
64 fclose(file);
65}
◆ kCharMd5Lenth
const size_t apollo::localization::msf::FileUtility::kCharMd5Lenth = 33 |
|
static |
◆ kUcharMd5Length
const size_t apollo::localization::msf::FileUtility::kUcharMd5Length = 16 |
|
static |
该类的文档由以下文件生成: