If it's a small file, you could read the whole thing into a string using GLib.FileUtils.get_contents and then just grab the part you want
On Wed, Oct 7, 2015 at 11:02 AM Guillaume Poirier-Morency < guillaumepoiriermore...@gmail.com> wrote: > Le mercredi 07 octobre 2015 à 10:16 -0400, Serge Hooge a écrit : > > Hello, folks. > > > > I am currently writing a small program with Vala/ncurses and I have > > suddenly found the need to read last n lines of a constantly changing > > file for display in an ncurses window. > > > > What would be the easiest way to go about it in Vala? > > It doesn't look like GIO is an option without a giant data stream > > kludge, but I kind of need it to create and delete some files along > > the > > way. > > You can use a DataInputStream http://valadoc.org/#!api=gio-2.0/GLib.Dat > aInputStream and seek approximately to n * average bytes per line from > the end and read the following data with read_line. It should read > approximately n lines quite efficiently. > > You can trigger the operation with a FileMonitor http://valadoc.org/#!a > pi=gio-2.0/GLib.FileMonitor > <http://valadoc.org/#!api=gio-2.0/GLib.FileMonitor> > > The other approach involve a subprocess that calls tail. > > > > > Cheers, > > _______________________________________________ > > vala-list mailing list > > vala-list@gnome.org > > https://mail.gnome.org/mailman/listinfo/vala-list > -- > Guillaume Poirier-Morency <guillaumepoiriermore...@gmail.com> > > Étudiant au baccalauréat en Informatique à l'Université de Montréal > Développeur d'application web > > Mon blog: https://arteymix.github.io > Mon projet de coopérative: https://pittoresque.github.io > Clé PGP: B1AD6EA5 > _______________________________________________ > vala-list mailing list > vala-list@gnome.org > https://mail.gnome.org/mailman/listinfo/vala-list > _______________________________________________ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list