This should fix FAT support for MS Windows and GNU/Linux.
Thanks to elhobbs for the clues.
This commit is contained in:
parent
902f673ab4
commit
47cfe6109e
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ typedef struct {
|
|||
char cFileName[256];
|
||||
char cAlternateFileName[14];
|
||||
u32 flags;
|
||||
u32 fileSize;
|
||||
} FsEntry;
|
||||
|
||||
void * FsReadFirst(const char * path, FsEntry * entry);
|
||||
|
|
Loading…
Reference in New Issue