--- mllib/regedit.ml | 12 +----------- mllib/registry.ml | 9 +++++++++ mllib/registry.mli | 5 +++++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/mllib/regedit.ml b/mllib/regedit.ml index f49d931..dd03f5a 100644 --- a/mllib/regedit.ml +++ b/mllib/regedit.ml @@ -34,17 +34,7 @@ and regtype = let rec import_key ((g, root) : Registry.t) (path, values) = (* Create the path starting at the root node. *) - let node = - let rec loop parent = function - | [] -> parent - | x :: xs -> - let node = - match g#hivex_node_get_child parent x with - | 0L -> g#hivex_node_add_child parent x (* not found, create *) - | node -> node in - loop node xs - in - loop root path in + let node = Registry.create_path (g, root) path in (* Delete any existing values in this node. *) (* g#hivex_node_set_values ... diff --git a/mllib/registry.ml b/mllib/registry.ml index ac85b50..767092c 100644 --- a/mllib/registry.ml +++ b/mllib/registry.ml @@ -52,6 +52,15 @@ let rec get_node ((g, node) : t) = function if node = 0L then None else get_node (g, node) xs +let rec create_path ((g, parent) : t) = function + | [] -> parent + | x :: xs -> + let node = + match g#hivex_node_get_child parent x with + | 0L -> g#hivex_node_add_child parent x (* not found, create *) + | node -> node in + create_path (g, node) xs + (* Take a 7 bit ASCII string and encode it as UTF16LE. *) let encode_utf16le str = let len = String.length str in diff --git a/mllib/registry.mli b/mllib/registry.mli index 9727cd5..293fc99 100644 --- a/mllib/registry.mli +++ b/mllib/registry.mli @@ -42,6 +42,11 @@ val get_node : t -> string list -> node option It returns [Some node] of the final node if found, or [None] if not found. *) +val create_path : t -> string list -> node +(** [create_path (g, root) path] is like {!get_node} except that it + creates registry nodes as it goes along if they don't exist. + It returns the final node in the path. *) + val encode_utf16le : string -> string (** Helper: Take a 7 bit ASCII string and encode it as UTF-16LE. *) -- 2.10.2