Permalink
Browse files

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

… sizes...
  • Loading branch information...
hrydgard committed Jul 3, 2017
1 parent 7da5dfc commit e6e96c0d895bc273785ef60ca4a57d3db38dc6b0
Showing with 17 additions and 3 deletions.
  1. +10 −0 Common/FileUtil.cpp
  2. +6 −2 ext/native/file/file_util.cpp
  3. +1 −1 ext/native/file/zip_read.cpp
View
@@ -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;
@@ -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;
@@ -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));

3 comments on commit e6e96c0

@unknownbrackets

This comment has been minimized.

Show comment
Hide comment
@unknownbrackets

unknownbrackets Jul 3, 2017

Collaborator

I guess that's because of this:
https://github.com/android/platform_bionic/blob/master/libc/include/sys/stat.h#L165

I thought stat64 was just a #define for stat previously...

Seems like it probably (?) won't matter for ppsspp, though.

-[Unknown]

Collaborator

unknownbrackets replied Jul 3, 2017

I guess that's because of this:
https://github.com/android/platform_bionic/blob/master/libc/include/sys/stat.h#L165

I thought stat64 was just a #define for stat previously...

Seems like it probably (?) won't matter for ppsspp, though.

-[Unknown]

@hrydgard

This comment has been minimized.

Show comment
Hide comment
@hrydgard

hrydgard Jul 3, 2017

Owner

Yeah, ISOs are never larger than 1.8GB or whatever it is anyway - well, except for the hacked Final Fantasy Type-0 single-disc translation...

Owner

hrydgard replied Jul 3, 2017

Yeah, ISOs are never larger than 1.8GB or whatever it is anyway - well, except for the hacked Final Fantasy Type-0 single-disc translation...

@Orphis

This comment has been minimized.

Show comment
Hide comment
Please sign in to comment.