File: ada

package info (click to toggle)
ruby-rouge 4.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,844 kB
  • sloc: ruby: 38,489; sed: 2,071; perl: 152; makefile: 8
file content (26 lines) | stat: -rw-r--r-- 641 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
with Ada.Directories;
with Ada.Direct_IO;
with Ada.Text_IO;

procedure Extra_IO.Read_File (Name : String) is

   package Dirs renames Ada.Directories;
   package Text_IO renames Ada.Text_IO;

   -- Get the size of the file for a new string.
   Size : Natural := Natural (Dirs.Size (Name));
   subtype File_String is String (1 .. Size);

   -- Instantiate Direct_IO for our file type.
   package FIO is new Ada.Direct_IO (File_String);

   File     : FIO.File_Type;
   Contents : File_String;

begin
   FIO.Open (File, FIO.In_File, Name);
   FIO.Read (File, Contents);
   FIO.Close (File);

   Text_IO.Put (Contents);
end Extra_IO.Read_File;