text stringlengths 0 234 |
|---|
end loop; |
end Prepend; |
Ret : Status_Code; |
D_Entry : FAT_Directory_Entry; |
V_Entry : VFAT_Directory_Entry; |
function To_VFAT_Entry is new Ada.Unchecked_Conversion |
(FAT_Directory_Entry, VFAT_Directory_Entry); |
C : Unsigned_8; |
Last_Seq : VFAT_Sequence_Number := 0; |
CRC : Unsigned_8 := 0; |
Matches : Boolean; |
Current_CRC : Unsigned_8; |
L_Name : String (1 .. MAX_FILENAME_LENGTH); |
L_Name_First : Natural; |
begin |
L_Name_First := L_Name'Last + 1; |
loop |
Ret := Next_Entry |
(FS, |
Current_Cluster => Current_Cluster, |
Current_Block => Current_Block, |
Current_Index => Current_Index, |
DEntry => D_Entry); |
if Ret /= OK then |
return Ret; |
end if; |
-- Check if we have a VFAT entry here by checking that the |
-- attributes are 16#0F# (e.g. all attributes set except |
-- subdirectory and archive) |
if D_Entry.Attributes = VFAT_Directory_Entry_Attribute then |
V_Entry := To_VFAT_Entry (D_Entry); |
if V_Entry.VFAT_Attr.Stop_Bit then |
L_Name_First := L_Name'Last + 1; |
else |
if Last_Seq = 0 |
or else Last_Seq - 1 /= V_Entry.VFAT_Attr.Sequence |
then |
L_Name_First := L_Name'Last + 1; |
end if; |
end if; |
Last_Seq := V_Entry.VFAT_Attr.Sequence; |
Prepend (V_Entry.Name_3, L_Name, L_Name_First); |
Prepend (V_Entry.Name_2, L_Name, L_Name_First); |
Prepend (V_Entry.Name_1, L_Name, L_Name_First); |
if V_Entry.VFAT_Attr.Sequence = 1 then |
CRC := V_Entry.Checksum; |
end if; |
-- Ignore Volumes and deleted files |
elsif not D_Entry.Attributes.Volume_Label |
and then Character'Pos (D_Entry.Filename (1)) /= 16#E5# |
then |
if L_Name_First not in L_Name'Range then |
Matches := False; |
else |
Current_CRC := 0; |
Last_Seq := 0; |
for Ch of String'(D_Entry.Filename & D_Entry.Extension) loop |
C := Character'Enum_Rep (Ch); |
Current_CRC := Shift_Right (Current_CRC and 16#FE#, 1) |
or Shift_Left (Current_CRC and 16#01#, 7); |
-- Modulo addition |
Current_CRC := Current_CRC + C; |
end loop; |
Matches := Current_CRC = CRC; |
end if; |
DEntry := |
(FS => FAT_Filesystem_Access (FS), |
L_Name => <>, |
S_Name => D_Entry.Filename, |
S_Name_Ext => D_Entry.Extension, |
Attributes => D_Entry.Attributes, |
Start_Cluster => (if FS.Version = FAT16 |
then Cluster_Type (D_Entry.Cluster_L) |
else Cluster_Type (D_Entry.Cluster_L) or |
Shift_Left |
(Cluster_Type (D_Entry.Cluster_H), 16)), |
Size => D_Entry.Size, |
Index => Current_Index - 1, |
Is_Root => False, |
Is_Dirty => False); |
if Matches then |
DEntry.L_Name := -L_Name (L_Name_First .. L_Name'Last); |
else |
DEntry.L_Name.Len := 0; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.