text
stringlengths
0
234
S_Idx := 0;
SName := (others => ' ');
for J in 1 .. Last loop
exit when Add_Tilde and then S_Idx >= 6;
exit when not Add_Tilde and then S_Idx = 8;
if Name.Name (J) in 'a' .. 'z' then
S_Idx := S_Idx + 1;
SName (S_Idx) := To_Upper (Name.Name (J));
elsif Is_Legal_Character (Name.Name (J)) then
S_Idx := S_Idx + 1;
SName (S_Idx) := Name.Name (J);
elsif Name.Name (J) = '.'
or else Name.Name (J) = ' '
then
-- dots that are not used as extension delimiters are invalid
-- in FAT short names and ignored in long names to short names
-- translation
Add_Tilde := True;
else
-- Any other character is translated as '_'
Add_Tilde := True;
S_Idx := S_Idx + 1;
SName (S_Idx) := '_';
end if;
end loop;
if Add_Tilde then
if S_Idx >= 6 then
SName (7 .. 8) := "~1";
else
SName (S_Idx + 1 .. S_Idx + 2) := "~1";
end if;
end if;
end To_Short_Name;
---------------
-- Inc_SName --
---------------
procedure Inc_SName (SName : in out String)
is
Idx : Natural := 0;
Num : Natural := 0;
begin
for J in reverse SName'Range loop
if Idx = 0 then
if SName (J) = ' ' then
null;
elsif SName (J) in '0' .. '9' then
Idx := J;
else
SName (SName'Last - 1 .. SName'Last) := "~1";
return;
end if;
elsif SName (J) in '0' .. '9' then
Idx := J;
elsif SName (J) = '~' then
Num := Value (SName (Idx .. SName'Last)) + 1;
-- make Idx point to '~'
Idx := J;
declare
N_Suffix : String := Natural'Image (Num);
begin
N_Suffix (N_Suffix'First) := '~';
if Idx + N_Suffix'Length - 1 > SName'Last then
SName (SName'Last - N_Suffix'Length + 1 .. SName'Last) :=
N_Suffix;
else
SName (Idx .. Idx + N_Suffix'Length - 1) := N_Suffix;
end if;
return;
Function Definition: function To_Disk_Parameter is new Ada.Unchecked_Conversion
Function Body: (Disk_Parameter_Block, FAT_Disk_Parameter);
subtype FSInfo_Block is Block (0 .. 11);
function To_FSInfo is new Ada.Unchecked_Conversion
(FSInfo_Block, FAT_FS_Info);
begin
FS.Window_Block := 16#FFFF_FFFF#;
Status := FS.Ensure_Block (0);
if Status /= OK then
return;
end if;
if FS.Window (510 .. 511) /= (16#55#, 16#AA#) then