]> git.ipfire.org Git - thirdparty/systemd.git/commit
edit-util: introduce EditFileContext
authorMike Yuan <me@yhndnzj.com>
Sat, 25 Feb 2023 13:02:17 +0000 (21:02 +0800)
committerMike Yuan <me@yhndnzj.com>
Fri, 10 Mar 2023 18:01:00 +0000 (02:01 +0800)
commit9a11b4f953f8fdd68aa407a4e4f31670fa789e7c
tree8472445483f82aee5500d8ade4ac1cc32cbed081
parentfa2413dd57bb594b846ee4cfb97d338e59ec5639
edit-util: introduce EditFileContext

This is a rather large change which moves
the add and install logic into edit-util.

We store an EditFile array and the number of
elements, along with the edit markers used in
temporary files and whether to remove the parent
directories of the target files if they're empty
in an EditFileContext object.

Call edit_files_add() to add an file to edit,
and do_edit_files_and_install() to do the actual
editing (through create_edit_temp_file(),
run_editor() and trim_edit_markers()).
After that, edit_file_context_done() can be used
to destroy the object.
src/shared/edit-util.c
src/shared/edit-util.h
src/systemctl/systemctl-edit.c