From 17e6fb64c63c33577d3085a0958f8a9bb94d99b2 Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Sun, 29 Apr 2018 11:53:40 +0200 Subject: [PATCH] Write string vectors to file --- src/alire-utils.adb | 22 ++++++++++++++++++++++ src/alire-utils.ads | 5 +++++ 2 files changed, 27 insertions(+) diff --git a/src/alire-utils.adb b/src/alire-utils.adb index 7deee4d9..48b60f6e 100644 --- a/src/alire-utils.adb +++ b/src/alire-utils.adb @@ -1,3 +1,4 @@ +with Ada.Streams.Stream_IO; with Ada.Strings.Fixed; with Ada.Strings.Maps; @@ -135,4 +136,25 @@ package body Alire.Utils is end return; end To_Native; + ----------- + -- Write -- + ----------- + + procedure Write (V : String_Vector; + Filename : Platform_Independent_Path; + Separator : String := ASCII.LF & "") + is + use Ada.Streams.Stream_IO; + F : File_Type; + begin + Create (F, Out_File, Filename); + + for Line of V loop + String'Write (Stream (F), Line); + String'Write (Stream (F), Separator); + end loop; + + Close (F); + end Write; + end Alire.Utils; diff --git a/src/alire-utils.ads b/src/alire-utils.ads index 1ce41f28..a82ba4aa 100644 --- a/src/alire-utils.ads +++ b/src/alire-utils.ads @@ -48,6 +48,11 @@ package Alire.Utils with Preelaborate is function Flatten (V : String_Vector; Separator : String := " ") return String; -- Concatenate all elements + procedure Write (V : String_Vector; + Filename : Platform_Independent_Path; + Separator : String := ASCII.LF & ""); + -- Dump contents to a given file + ----------------- -- XXX_XXX_XXX -- -----------------