[augeas-devel] saving edited files in another directory

David Lutterkort lutter at redhat.com
Thu May 13 15:40:21 UTC 2010


On Thu, 2010-05-13 at 08:48 -0400, Christopher Harvey wrote:
> I took a look at the relevant code in augeas. Looks like all writes take
> place in put_lens. put_lens is divided over put_del, put_store,
> put_concat, put_subtree, etc..
> All of those functions output to a file pointer directly. As far as I
> can tell the only way to implement aug_lens_put without major surgery to
> create string based implementations of those functions would be to have
> the state object tell the functions, "don't output to the file! output
> to this new string pointer!".
> Would that change be ok to add to augeas? Is there an easier way?

You can do what is done in lens_put in builtin.c: pass in a memstream.
On glibc systems, that's a FILE* backed by a buffer in memory; on other
systems, it involves IO into a temporary file (see init_memstream and
close_memstream in internal.c)

I wouldn't object to a patch that changes the functions in put.c, though
it's going to be a biggish change, and not directly needed for what you
want to accomplish.

David





More information about the augeas-devel mailing list