text stringlengths 0 234 |
|---|
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 |
-- ??? Do nothing for now |
return OK; |
end if; |
loop |
Next := Ent.FS.Get_FAT (Current); |
if Size > B_Per_Cluster then |
-- Current cluster is fully used |
Size := Size - B_Per_Cluster; |
elsif Size > 0 or else Current = Ent.Start_Cluster then |
-- Partially used cluster, but the last one |
Size := 0; |
if Next /= LAST_CLUSTER_VALUE then |
Ret := Ent.FS.Set_FAT (Current, LAST_CLUSTER_VALUE); |
end if; |
else |
-- We don't need more clusters |
Ret := Ent.FS.Set_FAT (Current, FREE_CLUSTER_VALUE); |
end if; |
exit when Ret /= OK; |
exit when Ent.FS.Is_Last_Cluster (Next); |
Current := Next; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.