[Vala] Fwd: I need help writing some function...



Whoops, forgot the mailing list.

---------- Forwarded message ----------
From: Reuben Dunnington <reuben yorba org>
Date: Tue, Aug 4, 2009 at 1:53 PM
Subject: Re: [Vala] I need help writing some function...
To: Arkadi Viner <arkashkin gmail com>


Hi,

The "append_to" method is not a static method; you must use it on an
instance of GLib.File. You want to be calling "append_to" like this:

   FileOutputStream file_stream = file.append_to(FileCreateFlags.NONE,
null);

You might also notice that, compared to your old code, this call doesn't
have another parameter. Check out valadoc.org, it should help you figure out
which functions are members of the namespace vs members of classes.

Reuben

On Tue, Aug 4, 2009 at 1:02 PM, Arkadi Viner <arkashkin gmail com> wrote:

Hello.
I am trying to write some function that would append a line to a text file.

 public static bool addLineToFile(string file_path, string line) {
   var file = File.new_for_path (file_path);
   if (!file.query_exists (null)){
       stderr.printf ("File '%s' doesn't exist.\n", file.get_path ());
       return false;
   }
   FileOutputStream file_stream =
GLib.File.append_to(file,FileCreateFlags.NONE,null,null);

///////////////////TO BE CONTINUED...////////////////////////

   return true;
}

I know that the function is not finished yet, but why it doesn't compile?
If some one could give some sample code to do this function it will be
great
because I can't find any good example
on the internet...

Thank you very much.

_______________________________________________
Vala-list mailing list
Vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]