nightshade

The nightshade programming language, compiler and tools (WIP)
Log | Files | Refs | README

utils.adb (790B)


      1 with Ada.Text_IO;                   use Ada.Text_IO;
      2 with Ada.Strings.Unbounded;         use Ada.Strings.Unbounded;
      3 with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO;
      4 
      5 package body Utils is
      6    function Load_Contents (File_Name : String) return String is
      7       F       : File_Type;
      8       Content : Unbounded_String := Null_Unbounded_String;
      9    begin
     10       Open (F, In_File, File_Name);
     11 
     12       while not End_Of_File (F) loop
     13          declare
     14             Line : Unbounded_String;
     15          begin
     16             Get_Line (F, Line);
     17             Append (Content, Line);
     18          end;
     19          if not End_Of_file (F) then
     20             Append (Content, ASCII.LF);
     21          end if;
     22       end loop;
     23       close (F);
     24 
     25       return To_String (Content);
     26 
     27    end Load_Contents;
     28 end Utils;