Re: Write string to file with 3.6



2012/10/20 Baptiste Saleil <baptiste saleil gmail com>:
> Hi there.
>
> I'm trying to update my extension for 3.6
> Here is my old code :
>
> let f = Gio.file_new_for_path(file);
> let out = f.replace(null, false, Gio.FileCreateFlags.NONE, null);
> Shell.write_string_to_stream (out, content);
>
> This code work perfectly with 3.4 but not 3.6. A file is created in the
> extension folder with name ".goutputstream-XXXXXX" instead of write on file.
> Same problem with :
>
> replace_contents(content);
>
> What I'm doing wrong ?

You're not closing the stream.
Gio.File.replace() is atomic, and this is achieved with a temporary
file that it rename()-d over the old one when the stream is closed.

Giovanni


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