Commit 8cb35a9e authored by Peter Griess's avatar Peter Griess Committed by Sara Golemon

Handle platforms where off_t is not convertible to size_t

Summary:
- On iOS, off_t is an int64_t, and as such std::min() doesn't compile
since the types don't match. Normalize to size_t and fail with an
error if this conversion can't be made

Test Plan:
- fbconfig -r folly && fbmake runtests
- Built on iOS

Reviewed By: tudorb@fb.com

FB internal diff: D1142795
parent 82275df6
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#ifndef FOLLY_FILEUTIL_H_ #ifndef FOLLY_FILEUTIL_H_
#define FOLLY_FILEUTIL_H_ #define FOLLY_FILEUTIL_H_
#include "folly/Conv.h"
#include "folly/Portability.h" #include "folly/Portability.h"
#include "folly/ScopeGuard.h" #include "folly/ScopeGuard.h"
...@@ -144,7 +145,7 @@ bool readFile(const char* file_name, Container& out, ...@@ -144,7 +145,7 @@ bool readFile(const char* file_name, Container& out,
constexpr size_t initialAlloc = 1024 * 4; constexpr size_t initialAlloc = 1024 * 4;
out.resize( out.resize(
std::min( std::min(
buf.st_size ? buf.st_size + 1 : initialAlloc, buf.st_size > 0 ? folly::to<size_t>(buf.st_size + 1) : initialAlloc,
num_bytes)); num_bytes));
while (soFar < out.size()) { while (soFar < out.size()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment