mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-15 16:05:10 +01:00
f6c9003574
*modified libcustomfat and ntfs fragment fetch function to support >512 bytes per sector *Added new ehcmodule (thanks rodries) *Added real support of using both ports simultaniously without shutting down the other (thanks rodries for the ehcmodule works on this). There is no longer the limitation that the settings have to be on SD card for this. (ONLY HERMES CIOS) *Moved a few settings to Feature Settings and added a new Hard Drive Settings *Changed Wiinnertag path to only point to the path and not to the file. You must correct the path manually in custom path settings or reset you configs for this change or Winnertag won't work!! *Removed a few compile warnings for devkitPPC R23
64 lines
1.4 KiB
C
64 lines
1.4 KiB
C
#include "fatfile.h"
|
|
|
|
#include <fcntl.h>
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
#include <ctype.h>
|
|
#include <unistd.h>
|
|
|
|
#include "cache.h"
|
|
#include "file_allocation_table.h"
|
|
#include "bit_ops.h"
|
|
#include "filetime.h"
|
|
#include "lock.h"
|
|
#include "fatfile_frag.h"
|
|
|
|
int _FAT_get_fragments (const char *path, _fat_frag_append_t append_fragment, void *callback_data)
|
|
{
|
|
struct _reent r;
|
|
FILE_STRUCT file;
|
|
PARTITION* partition;
|
|
u32 cluster;
|
|
u32 sector;
|
|
u32 offset; // in sectors
|
|
u32 size; // in sectors
|
|
int ret = -1;
|
|
int fd;
|
|
|
|
fd = _FAT_open_r (&r, &file, path, O_RDONLY, 0);
|
|
if (fd == -1) return -1;
|
|
if (fd != (int)&file) return -1;
|
|
|
|
partition = file.partition;
|
|
_FAT_lock(&partition->lock);
|
|
|
|
size = file.filesize / partition->bytesPerSector;
|
|
cluster = file.startCluster;
|
|
offset = 0;
|
|
|
|
do {
|
|
if (!_FAT_fat_isValidCluster(partition, cluster)) {
|
|
// invalid cluster
|
|
goto out;
|
|
}
|
|
// add cluster to fileinfo
|
|
sector = _FAT_fat_clusterToSector(partition, cluster);
|
|
if (append_fragment(callback_data, offset, sector, partition->sectorsPerCluster)) {
|
|
// too many fragments
|
|
goto out;
|
|
}
|
|
offset += partition->sectorsPerCluster;
|
|
cluster = _FAT_fat_nextCluster (partition, cluster);
|
|
} while (offset < size);
|
|
|
|
// set size
|
|
append_fragment(callback_data, size, 0, 0);
|
|
// success
|
|
ret = 0;
|
|
|
|
out:
|
|
_FAT_unlock(&partition->lock);
|
|
_FAT_close_r(&r, fd);
|
|
return ret;
|
|
}
|