Re: open an existing file in buffer and write on it
- From: Damien Caliste <damien caliste cea fr>
- To: gtk-app-devel-list gnome org
- Subject: Re: open an existing file in buffer and write on it
- Date: Fri, 25 Jan 2013 17:02:55 +0100
Hello,
Le 25/01/2013, Rudra Banerjee <rudra banerjee aol co uk> a Ãcrit :
But is it so tough? database and all that?
For managing several bibliography files, that should be better yes.
All I want to do is to have the ability of editing an existing file.
Since directly editing the file is not recommended, this is the reason
why I want to open it as buffer!
For just handling one file, that's not necessary of course.
The idea when you want to change a file on disk is (not too big) :
- generate a buffer of the full content of the file in memory, using
GString for instance
(http://developer.gnome.org/glib/unstable/glib-Strings.html) since
they are automatically expending in size but can be used with
equivalent printf() convenient functions ;
- copy atomicaly the buffer in the file with g-file-set-contents()
http://developer.gnome.org/glib/unstable/glib-File-Utilities.html#g-file-set-contents
- delete the buffer.
Damien.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]