text
stringlengths 0
234
|
|---|
end if;
|
if Idx < Path'Last then
|
-- Intermediate entry: needs to be a directory
|
if not Is_Subdirectory (DEntry) then
|
return No_Such_Path;
|
end if;
|
end if;
|
end loop;
|
return OK;
|
end Find;
|
------------------
|
-- Update_Entry --
|
------------------
|
function Update_Entry
|
(Parent : FAT_Node;
|
Value : in out FAT_Node) return Status_Code
|
is
|
subtype Entry_Block is Block (1 .. 32);
|
function To_Block is new
|
Ada.Unchecked_Conversion (FAT_Directory_Entry, Entry_Block);
|
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
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.