How can I read the whole file content in a string in Ada?

2

I have to read a file in an Ada program and get the file content in some string.

Any tips on how to do that?

Iorek Byrnison 2013-02-12 21:40:09

1 answer

2

You can use the Ada Util library for that.

The @@Read_File@@ procedure is here for that:

/// with Ada.Strings.Unbounded; with Util.Files; ... Content : Ada.Strings.Unbounded.Unbounded_String; ... Util.Files.Read_File (Path => "file.txt", Into => Content); ///

Stephane Carrez 2013-02-12 21:44:48

  • Syntax for headers
  • !!!! Header 1 # Header 1 = Header 1 =
  • !!! Header 2 ## Header 2 == Header 2 ==
  • !! Header 3 ### Header 3 === Header 3 ===
  • ! Header 4 #### Header 4 ==== Header 4 ====
  • Text style syntax
  • __Bold item__ ''Italic item'' **Bold item** __Italic item__ '''Bold item''' ''Italic item''
  • @@Inline code item@@ `Inline code item`
  • --Strike item-- ++Underline item++ <s>Strike item</s> <u>Underline item</u> <ins>Inserted</ins> <del>Deleted</del>
  • Syntax for lists
  • * Bullet list * Bullet list
  • # Numbered list 1. Numbered list
  • /// <pre>
  • verbatim code block
  • /// ``` </pre>
  • Links and images
  • [Link label | Link URL] [[Link URL | Link label ]] [Link label](Link URL)
  • ((Image link | Image label)) [[Image:Image link | Image label ]] {{Image link | Image label }} ![Link label](Image:Image link)