1
0
Fork 0
forked from AbleOS/ableos
ableos-idl/sysdata/programs/filesystem_fat32/src/main.hb
2024-10-25 16:37:38 +01:00

59 lines
1.2 KiB
Plaintext

stn := @use("../../../libraries/stn/src/lib.hb");
.{string, memory, buffer, log} := stn
attributes := @use("attributes.hb")
datetime := @use("datetime.hb")
directory := @use("file.hb")
bios_parameter_block := @use("bios_parameter_block.hb");
.{bpb_sanity_check, ebr_sanity_check, fs_info_sanity_check} := bios_parameter_block;
.{new_bpb, new_ebr, new_fs_info} := bios_parameter_block
FAT12_THRESHOLD := 4085
FAT16_THRESHOLD := 65525
ExFAT := 0
FAT12 := 1
FAT16 := 2
FAT32 := 3
calculate_fat_type := fn(sector_size: uint, total_clusters: uint): uint {
if sector_size == 0 {
return ExFAT
} else if total_clusters < 4085 {
return FAT12
} else if total_clusters < 65525 {
return FAT16
} else {
return FAT32
}
}
main := fn(): int {
bpb := new_bpb()
ebr := new_ebr()
fsi := new_fs_info()
fat_type := calculate_fat_type(1, 100)
if fat_type != FAT32 {
log.warn("filesystem_fat32 driver only supports Fat32.\0")
}
bsc := bpb_sanity_check(bpb)
esc := ebr_sanity_check(ebr)
fssc := fs_info_sanity_check(fsi)
msg_type := 0
loop {
// Open file
if msg_type == 0 {
// Paths without a node-disk component are to be treated as local files.
file_path := "node-disk:/test\0"
} else {
// error
}
}
return 0
}