diff --git a/desmume/src/cflash.c b/desmume/src/cflash.c index 3470c546f..1f24c3b42 100644 --- a/desmume/src/cflash.c +++ b/desmume/src/cflash.c @@ -152,8 +152,7 @@ void add_file(char *fname, FsEntry * entry, int fileLevel) { files[numFiles].ext[j] = 0x20; } - //files[numFiles].fileSize = entry->nFileSizeLow; - files[numFiles].fileSize = 0; + files[numFiles].fileSize = entry->fileSize; if (entry->flags & FS_IS_DIR) { if (strcmp(fname,".")==0) @@ -523,7 +522,7 @@ u16 fread_buffered(int dirent,u32 cluster,u32 offset) { fatstring_to_asciiz(dirent,fname,NULL); strncat(fpath,fname,256-strlen(fpath)); - hFile = fopen(fpath, "w"); + hFile = fopen(fpath, "r"); if (!hFile) return 0; fread(&freadBuffer, 1, 512, hFile); diff --git a/desmume/src/fs-linux.c b/desmume/src/fs-linux.c index 494e48fec..f3993e52a 100644 --- a/desmume/src/fs-linux.c +++ b/desmume/src/fs-linux.c @@ -62,7 +62,10 @@ void * FsReadFirst(const char * path, FsEntry * entry) { stat(buffer, &s); if (S_ISDIR(s.st_mode)) { entry->flags = FS_IS_DIR; - } + entry->fileSize = 0; + } else { + entry->fileSize = s.st_size; + } return dir; } @@ -87,6 +90,9 @@ int FsReadNext(void * search, FsEntry * entry) { stat(buffer, &s); if (S_ISDIR(s.st_mode)) { entry->flags = FS_IS_DIR; + entry->fileSize = 0; + } else { + entry->fileSize = s.st_size; } return 1; diff --git a/desmume/src/fs-windows.c b/desmume/src/fs-windows.c index a2199f451..aa6221fb2 100644 --- a/desmume/src/fs-windows.c +++ b/desmume/src/fs-windows.c @@ -46,7 +46,10 @@ void * FsReadFirst(const char * p, FsEntry * entry) { entry->flags = 0; if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { entry->flags = FS_IS_DIR; - } + entry->fileSize = 0; + } else { + entry->fileSize = FindFileData.nFileSizeLow; + } ret = (void**)malloc(sizeof(HANDLE)); *ret = hFind; @@ -67,7 +70,10 @@ int FsReadNext(void * search, FsEntry * entry) { entry->flags = 0; if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { entry->flags = FS_IS_DIR; - } + entry->fileSize = 0; + } else { + entry->fileSize = FindFileData.nFileSizeLow; + } return ret; } diff --git a/desmume/src/fs.h b/desmume/src/fs.h index a1f25b8fb..97cf21b4f 100644 --- a/desmume/src/fs.h +++ b/desmume/src/fs.h @@ -36,6 +36,7 @@ typedef struct { char cFileName[256]; char cAlternateFileName[14]; u32 flags; + u32 fileSize; } FsEntry; void * FsReadFirst(const char * path, FsEntry * entry);