text
stringlengths
0
234
-- ??? 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;
Size := Size - B_Per_Cluster;
end loop;
return Ret;
end Adjust_Clusters;
-------------------------------
-- Find_Empty_Entry_Sequence --
-------------------------------
function Find_Empty_Entry_Sequence
(Parent : access FAT_Directory_Handle;
Num_Entries : Natural) return Entry_Index
is
Status : Status_Code;
D_Entry : FAT_Directory_Entry;
Sequence : Natural := 0;
Ret : Entry_Index;
Cluster : Cluster_Type := Parent.Start_Cluster;
Block : Block_Offset := Cluster_To_Block (Parent.FS.all, Cluster);
begin
Parent.Current_Index := 0;
loop
Status := Next_Entry
(Parent.FS,
Current_Cluster => Cluster,
Current_Block => Block,
Current_Index => Parent.Current_Index,
DEntry => D_Entry);
if Status /= OK then
return Null_Index;
end if;
if D_Entry.Attributes = VFAT_Directory_Entry_Attribute then
if Sequence = 0 then
-- Parent.Current_Index points to the next unread value.
-- So the just read entry is at Parent.Current_Index - 1
Ret := Parent.Current_Index - 1;
end if;
Sequence := Sequence + 1;
elsif Character'Pos (D_Entry.Filename (1)) = 16#E5# then
-- A deleted entry has been found
if Sequence >= Num_Entries then
return Ret;
else
Sequence := 0;
end if;
else
Sequence := 0;
end if;
end loop;
end Find_Empty_Entry_Sequence;
--------------------
-- Allocate_Entry --
--------------------
function Allocate_Entry
(Parent : access FAT_Directory_Handle;
Name : FAT_Name;
Attributes : FAT_Directory_Entry_Attribute;
E : out FAT_Node) return Status_Code
is
subtype Short_Name is String (1 .. 8);
subtype Extension is String (1 .. 3);
function Is_Legal_Character (C : Character) return Boolean
is (C in 'A' .. 'Z'
or else C in '0' .. '9'
or else C = '!'
or else C = '#'
or else C = '$'