text
stringlengths
0
234
SName (SName'Last - N_Suffix'Length + 1 .. SName'Last) :=
N_Suffix;
else
SName (Idx .. Idx + N_Suffix'Length - 1) := N_Suffix;
end if;
return;
Function Definition: function To_Disk_Parameter is new Ada.Unchecked_Conversion
Function Body: (Disk_Parameter_Block, FAT_Disk_Parameter);
subtype FSInfo_Block is Block (0 .. 11);
function To_FSInfo is new Ada.Unchecked_Conversion
(FSInfo_Block, FAT_FS_Info);
begin
FS.Window_Block := 16#FFFF_FFFF#;
Status := FS.Ensure_Block (0);
if Status /= OK then
return;
end if;
if FS.Window (510 .. 511) /= (16#55#, 16#AA#) then
Status := No_Filesystem;
return;
end if;
FS.Disk_Parameters :=
To_Disk_Parameter (FS.Window (0 .. 91));
if FS.Version = FAT32 then
Status :=
FS.Ensure_Block (Block_Offset (FS.FSInfo_Block_Number));
if Status /= OK then
return;
end if;
-- Check the generic FAT block signature
if FS.Window (510 .. 511) /= (16#55#, 16#AA#) then
Status := No_Filesystem;
return;
end if;
FS.FSInfo :=
To_FSInfo (FS.Window (16#1E4# .. 16#1EF#));
FS.FSInfo_Changed := False;
end if;
declare
FAT_Size_In_Block : constant Unsigned_32 :=
FS.FAT_Table_Size_In_Blocks *
Unsigned_32 (FS.Number_Of_FATs);
Root_Dir_Size : Block_Offset;
begin
FS.FAT_Addr := Block_Offset (FS.Reserved_Blocks);
FS.Data_Area := FS.FAT_Addr + Block_Offset (FAT_Size_In_Block);
if FS.Version = FAT16 then
-- Add space for the root directory
FS.Root_Dir_Area := FS.Data_Area;
Root_Dir_Size :=
(Block_Offset (FS.FAT16_Root_Dir_Num_Entries) * 32 +
Block_Offset (FS.Block_Size) - 1) /
Block_Offset (FS.Block_Size);
-- Align on clusters
Root_Dir_Size :=
((Root_Dir_Size + FS.Blocks_Per_Cluster - 1) /
FS.Blocks_Per_Cluster) *
FS.Blocks_Per_Cluster;
FS.Data_Area := FS.Data_Area + Root_Dir_Size;
end if;
FS.Num_Clusters :=
Cluster_Type
((FS.Total_Number_Of_Blocks - Unsigned_32 (FS.Data_Area)) /
Unsigned_32 (FS.Blocks_Per_Cluster));
Function Definition: procedure List (Path : String);
Function Body: ----------
-- List --
----------
procedure List (Path : String) is
DD : Directory_Descriptor;
Status : Status_Code;
First : Boolean := True;
begin
Status := Open (DD, Path);
if Status /= OK then
Put ("Cannot open directory '" & Path & "': " & Status'Img);
return;
end if;
if Recursive then
Put_Line (Path & ":");
end if;