Merge "test_util: Fix gcc build."
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <ios>
|
#include <ios>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -48,7 +49,7 @@ bool CompareFiles(const std::string& file1, const std::string& file2) {
|
|||||||
const std::size_t r1 = std::fread(buf1, 1, kBlockSize, f1.get());
|
const std::size_t r1 = std::fread(buf1, 1, kBlockSize, f1.get());
|
||||||
const std::size_t r2 = std::fread(buf2, 1, kBlockSize, f2.get());
|
const std::size_t r2 = std::fread(buf2, 1, kBlockSize, f2.get());
|
||||||
|
|
||||||
if (r1 != r2 || memcmp(buf1, buf2, r1)) {
|
if (r1 != r2 || std::memcmp(buf1, buf2, r1)) {
|
||||||
return 0; // Files are not equal
|
return 0; // Files are not equal
|
||||||
}
|
}
|
||||||
} while (!std::feof(f1.get()) && !std::feof(f2.get()));
|
} while (!std::feof(f1.get()) && !std::feof(f2.get()));
|
||||||
@@ -65,10 +66,12 @@ std::string GetTempFileName() {
|
|||||||
std::uint64_t GetFileSize(const std::string& file_name) {
|
std::uint64_t GetFileSize(const std::string& file_name) {
|
||||||
std::uint64_t file_size = 0;
|
std::uint64_t file_size = 0;
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
struct stat st = {0};
|
struct stat st;
|
||||||
|
st.st_size = 0;
|
||||||
if (stat(file_name.c_str(), &st) == 0) {
|
if (stat(file_name.c_str(), &st) == 0) {
|
||||||
#else
|
#else
|
||||||
struct _stat st = {0};
|
struct _stat st;
|
||||||
|
st.st_size = 0;
|
||||||
if (_stat(file_name.c_str(), &st) == 0) {
|
if (_stat(file_name.c_str(), &st) == 0) {
|
||||||
#endif
|
#endif
|
||||||
file_size = st.st_size;
|
file_size = st.st_size;
|
||||||
|
|||||||
Reference in New Issue
Block a user