text
stringlengths
0
234
is
subtype Entry_Data is Block (1 .. 32);
function To_Entry is new Ada.Unchecked_Conversion
(Entry_Data, FAT_Directory_Entry);
Ret : Status_Code;
Block_Off : Natural;
begin
if Current_Index = 16#FFFF# then
return No_More_Entries;
end if;
if Current_Cluster = 0 and then FS.Version = FAT16 then
if Current_Index >
Entry_Index (FS.FAT16_Root_Dir_Num_Entries)
then
return No_More_Entries;
else
Block_Off :=
Natural (FAT_File_Size (Current_Index * 32) mod
FS.Block_Size);
Current_Block :=
FS.Root_Dir_Area +
Block_Offset
(FAT_File_Size (Current_Index * 32) / FS.Block_Size);
end if;
else
Block_Off := Natural
(FAT_File_Size (Current_Index * 32) mod FS.Block_Size);
-- Check if we're on a block boundare
if Unsigned_32 (Block_Off) = 0 and then Current_Index /= 0 then
Current_Block := Current_Block + 1;
end if;
-- Check if we're on the boundary of a new cluster
if Current_Block - FS.Cluster_To_Block (Current_Cluster)
= FS.Blocks_Per_Cluster
then
-- The block we need to read is outside of the current cluster.
-- Let's move on to the next
-- Read the FAT table to determine the next cluster
Current_Cluster := FS.Get_FAT (Current_Cluster);
if Current_Cluster = 1
or else FS.Is_Last_Cluster (Current_Cluster)
then
return Internal_Error;
end if;
Current_Block := FS.Cluster_To_Block (Current_Cluster);
end if;
end if;
Ret := FS.Ensure_Block (Current_Block);
if Ret /= OK then
return Ret;
end if;
if FS.Window (Block_Off) = 0 then
-- End of entries: we stick the index here to make sure that further
-- calls to Next_Entry always end-up here
return No_More_Entries;
end if;
DEntry := To_Entry (FS.Window (Block_Off .. Block_Off + 31));
Current_Index := Current_Index + 1;
return OK;
end Next_Entry;
----------------
-- Next_Entry --
----------------
function Next_Entry
(FS : access FAT_Filesystem;
Current_Cluster : in out Cluster_Type;
Current_Block : in out Block_Offset;
Current_Index : in out Entry_Index;
DEntry : out FAT_Node) return Status_Code
is
procedure Prepend
(Name : Wide_String;
Full : in out String;
Idx : in out Natural);
-- Prepends Name to Full
-------------
-- Prepend --
-------------
procedure Prepend
(Name : Wide_String;
Full : in out String;
Idx : in out Natural)