Skip to content

Instantly share code, notes, and snippets.

@charlie5
Created January 19, 2017 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save charlie5/a3855c1ffdcd6cafce1ea87cb671b345 to your computer and use it in GitHub Desktop.
Save charlie5/a3855c1ffdcd6cafce1ea87cb671b345 to your computer and use it in GitHub Desktop.
declare
File_Size : Ada.Directories.File_Size := Ada.Directories.Size ("your_file");
Record_Bytes : Integer := Your_Record'Size * 8;
Num_Records : Integer := File_Size / Record_Bytes;
First : Integer := Num_Records - 4
File : ada.streams.stream_io.file_type;
Stream : ada.streams.stream_io.Stream_Access;
Values : array (1..4) of Your_Record;
begin
ada.streams.stream_io.open (File, in_File, "your_file");
ada.streams.stream_io.set_Index (File, First * Record_Bytes);
Stream := ada.streams.stream_io.stream (File);
your_record'Read (Stream, Values (1));
your_record'Read (Stream, Values (2));
your_record'Read (Stream, Values (3));
your_record'Read (Stream, Values (4));
ada.streams.stream_io.close (File);
end;
@sparre
Copy link

sparre commented Jan 19, 2017

Why not use Ada.Direct_IO for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment