text
stringlengths
0
234
if -Long_Name (Ent) = "." then
null;
elsif -Long_Name (Ent) = ".." then
Parent := Ent;
elsif not Recursive then
return Non_Empty_Directory;
else
if Ent.Attributes.Subdirectory then
Ret := Delete_Subdir (Ent, True);
else
Ret := Delete_Entry (Dir, Ent);
end if;
if Ret /= OK then
Close (Handle.all);
return Ret;
end if;
end if;
end loop;
Close (Handle.all);
-- Free the clusters associated to the subdirectory
Ret := Delete_Entry (Parent, Dir);
if Ret /= OK then
return Ret;
end if;
return Ret;
end Delete_Subdir;
------------------
-- Delete_Entry --
------------------
function Delete_Entry
(Dir : FAT_Node;
Ent : FAT_Node) return Status_Code
is
Current : Cluster_Type := Ent.Start_Cluster;
Handle : FAT_Directory_Handle_Access;
Next : Cluster_Type;
Child_Ent : FAT_Node;
Ret : Status_Code;
Block_Off : Natural;
begin
-- Mark the entry's cluster chain as available
loop
Next := Ent.FS.Get_FAT (Current);
Ret := Ent.FS.Set_FAT (Current, FREE_CLUSTER_VALUE);
exit when Ret /= OK;
exit when Ent.FS.Is_Last_Cluster (Next);
Current := Next;
end loop;
-- Mark the parent's entry as deleted
Ret := Dir.FAT_Open (Handle);
if Ret /= OK then
return Ret;
end if;
while Read (Handle.all, Child_Ent) = OK loop
if Long_Name (Child_Ent) = Long_Name (Ent) then
Block_Off := Natural
((FAT_File_Size (Handle.Current_Index - 1) * 32)
mod Dir.FS.Block_Size);
-- Mark the entry as deleted: first basename character set to
-- 16#E5#
Handle.FS.Window (Block_Off) := 16#E5#;
Ret := Handle.FS.Write_Window;
exit;
end if;
end loop;
Close (Handle.all);
return Ret;
end Delete_Entry;
---------------------
-- Adjust_Clusters --
---------------------
function Adjust_Clusters (Ent : FAT_Node) return Status_Code
is
B_Per_Cluster : constant FAT_File_Size :=
FAT_File_Size (Ent.FS.Blocks_Per_Cluster) *
Ent.FS.Block_Size;
Size : FAT_File_Size := Ent.Size;
Current : Cluster_Type := Ent.Start_Cluster;
Next : Cluster_Type;
Ret : Status_Code := OK;
begin
if Ent.Attributes.Subdirectory then