mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-26 23:10:38 +00:00
Add VFSFileSystem for Android to be able to mount flash0: inside the APK
This commit is contained in:
parent
17c8eb1ae7
commit
3f6353af5a
@ -167,6 +167,13 @@ bool getFileInfo(const char *path, FileInfo *fileInfo)
|
||||
fileInfo->fullName = path;
|
||||
|
||||
#ifdef _WIN32
|
||||
fileInfo->size = 0;
|
||||
FILE *f = fopen(path, "rb");
|
||||
if (f) {
|
||||
fseek(f, 0, SEEK_END);
|
||||
fileInfo->size = ftell(f);
|
||||
fclose(f);
|
||||
}
|
||||
DWORD attributes = GetFileAttributes(path);
|
||||
fileInfo->isDirectory = (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
fileInfo->isWritable = (attributes & FILE_ATTRIBUTE_READONLY) == 0;
|
||||
@ -185,6 +192,7 @@ bool getFileInfo(const char *path, FileInfo *fileInfo)
|
||||
|
||||
fileInfo->isDirectory = S_ISDIR(file_info.st_mode);
|
||||
fileInfo->isWritable = false;
|
||||
fileInfo->size = file_info.st_size;
|
||||
// HACK: approximation
|
||||
if (file_info.st_mode & 0200)
|
||||
fileInfo->isWritable = true;
|
||||
|
@ -19,6 +19,7 @@ struct FileInfo
|
||||
bool exists;
|
||||
bool isDirectory;
|
||||
bool isWritable;
|
||||
size_t size;
|
||||
|
||||
bool operator <(const FileInfo &other) const {
|
||||
if (isDirectory && !other.isDirectory)
|
||||
|
@ -77,7 +77,7 @@ ZipAssetReader::~ZipAssetReader() {
|
||||
}
|
||||
|
||||
uint8_t *ZipAssetReader::ReadAsset(const char *path, size_t *size) {
|
||||
char temp_path[256];
|
||||
char temp_path[1024];
|
||||
strcpy(temp_path, in_zip_path_);
|
||||
strcat(temp_path, path);
|
||||
return ReadFromZip(zip_file_, temp_path, size);
|
||||
@ -142,10 +142,24 @@ bool ZipAssetReader::GetFileListing(const char *path, std::vector<FileInfo> *lis
|
||||
|
||||
bool ZipAssetReader::GetFileInfo(const char *path, FileInfo *info)
|
||||
{
|
||||
struct zip_stat zstat;
|
||||
char temp_path[1024];
|
||||
strcpy(temp_path, in_zip_path_);
|
||||
strcat(temp_path, path);
|
||||
if (0 != zip_stat(zip_file_, temp_path, ZIP_FL_NOCASE, &zstat))
|
||||
{
|
||||
ELOG("Failed doing zip_stat on %s, bailing", path);
|
||||
info->exists = false;
|
||||
info->size = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
info->fullName = path;
|
||||
info->exists = true; // TODO
|
||||
info->isWritable = false;
|
||||
info->isDirectory = false; // TODO
|
||||
info->size = zstat.size;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user