comp.lang.ada
 help / color / mirror / Atom feed
From: Ada novice <shai.lesh@gmx.com>
Subject: cannot write to a file in Linux despite +rw permissions
Date: Fri, 18 Jan 2013 02:13:55 -0800 (PST)
Date: 2013-01-18T02:13:55-08:00	[thread overview]
Message-ID: <1d536a59-c2e6-40d8-bf1e-fa7a0b4a923a@googlegroups.com> (raw)

Hello,
      I am a newbie in Linux and I have recently installed swiftlinux, which is Debian based. I am testing my Ada codes. They run well (I have put GNAT GPL 2011 for now), except that I see that I cannot write to text files. I have issued the command "chmod -R +rw" to the parent folder but that doesn't help and neither did running GPS as root help. 

If the compilation files are created and can be "destroyed" by the GPS clean command, this means that it should not be a problem to write to a text file. I also have LaTeX installed and I have no difficulty to generate a pdf file and modify it on subsequent compilation. 

So I am a bit puzzled that I cannot write to a file as an output of an Ada program. What happens is that the file gets created, say: "hi.text" but then it stays blank. I have tried to create the file "hi.txt" before running my Ada program in GPS but that is not helping also.

Here's a small code that I'm using (this works fine on Windows with the file and its contents created):

with Ada.Float_Text_IO;
with Ada.Text_IO; use Ada.Text_IO;


procedure Test_Writing is

   X                                             : Float := 3.0;
   Y                                             : Float := 2.0;


 Output_Data_File_All                            : File_Type;


 procedure Write_Files_All (Output_File          : File_Type;
                            Out_1           : Float;
                            Out_2           : Float;
                            Prec            : Natural := 3
                            ) is

        begin
             Ada.Float_Text_IO.Put (File => Output_File, Item => Out_1, Fore => 3, Aft => Prec, Exp => 0);
             Ada.Text_IO.Put (Output_File, "   ");

             Ada.Float_Text_IO.Put (File => Output_File, Item => Out_2, Fore => 3, Aft => Prec, Exp => 0);
             Ada.Text_IO.New_Line (Output_File);

       end Write_Files_All;



       begin
            Ada.Text_IO.Put ("Put file name to write for all elements: ");
            Create (Output_Data_File_All, Out_File, Get_Line);
            Ada.Text_IO.New_Line(1);

           for I in 1 .. 3 loop
           
             Ada.Float_Text_IO.Put (Item => X, Fore => 3, Aft  => 4, Exp  => 0);
             Ada.Float_Text_IO.Put (Item => Y, Fore => 3, Aft  => 5, Exp  => 0);
             Ada.Text_IO.New_Line (1);

             --write to file
             Write_Files_All (Output_Data_File_All,
                            Out_1 => x,
                            Out_2 => y
                            );

             X := X + 1.0;
             Y := Y + 2.0;

       end loop;

    Close (Output_Data_File_All);

end Test_Writing;

Since the code compiles and runs fine in GPS, I do not understand why the file cannot be written in the above case with the X and Y values.

Guess it must be something on Linux that I am not paying attention to.


Thanks for any suggestions.
YC 



             reply	other threads:[~2013-01-18 10:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-18 10:13 Ada novice [this message]
2013-01-18 10:37 ` cannot write to a file in Linux despite +rw permissions Jacob Sparre Andersen
2013-01-18 11:15   ` Ada novice
2013-01-18 10:59 ` Brian Drummond
2013-01-18 11:19   ` Ada novice
2013-01-18 15:44     ` Ada novice
2013-01-18 23:36       ` Brian Drummond
2013-01-19  7:08         ` Ada novice
2013-01-19 10:11           ` Brian Drummond
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox