Fix build with NDK 15. This does force us to make do with 32-bit file sizes...

This commit is contained in:
Henrik Rydgård 2017-07-03 16:16:25 +02:00
parent 7da5dfcdd7
commit e6e96c0d89
3 changed files with 17 additions and 3 deletions

View File

@ -443,8 +443,13 @@ bool GetFileDetails(const std::string &filename, FileDetails *details) {
if (!Exists(filename)) {
return false;
}
#if __ANDROID__ && __ANDROID_API__ < 21
struct stat buf;
if (stat(filename.c_str(), &buf) == 0) {
#else
struct stat64 buf;
if (stat64(filename.c_str(), &buf) == 0) {
#endif
details->size = buf.st_size;
details->isDirectory = S_ISDIR(buf.st_mode);
details->atime = buf.st_atime;
@ -506,9 +511,14 @@ u64 GetFileSize(const std::string &filename) {
if (attr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
return 0;
return ((u64)attr.nFileSizeHigh << 32) | (u64)attr.nFileSizeLow;
#else
#if __ANDROID__ && __ANDROID_API__ < 21
struct stat file_info;
int result = stat(filename.c_str(), &file_info);
#else
struct stat64 file_info;
int result = stat64(filename.c_str(), &file_info);
#endif
if (result != 0) {
WARN_LOG(COMMON, "GetSize: failed %s: No such file", filename.c_str());
return 0;

View File

@ -153,12 +153,16 @@ bool getFileInfo(const char *path, FileInfo *fileInfo) {
fileInfo->isWritable = (attrs.dwFileAttributes & FILE_ATTRIBUTE_READONLY) == 0;
fileInfo->exists = true;
#else
struct stat64 file_info;
std::string copy(path);
#ifdef __ANDROID__ && __ANDROID_API__ < 21
struct stat file_info;
int result = stat(copy.c_str(), &file_info);
#else
struct stat64 file_info;
int result = stat64(copy.c_str(), &file_info);
#endif
if (result < 0) {
WLOG("IsDirectory: stat failed on %s", path);
fileInfo->exists = false;

View File

@ -183,7 +183,7 @@ bool ZipAssetReader::GetFileListing(const char *orig_path, std::vector<FileInfo>
continue;
if (!memcmp(name, path, pathlen)) {
// The prefix is right. Let's see if this is a file or path.
char *slashPos = strchr(name + pathlen + 1, '/');
const char *slashPos = strchr(name + pathlen + 1, '/');
if (slashPos != 0) {
// A directory.
std::string dirName = std::string(name + pathlen + 1, slashPos - (name + pathlen + 1));