text stringlengths 0 234 |
|---|
Bytes : Entry_Data; |
procedure To_Short_Name |
(Name : FAT_Name; |
SName : out Short_Name; |
Ext : out Extension); |
-- Translates a long name into short 8.3 name |
-- If the long name is mixed or lower case. then 8.3 will be uppercased |
-- If the long name contains characters not allowed in an 8.3 name, then |
-- the name is stripped of invalid characters such as space and extra |
-- periods. Other unknown characters are changed to underscores. |
-- The stripped name is then truncated, followed by a ~1. Inc_SName |
-- below will increase the digit number in case there's overloaded 8.3 |
-- names. |
-- If the long name is longer than 8.3, then ~1 suffix will also be |
-- used. |
function To_Upper (C : Character) return Character is |
(if C in 'a' .. 'z' |
then Character'Val |
(Character'Pos (C) + Character'Pos ('A') - Character'Pos ('a')) |
else C); |
function Value (S : String) return Natural; |
-- For a positive int represented in S, returns its value |
procedure Inc_SName (SName : in out String); |
-- Increment the suffix of the short FAT name |
-- e.g.: |
-- ABCDEFGH => ABCDEF~1 |
-- ABC => ABC~1 |
-- ABC~9 => ABC~10 |
-- ABCDEF~9 => ABCDE~10 |
procedure To_WString |
(S : FAT_Name; |
Idx : in out Natural; |
WS : in out Wide_String); |
-- Dumps S (Idx .. Idx + WS'Length - 1) into WS and increments Idx |
----------- |
-- Value -- |
----------- |
function Value (S : String) return Natural |
is |
Val : constant String := Trim (S); |
Digit : Natural; |
Ret : Natural := 0; |
begin |
for J in Val'Range loop |
Digit := Character'Pos (Val (J)) - Character'Pos ('0'); |
Ret := Ret * 10 + Digit; |
end loop; |
return Ret; |
end Value; |
------------------- |
-- To_Short_Name -- |
------------------- |
procedure To_Short_Name |
(Name : FAT_Name; |
SName : out Short_Name; |
Ext : out Extension) |
is |
S_Idx : Natural := 0; |
Add_Tilde : Boolean := False; |
Last : Natural := Name.Len; |
begin |
-- Copy the file extension |
Ext := (others => ' '); |
for J in reverse 1 .. Name.Len loop |
if Name.Name (J) = '.' then |
if J = Name.Len then |
-- Take care of names ending with a '.' (e.g. no extension, |
-- the final '.' is part of the basename) |
Last := J; |
Ext := (others => ' '); |
else |
Last := J - 1; |
S_Idx := Ext'First; |
for K in J + 1 .. Name.Len loop |
Ext (S_Idx) := To_Upper (Name.Name (K)); |
S_Idx := S_Idx + 1; |
-- In case the extension is more than 3 characters, we |
-- keep the first 3 ones. |
exit when S_Idx > Ext'Last; |
end loop; |
end if; |
exit; |
end if; |
end loop; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.