text
stringlengths 0
234
|
|---|
function To_Entry is new
|
Ada.Unchecked_Conversion (Entry_Block, FAT_Directory_Entry);
|
Ent : FAT_Directory_Entry;
|
Cluster : Cluster_Type := Parent.Start_Cluster;
|
Offset : FAT_File_Size := FAT_File_Size (Value.Index) * 32;
|
Block_Off : Natural;
|
Block : Block_Offset;
|
Ret : Status_Code;
|
begin
|
if not Value.Is_Dirty then
|
return OK;
|
end if;
|
while Offset > Parent.FS.Cluster_Size loop
|
Cluster := Parent.FS.Get_FAT (Cluster);
|
Offset := Offset - Parent.FS.Cluster_Size;
|
end loop;
|
Block := Block_Offset (Offset / Parent.FS.Block_Size);
|
Block_Off := Natural (Offset mod Parent.FS.Block_Size);
|
Ret := Parent.FS.Ensure_Block
|
(Parent.FS.Cluster_To_Block (Cluster) + Block);
|
if Ret /= OK then
|
return Ret;
|
end if;
|
Ent := To_Entry (Parent.FS.Window (Block_Off .. Block_Off + 31));
|
-- For now only the size can be modified, so just apply this
|
-- modification
|
Ent.Size := Value.Size;
|
Value.Is_Dirty := False;
|
Parent.FS.Window (Block_Off .. Block_Off + 31) := To_Block (Ent);
|
Ret := Parent.FS.Write_Window;
|
return Ret;
|
end Update_Entry;
|
----------------
|
-- Root_Entry --
|
----------------
|
function Root_Entry (FS : in out FAT_Filesystem) return FAT_Node
|
is
|
Ret : FAT_Node;
|
begin
|
Ret.FS := FS'Unchecked_Access;
|
Ret.Attributes := (Subdirectory => True,
|
others => False);
|
Ret.Is_Root := True;
|
Ret.L_Name := (Name => (others => ' '),
|
Len => 0);
|
if FS.Version = FAT16 then
|
Ret.Start_Cluster := 0;
|
else
|
Ret.Start_Cluster := FS.Root_Dir_Cluster;
|
end if;
|
Ret.Index := 0;
|
return Ret;
|
end Root_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_Directory_Entry) return Status_Code
|
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 +
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.