Read a little bit of the data from the file

This commit is contained in:
Byron Lathi
2023-12-05 08:15:24 -08:00
parent 946234381d
commit 13738fc0d8
2 changed files with 21 additions and 4 deletions

View File

@@ -1,11 +1,30 @@
#include <stdio.h>
#include <filesystems/fat32.h>
#include <conio.h>
void fat32_init(void);
int main(void) {
struct fat32_directory_entry dentry;
int i;
uint32_t offset = 0;
uint32_t cluster;
fat32_init();
/* This is what is going to be part of open */
fat32_get_cluster_by_name("TEST TXT", &dentry);
cprintf("attr1: %x\n", dentry.attr1);
cprintf("cluster: %x%x\n", dentry.cluster_high, dentry.cluster_low);
cprintf("File Size: %lx\n", dentry.file_size);
/* This will become part of read */
cluster = (dentry.cluster_high << 16) | dentry.cluster_low;
fat32_read_cluster(cluster + offset/512, sd_buf);
for (i = 0; i < dentry.file_size; i++) {
cprintf("%c", sd_buf[i]);
}
return 0;
}