separate (Tar)
procedure Read (Files : Name := "?";
                Archive : Name := Tar.Tape;
                Record_Size : Positive := Tar.Tblock;
                Records_Per_Block : Positive := 8;
                Swap_Bytes : Boolean := False) is

    Buffer : System.Byte_String (1 .. Record_Size);
    Source_File : Block_Buffer.Buffer_Type;
    Target_File : Dio.File_Type;
    File_Bytes : Natural;

    procedure Open (Rational_Name : String) is
    begin
        Open_Out_File (File => Target_File, Name => Rational_Name);
    exception
        when others =>
            null;
    end Open;

    procedure Write (Data : System.Byte_String) is
    begin
        Dio.Write (Target_File, Data);
    exception
        when others =>
            null;
    end Write;

    procedure Close is
    begin
        Dio.Close (Target_File);
    exception
        when others =>
            null;
    end Close;

    procedure Read_File (Total_Bytes : Natural; Do_Process : Boolean) is
        Bytes_Left : Natural := Total_Bytes;
    begin
        while Bytes_Left > 0 loop
            Block_Buffer.Read (Source_File, Buffer);
            if Bytes_Left > Buffer'Length then
                if Do_Process then
                    Write (Buffer);
                end if;
                Bytes_Left := Bytes_Left - Buffer'Length;
            else
                if Do_Process then
                    Write (Buffer (1 .. Bytes_Left));
                end if;
                Bytes_Left := 0;
            end if;
        end loop;
    end Read_File;

begin
    Block_Buffer.Open (Source_File, Dio.In_File, Archive,
                       Record_Size, Records_Per_Block, Swap_Bytes);
    loop
        Block_Buffer.Read (Source_File, Buffer);
        exit when File_End (Buffer);
        File_Bytes := File_Byte_Count (Buffer);

        if Naming.Matches (File_Name (Buffer), Files) then
            Put_Line (File_Name (Buffer) & " => " &
                      Naming.To_Rational_Name (File_Name (Buffer)) & ";" &
                      Natural'Image (File_Bytes) & " bytes");
            if File_Bytes > 0 then
                Open (Naming.To_Rational_Name (File_Name (Buffer)));
                Read_File (File_Bytes, Do_Process => True);
                Close;
            else
                Put_Line ("directory '" & File_Name (Buffer) & "' ignored.");
            end if;
        else
            Read_File (File_Bytes, Do_Process => False);
        end if;
    end loop;
    Block_Buffer.Close (Source_File);
exception
    when others =>
        Block_Buffer.Close (Source_File);
        raise;
end Read;