text stringlengths 0 234 |
|---|
is |
Val : Unsigned_16; |
begin |
for J in reverse Name'Range loop |
Val := Wide_Character'Pos (Name (J)); |
if Val /= 16#FFFF# |
and then Val /= 0 |
then |
Idx := Idx - 1; |
exit when Idx not in Full'Range; |
if Val < 255 then |
Full (Idx) := Character'Val (Val); |
elsif Val = 16#F029# then |
-- Path ends with a '.' |
Full (Idx) := '.'; |
elsif Val = 16#F028# then |
-- Path ends with a ' ' |
Full (Idx) := ' '; |
else |
Full (Idx) := '?'; |
end if; |
end if; |
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; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.