2023-02-21 13:36:20 +00:00
|
|
|
//
|
|
|
|
// Created by nigel on 21/02/23.
|
|
|
|
//
|
|
|
|
#include "FAT.h"
|
2023-02-21 20:43:14 +00:00
|
|
|
#include "../../ata pio/ATAPIO.h"
|
|
|
|
#include "../../../memory/KernelHeap.h"
|
2023-02-23 22:54:02 +00:00
|
|
|
#include "../../../../CoreLib/Memory.h"
|
|
|
|
#include "../../partitiontables/mbr/MasterBootRecord.h"
|
2023-02-21 20:43:14 +00:00
|
|
|
#include <CoreLib/Memory.h>
|
2023-02-23 22:54:02 +00:00
|
|
|
superblock* FAT::Mount(filesystem *fs, const char* name ,vfsmount *mnt)
|
2022-03-15 20:56:32 +00:00
|
|
|
{
|
2023-02-17 20:52:03 +00:00
|
|
|
|
2023-02-23 22:54:02 +00:00
|
|
|
if( strncmp (fs->name, "fat", 3 ) != 0 )
|
|
|
|
{
|
|
|
|
printf("Can't mount filesystem with none fat type!\n");
|
|
|
|
return nullptr;
|
|
|
|
}
|
2022-03-15 20:56:32 +00:00
|
|
|
|
2023-02-23 22:54:02 +00:00
|
|
|
superblock* sb = (superblock*) malloc(sizeof(superblock));
|
|
|
|
directoryEntry* root = (directoryEntry*) malloc(sizeof (directoryEntry));
|
|
|
|
root->name = (char*) name;
|
|
|
|
root->node = nullptr;
|
|
|
|
root->parent = nullptr;
|
2022-03-15 20:56:32 +00:00
|
|
|
|
2023-02-23 22:54:02 +00:00
|
|
|
dentry_operations* op = (dentry_operations*) malloc(sizeof(dentry_operations));
|
|
|
|
op->compare = FAT::compare;
|
2023-02-21 20:43:14 +00:00
|
|
|
|
|
|
|
|
2023-02-23 22:54:02 +00:00
|
|
|
root->op = op;
|
2023-02-21 20:43:14 +00:00
|
|
|
|
|
|
|
|
2023-02-23 22:54:02 +00:00
|
|
|
mnt->mnt_count =1;
|
|
|
|
mnt->mnt_devname = "QEMU HDD";
|
|
|
|
mnt->mnt_flags = 0;
|
|
|
|
mnt->mnt_parent = nullptr;
|
2023-02-21 20:43:14 +00:00
|
|
|
|
2023-02-23 22:54:02 +00:00
|
|
|
mnt->root = root;
|
|
|
|
mnt->sb = sb;
|
2023-02-21 20:43:14 +00:00
|
|
|
|
2023-02-23 22:54:02 +00:00
|
|
|
sb->type = fs;
|
|
|
|
sb->root = root;
|
|
|
|
//sb->fs_info = getBPB();
|
2023-02-21 20:43:14 +00:00
|
|
|
|
2023-02-23 22:54:02 +00:00
|
|
|
return sb;
|
2023-02-17 20:52:03 +00:00
|
|
|
}
|
2023-02-23 22:54:02 +00:00
|
|
|
int FAT::Read(file* file, void* buffer , int length)
|
2023-02-21 13:36:20 +00:00
|
|
|
{
|
2023-02-23 22:54:02 +00:00
|
|
|
return 0;
|
2023-02-17 20:52:03 +00:00
|
|
|
}
|
2023-02-23 22:54:02 +00:00
|
|
|
int FAT::Write(file* file, const void* buffer, int length)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
int FAT::compare (directoryEntry*, char* filename, char* filename2)
|
|
|
|
{
|
|
|
|
// use the size of the smallest string
|
|
|
|
int a = strlen(filename);
|
|
|
|
int b = strlen(filename2);
|
2023-02-17 20:52:03 +00:00
|
|
|
|
2023-02-23 22:54:02 +00:00
|
|
|
if( a == b ){
|
|
|
|
return strncmp(filename, filename2, a);
|
|
|
|
}
|
|
|
|
return a-b;
|
2023-02-17 20:52:03 +00:00
|
|
|
}
|
2023-02-23 22:54:02 +00:00
|
|
|
int FAT::create(inode* dir_node, inode** target, const char* component_name){}
|
|
|
|
int FAT::lookup (inode*, inode**, const char*){}
|
2023-02-17 20:52:03 +00:00
|
|
|
|
2023-02-21 20:43:14 +00:00
|
|
|
|
2023-02-23 22:54:02 +00:00
|
|
|
FAT_TYPE FAT::determineFATType(BiosParameterBlock* bpb){
|
|
|
|
int RootDirSector = ((bpb->RootEntCnt * 32) + (bpb->BytsPerSec -1)) / bpb->BytsPerSec;
|
|
|
|
int FATSz = 0;
|
|
|
|
if(bpb->FATSz16 != 0){
|
|
|
|
FATSz = bpb->FATSz16;
|
|
|
|
} else{
|
|
|
|
// FATSz = bpb->FATSz32;
|
2023-02-21 20:43:14 +00:00
|
|
|
|
2023-02-23 22:54:02 +00:00
|
|
|
}
|
|
|
|
int TotSec = 0;
|
|
|
|
if(bpb->TotSec16 != 0){
|
|
|
|
TotSec= bpb->TotSec16;
|
|
|
|
}else{
|
|
|
|
TotSec = bpb->TotSec32;
|
|
|
|
}
|
2023-02-21 20:43:14 +00:00
|
|
|
|
2023-02-23 22:54:02 +00:00
|
|
|
int DataSec = TotSec - (bpb->RsvdSecCnt + (bpb->NumFATs * FATSz) + RootDirSector);
|
|
|
|
int CountofClusters = DataSec / bpb->SecPerClus;
|
2023-02-21 20:43:14 +00:00
|
|
|
|
2023-02-23 22:54:02 +00:00
|
|
|
if(CountofClusters < 4085){
|
|
|
|
return FAT_TYPE::FAT12;
|
|
|
|
} else if (CountofClusters < 65525) {
|
|
|
|
return FAT_TYPE::FAT16;
|
|
|
|
} else{
|
|
|
|
return FAT_TYPE::FAT32;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
BiosParameterBlock* FAT::getBPB( bool DEBUG ){
|
|
|
|
BiosParameterBlock* bpb = (BiosParameterBlock*) malloc(sizeof(BiosParameterBlock));
|
|
|
|
uint16_t StartAddress = 0x00 ;
|
|
|
|
ATAPIO::Read(ATAPIO_PORT::Primary, DEVICE_DRIVE::MASTER, StartAddress, (uint16_t*) bpb);
|
2023-02-17 20:52:03 +00:00
|
|
|
|
2023-02-19 13:17:47 +00:00
|
|
|
if(DEBUG)
|
|
|
|
{
|
2023-02-23 22:54:02 +00:00
|
|
|
printf("OEM ID: %s\n", bpb->OEMName);
|
|
|
|
printf("Bytes per sector: %d\n", bpb->BytsPerSec);
|
|
|
|
printf("Sectors per cluster: %d\n", bpb->SecPerClus);
|
|
|
|
printf("Reserved sectors: %d\n", bpb->RsvdSecCnt);
|
|
|
|
printf("Number of FAT: %d\n", bpb->NumFATs);
|
|
|
|
printf("Number of Dir entries: %d\n", bpb->RootEntCnt);
|
|
|
|
printf("Total Sectors in volume: %d\n", bpb->TotSec16 == 0 ? bpb->TotSec32 : bpb->TotSec16);
|
|
|
|
printf("Sectors per FAT: %d\n", bpb->FATSz16 );
|
2023-02-19 13:17:47 +00:00
|
|
|
}
|
|
|
|
|
2023-02-21 20:43:14 +00:00
|
|
|
return bpb;
|
|
|
|
}
|
2023-02-23 22:54:02 +00:00
|
|
|
uint16_t FAT::GetFATEntry (BiosParameterBlock* bpb, unsigned int cluster){
|
2023-02-24 20:31:20 +00:00
|
|
|
int FATSz = bpb->FATSz16;
|
2023-02-21 20:43:14 +00:00
|
|
|
|
2023-02-23 22:54:02 +00:00
|
|
|
int FATOffset = 0;
|
|
|
|
FAT_TYPE type = FAT::determineFATType(bpb);
|
|
|
|
if( type == FAT_TYPE::FAT16){
|
|
|
|
FATOffset = cluster *2;
|
|
|
|
} else if( type == FAT_TYPE::FAT32){
|
|
|
|
FATOffset = cluster * 4;
|
|
|
|
}
|
2023-02-17 20:52:03 +00:00
|
|
|
|
2023-02-23 22:54:02 +00:00
|
|
|
int thisFATSecNum = bpb->RsvdSecCnt + (FATOffset / bpb->BytsPerSec); // Sector number containing the entry for the cluster
|
2023-02-21 20:43:14 +00:00
|
|
|
|
2023-02-24 20:31:20 +00:00
|
|
|
// For any other FAT other than the default
|
2023-02-23 22:54:02 +00:00
|
|
|
// SectorNumber = (FATNumber * FATSz) + ThisFATSecNum
|
|
|
|
|
|
|
|
uint16_t buff[bpb->BytsPerSec];
|
|
|
|
|
|
|
|
ATAPIO::Read(ATAPIO_PORT::Primary, DEVICE_DRIVE::MASTER, thisFATSecNum, buff );
|
2023-02-21 20:43:14 +00:00
|
|
|
|
2023-02-23 22:54:02 +00:00
|
|
|
int thisFATEntOffset = FATOffset % bpb->BytsPerSec; // offset for the entry in the sector containing the entry for the cluster
|
|
|
|
uint16_t ClusterEntryValue = 0;
|
|
|
|
// Get the FATEntry
|
|
|
|
if(type == FAT_TYPE::FAT16){
|
|
|
|
return *((uint16_t*) &buff[thisFATEntOffset]);
|
|
|
|
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
// FAT32 logic
|
|
|
|
return 0;
|
|
|
|
}
|
2023-02-17 20:52:03 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-02-23 22:54:02 +00:00
|
|
|
uint16_t FAT::DetermineFreeSpace()
|
|
|
|
{
|
|
|
|
// Loop through all FAT entries in all FAT's
|
|
|
|
// to construct a list of free/available clusters
|
|
|
|
// Free clusters are recorded with all 0's except on FAT32 where
|
|
|
|
// the highest order 4 bits should be ignored.
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The number of sectors reserved for each FAT (count of sectors in the BPB_FATSz16 or
|
|
|
|
BPB_FATSz32 fields) may be bigger than the actual number of sectors required for
|
|
|
|
containing the entire FAT. Therefore, there may be totally unused FAT sectors at the end of
|
|
|
|
each FAT in the FAT region of the volume. Each implementation must determine the value
|
|
|
|
for the last valid sector in the FAT using CountOfClusters (the last valid sector in the FAT
|
|
|
|
is the one containing the FAT entry numbered CountOfClusters + 1).
|
|
|
|
All sectors reserved for the FAT beyond the last valid sector (defined as the one containing
|
|
|
|
the FAT entry for the last cluster) must be set to 0x0 during volume initialization/format.
|
|
|
|
*/
|
2023-02-21 20:43:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-02-23 22:54:02 +00:00
|
|
|
int FAT::GetSectorOfRootDirectory (BiosParameterBlock* bpb)
|
|
|
|
{
|
|
|
|
return (bpb->RsvdSecCnt + (bpb->NumFATs * bpb->FATSz16));
|
|
|
|
}
|
|
|
|
|
2023-02-24 20:31:20 +00:00
|
|
|
unsigned int FAT::RootDirSize(BiosParameterBlock* bpb)
|
2023-02-23 22:54:02 +00:00
|
|
|
{
|
2023-02-24 20:31:20 +00:00
|
|
|
return ((bpb->RootEntCnt * 32) + (bpb->BytsPerSec -1)) /bpb->BytsPerSec;
|
|
|
|
|
2023-02-23 22:54:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t* ReadFAT (BiosParameterBlock& bpb , bool DEBUG = false ) {
|
|
|
|
uint32_t FATAddress = /*StartAddress*/ 0x00 + bpb.RsvdSecCnt ;
|
2023-02-17 20:52:03 +00:00
|
|
|
uint16_t* FAT = (uint16_t*)malloc(sizeof (uint16_t) * 256);
|
2023-02-21 20:43:14 +00:00
|
|
|
|
2023-02-23 22:54:02 +00:00
|
|
|
ATAPIO::Read(ATAPIO_PORT::Primary, DEVICE_DRIVE::MASTER, FATAddress, FAT );
|
2023-02-17 20:52:03 +00:00
|
|
|
|
|
|
|
// Show data in terminal
|
2023-02-19 13:17:47 +00:00
|
|
|
if(DEBUG){
|
|
|
|
for( unsigned int i =0 ; i < 256 ; i++) {
|
|
|
|
printf("0x%x ", (unsigned short)FAT[i]);
|
|
|
|
}
|
|
|
|
kterm_put('\n');
|
2023-02-17 20:52:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FAT;
|
|
|
|
}
|
2023-02-21 13:36:20 +00:00
|
|
|
|
2023-02-24 20:31:20 +00:00
|
|
|
void FAT::OpenSubdir(DIR* directory, BiosParameterBlock* bpb ){
|
|
|
|
|
|
|
|
unsigned int cluster = directory->FstClusLo;
|
|
|
|
printf("Listing contents of " );
|
|
|
|
|
|
|
|
for(unsigned char n : directory->Name){
|
|
|
|
if(n == 0x20)
|
|
|
|
continue;
|
|
|
|
kterm_put(n);
|
|
|
|
}
|
|
|
|
kterm_put('\n');
|
|
|
|
printf("FsCluHi: 0x%x , FsCluLo: 0x%x\n", directory->FstClusHi, directory->FstClusLo);
|
|
|
|
printf("Cluster: 0x%x\n", cluster);
|
|
|
|
unsigned int FATEntry = FAT::GetFATEntry(bpb, cluster);
|
|
|
|
printf("FAT_Entry: 0x%x\n", FATEntry);
|
|
|
|
|
|
|
|
unsigned int root_dir_sectors = FAT::RootDirSize(bpb);
|
|
|
|
unsigned int fat_size = bpb->FATSz16;
|
|
|
|
unsigned int first_data_sector = bpb->RsvdSecCnt + ( bpb->NumFATs * fat_size) + root_dir_sectors;
|
|
|
|
unsigned int first_directory_sector = ((cluster - 2) * bpb->SecPerClus) + first_data_sector;
|
|
|
|
printf("Directory first sector 0x%x\n" , first_directory_sector);
|
|
|
|
uint16_t data[256];
|
|
|
|
ATAPIO::Read(ATAPIO_PORT::Primary, DEVICE_DRIVE::MASTER, first_directory_sector, data);
|
|
|
|
|
|
|
|
auto* directoryContents = (DIR*) data;
|
|
|
|
for(int i = 0; i < sizeof(data) / sizeof(DIR); i++){
|
|
|
|
DIR* entry = (DIR*)((uint32_t)directoryContents + (i * sizeof(DIR)));
|
|
|
|
|
|
|
|
if(entry->Name[0] == FAT::FREE_DIR || entry->Name[0] == FAT::FREE_DIR_2 || entry->Name[0] == 0xE5)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if(entry->ATTR & FAT::ATTRIBUTES::ATTR_HIDDEN){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(entry->ATTR & FAT::ATTRIBUTES::ATTR_SYSTEM)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
if(entry->ATTR & FAT::ATTRIBUTES::ATTR_VOLUME_ID){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(entry->ATTR & FAT::ATTRIBUTES::ATTR_LONG_NAME)){
|
|
|
|
for(char n : entry->Name){
|
|
|
|
if(n == 0x20)
|
|
|
|
continue;
|
|
|
|
kterm_put(n);
|
|
|
|
}
|
|
|
|
kterm_put('\n');
|
|
|
|
}else{
|
|
|
|
printf("LFN\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-02-25 20:03:10 +00:00
|
|
|
void FAT::readFile(DIR* fileEntry , BiosParameterBlock* bpb){
|
|
|
|
unsigned int cluster = fileEntry->FstClusLo;
|
|
|
|
unsigned int FATEntry = FAT::GetFATEntry(bpb, cluster);
|
|
|
|
unsigned int root_dir_sectors = FAT::RootDirSize(bpb);
|
|
|
|
unsigned int fat_size = bpb->FATSz16;
|
|
|
|
unsigned int first_data_sector = bpb->RsvdSecCnt + (bpb->NumFATs * fat_size) + root_dir_sectors;
|
|
|
|
unsigned int file_data_sector = ((cluster -2) * bpb->SecPerClus) + first_data_sector;
|
|
|
|
printf("FAT entry = %x\n", FATEntry);
|
|
|
|
uint16_t data[256];
|
|
|
|
ATAPIO::Read(ATAPIO_PORT::Primary, DEVICE_DRIVE::MASTER, file_data_sector, data);
|
2023-02-23 22:54:02 +00:00
|
|
|
|
2023-02-25 20:03:10 +00:00
|
|
|
for (unsigned short n : data)
|
|
|
|
{
|
2023-02-19 13:17:47 +00:00
|
|
|
kterm_put(n & 0x00ff);
|
|
|
|
kterm_put(n >> 8);
|
|
|
|
}
|
2023-02-17 20:52:03 +00:00
|
|
|
|
2023-02-25 20:03:10 +00:00
|
|
|
}
|
2023-02-17 20:52:03 +00:00
|
|
|
|
2023-02-23 22:54:02 +00:00
|
|
|
/*
|
|
|
|
file fsysFatDirectory (const char* DirectoryName){
|
|
|
|
file file;
|
2023-02-17 20:52:03 +00:00
|
|
|
unsigned char* buf;
|
|
|
|
PDIRECTORY directory;
|
|
|
|
|
|
|
|
char DosFileName[11];
|
2023-02-23 22:54:02 +00:00
|
|
|
//ToDosFileName(DirectoryName, DosFileName, 11);
|
2023-02-17 20:52:03 +00:00
|
|
|
DosFileName[11] =0;
|
|
|
|
|
|
|
|
for (int sector=0; sector <14 ; sector++){
|
2023-02-23 22:54:02 +00:00
|
|
|
ATAPIO::Read(BUS_PORT::Primary, DEVICE_DRIVE::MASTER, mountInfo.rootOffset + sector, (uint16_t*)buf);
|
2023-02-17 20:52:03 +00:00
|
|
|
directory = (PDIRECTORY) buf;
|
|
|
|
|
|
|
|
for (int i =0; i < 16; i++){
|
|
|
|
char name[11];
|
|
|
|
memcpy(name, directory->Filename, 11);
|
|
|
|
name[11]=0;
|
|
|
|
|
|
|
|
if(strncmp(DosFileName, name, 11) == 0){
|
|
|
|
strcpy(file.name, DirectoryName);
|
|
|
|
file.id = 0;
|
|
|
|
file.currentCluster = directory->FirstCluster;
|
|
|
|
file.eof = 0;
|
|
|
|
file.filelength = directory->FileSize;
|
|
|
|
|
|
|
|
if(directory->Attrib == 0x10){
|
2023-02-23 22:54:02 +00:00
|
|
|
file.flags = 2;
|
2023-02-17 20:52:03 +00:00
|
|
|
} else {
|
2023-02-23 22:54:02 +00:00
|
|
|
file.flags = 1;
|
2023-02-17 20:52:03 +00:00
|
|
|
}
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
directory++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Can't find file
|
2023-02-23 22:54:02 +00:00
|
|
|
file.flags = -1;
|
2023-02-17 20:52:03 +00:00
|
|
|
return file;
|
|
|
|
|
2022-03-15 20:56:32 +00:00
|
|
|
}
|
2023-02-21 13:36:20 +00:00
|
|
|
|
2023-02-17 20:52:03 +00:00
|
|
|
|
|
|
|
void fsysFATRead(PFILE file, unsigned char* buffer, unsigned int length){
|
|
|
|
if(file){
|
|
|
|
unsigned int physSector = 32 + (file->currentCluster - 1);
|
|
|
|
const unsigned int SECTOR_SIZE = 512;
|
|
|
|
// read sector
|
|
|
|
ATA_DEVICE::Read(BUS_PORT::Primary, DEVICE_DRIVE::MASTER, physSector, (uint16_t*) buffer );
|
2022-03-15 20:56:32 +00:00
|
|
|
|
2023-02-17 20:52:03 +00:00
|
|
|
unsigned int FAT_Offset = file->currentCluster + (file->currentCluster /2);
|
|
|
|
unsigned int FAT_Sector = 1 + (FAT_Offset / SECTOR_SIZE);
|
|
|
|
unsigned int entryOffset =FAT_Offset % SECTOR_SIZE;
|
|
|
|
|
|
|
|
uint8_t FAT[SECTOR_SIZE*2];
|
|
|
|
ATA_DEVICE::Read(BUS_PORT::Primary, DEVICE_DRIVE::MASTER, FAT_Sector,(uint16_t*) FAT); // Read 1st FAT sector
|
|
|
|
|
|
|
|
ATA_DEVICE::Read(BUS_PORT::Primary, DEVICE_DRIVE::MASTER, FAT_Sector +1, (uint16_t*)FAT+SECTOR_SIZE);
|
|
|
|
|
|
|
|
// read entry for next cluster
|
|
|
|
uint16_t nextCluster = *(uint16_t*) &FAT[entryOffset];
|
|
|
|
|
|
|
|
// test if entry is odd or even
|
|
|
|
if(file->currentCluster & 0x0001){
|
|
|
|
nextCluster>>= 4; // grab the high 12 bits
|
|
|
|
}else{
|
|
|
|
nextCluster &= 0x0FFF; // grab the low 12 bits
|
|
|
|
}
|
|
|
|
|
|
|
|
// test for end of file
|
|
|
|
if(nextCluster >= 0xff8){
|
|
|
|
file->eof -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// test for file corruption
|
|
|
|
if(nextCluster == 0){
|
|
|
|
file->eof =1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// set next cluster
|
|
|
|
file->currentCluster = nextCluster;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2023-02-21 13:36:20 +00:00
|
|
|
|
2023-02-17 20:52:03 +00:00
|
|
|
FILE fsysFatOpenSubDir(FILE kFile, const char* filename){
|
|
|
|
FILE file;
|
|
|
|
|
|
|
|
char DosFileName[11];
|
|
|
|
ToDosFileName(filename, DosFileName, 11);
|
|
|
|
DosFileName[11] = 0;
|
|
|
|
|
|
|
|
while(!kFile.eof){
|
|
|
|
//read directory
|
|
|
|
unsigned char buf[512];
|
|
|
|
fsysFATRead(&file, buf, 512);
|
|
|
|
|
|
|
|
PDIRECTORY pkDir = (PDIRECTORY) buf;
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < 16; i++){
|
|
|
|
// get current filename
|
|
|
|
char name[11];
|
|
|
|
memcpy(name, pkDir->Filename, 11);
|
|
|
|
name[11] = 0;
|
|
|
|
|
|
|
|
if(strncmp(name, DosFileName, 11) == 0){
|
|
|
|
strcpy(file.name, filename);
|
|
|
|
file.id = 0;
|
|
|
|
file.currentCluster = pkDir->FirstCluster;
|
|
|
|
file.filelength = pkDir->FileSize;
|
|
|
|
file.eof = 0;
|
|
|
|
|
|
|
|
// set file type;
|
|
|
|
if(pkDir->Attrib == 0x10){
|
2023-02-23 22:54:02 +00:00
|
|
|
file.flags = 2;
|
2023-02-17 20:52:03 +00:00
|
|
|
} else{
|
2023-02-23 22:54:02 +00:00
|
|
|
file.flags = 1;
|
2023-02-17 20:52:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
// go to next entry
|
|
|
|
pkDir++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// unable to find file
|
2023-02-23 22:54:02 +00:00
|
|
|
file.flags = -1;
|
2023-02-17 20:52:03 +00:00
|
|
|
return file;
|
|
|
|
}
|
2023-02-23 22:54:02 +00:00
|
|
|
*/
|