text
stringlengths
0
234
Function Definition: function To_Data is new Ada.Unchecked_Conversion
Function Body: (FAT_Directory_Entry, Entry_Data);
function To_Data is new Ada.Unchecked_Conversion
(VFAT_Directory_Entry, Entry_Data);
function Find_Empty_Entry_Sequence
(Parent : access FAT_Directory_Handle;
Num_Entries : Natural) return Entry_Index;
-- Finds a sequence of deleted entries that can fit Num_Entries.
-- Returns the first entry of this sequence
--------------
-- Set_Size --
--------------
procedure Set_Size
(E : in out FAT_Node;
Size : FAT_File_Size)
is
begin
if E.Size /= Size then
E.Size := Size;
E.Is_Dirty := True;
end if;
end Set_Size;
----------
-- Find --
----------
function Find
(Parent : FAT_Node;
Filename : FAT_Name;
DEntry : out FAT_Node) return Status_Code
is
-- We use a copy of the handle, so as not to touch the state of initial
-- handle
Status : Status_Code;
Cluster : Cluster_Type := Parent.Start_Cluster;
Block : Block_Offset := Parent.FS.Cluster_To_Block (Cluster);
Index : Entry_Index := 0;
begin
loop
Status := Next_Entry
(FS => Parent.FS,
Current_Cluster => Cluster,
Current_Block => Block,
Current_Index => Index,
DEntry => DEntry);
if Status /= OK then
return No_Such_File;
end if;
if Long_Name (DEntry) = Filename or else
(DEntry.L_Name.Len = 0 and then Short_Name (DEntry) = Filename)
then
return OK;
end if;
end loop;
end Find;
----------
-- Find --
----------
function Find
(FS : in out FAT_Filesystem;
Path : String;
DEntry : out FAT_Node) return Status_Code
is
Status : Status_Code;
Idx : Natural; -- Idx is used to walk through the Path
Token : FAT_Name;
begin
DEntry := Root_Entry (FS);
-- Looping through the Path. We start at 2 as we ignore the initial '/'
Idx := Path'First + 1;
while Idx <= Path'Last loop
Token.Len := 0;
for J in Idx .. Path'Last loop
if Path (J) = '/' then
exit;
end if;
Token.Len := Token.Len + 1;
Token.Name (Token.Len) := Path (J);
end loop;
Idx := Idx + Token.Len + 1;
Status := Find (DEntry, Token, DEntry);
if Status /= OK then
return No_Such_File;