Version 0.1.3.
[guestfs-browser.git] / filetree_type.ml
index 9f2bc64..f39137e 100644 (file)
 
 open Utils
 
+(* See struct/field description in .mli file. *)
 type t = {
   view : GTree.view;
   model : GTree.tree_store;
-  hash : (int, hdata) Hashtbl.t;    (* hash from index_col -> hdata *)
+  hash : (int, hdata) Hashtbl.t;
   index_col : int GTree.column;
   mode_col : string GTree.column;
   name_col : string GTree.column;
-  size_col : int64 GTree.column;
+  size_col : string GTree.column;
   date_col : string GTree.column;
-  link_col : string GTree.column;
 }
 
-and hdata = state_t * content_t
+and hdata = {
+  mutable state : state_t;
+  content : content_t;
+  mutable visited : bool;
+  mutable hiveh : Hivex.t option;
+}
 
-(* The type of the hidden column used to implement on-demand loading.
- * All rows are classified as either nodes or leafs (eg. a "node" might
- * be a directory, or a top-level operating system, or anything else
- * which the user could open and look inside).
- *)
 and state_t =
-  | IsLeaf           (* there are no children *)
-  | NodeNotStarted   (* user has not tried to open this *)
-  | NodeLoading      (* user tried to open it, still loading *)
-  | IsNode           (* we've loaded the children of this directory *)
+  | IsLeaf
+  | NodeNotStarted
+  | NodeLoading
+  | IsNode
 
-(* The actual content of a row. *)
 and content_t =
-  | Loading                          (* special "loading ..." node *)
-  | ErrorMessage of string           (* error message node *)
-  | Info of string                   (* information node (eg. disk usage) *)
-  | Top of Slave.source              (* top level OS or volume node *)
-  | Directory of Slave.direntry      (* a directory *)
-  | File of Slave.direntry           (* a file inc. special files *)
+  | Loading
+  | ErrorMessage of string
+  | Info of string
+  | Top of Slave.source
+  | TopWinReg of Slave.source * string * string * string
+  | Directory of Slave.direntry
+  | File of Slave.direntry
+  | RegKey of Hivex.node
+  | RegValue of Hivex.value
 
 (* Store hdata into a row. *)
 let store_hdata {model = model; hash = hash; index_col = index_col} row hdata =
@@ -65,9 +67,9 @@ let get_hdata { model = model; hash = hash; index_col = index_col } row =
   with Not_found -> assert false
 
 (* Iterate over children of node, looking for matching hdata. *)
-let find_child_node_by_hdata ({ model = model } as t) row hdata =
+let find_child_node_by_content ({ model = model } as t) row c =
   let rec loop row =
-    if hdata = get_hdata t row then
+    if (get_hdata t row).content = c then
       row
     else if model#iter_next row then
       loop row
@@ -89,26 +91,31 @@ let find_child_node_by_hdata ({ model = model } as t) row hdata =
  *       \_ Directory
  *            \_ Directory
  *                 \_ Loading    <--- you are here
+ *
+ * Note this function cannot be called on registry keys.
  *)
 let rec get_pathname ({ model = model } as t) row =
   let hdata = get_hdata t row in
   let parent = model#iter_parent row in
 
   match hdata, parent with
-  | (IsLeaf, (Loading|ErrorMessage _|Info _)), Some parent ->
+  | { state=IsLeaf; content=(Loading|ErrorMessage _|Info _) }, Some parent ->
       get_pathname t parent
-  | (IsLeaf, (Loading|ErrorMessage _|Info _)), None ->
+  | { state=IsLeaf; content=(Loading|ErrorMessage _|Info _) }, None ->
       assert false
-  | (_, Directory { Slave.dent_name = name }), Some parent
-  | (_, File { Slave.dent_name = name }), Some parent ->
+  | { content=Directory { Slave.dent_name = name }}, Some parent
+  | { content=File { Slave.dent_name = name }}, Some parent ->
       let src, parent_name = get_pathname t parent in
       let path =
         if parent_name = "/" then "/" ^ name
         else parent_name ^ "/" ^ name in
       src, path
-  | (_, Top src), _ -> src, "/"
-  | (_, Directory _), None -> assert false
-  | (_, File _), None -> assert false
-  | (_, Loading), _ -> assert false
-  | (_, ErrorMessage _), _ -> assert false
-  | (_, Info _), _ -> assert false
+  | { content=Top src }, _ -> src, "/"
+  | { content=Directory _ }, None -> assert false
+  | { content=File _ }, None -> assert false
+  | { content=Loading }, _ -> assert false
+  | { content=ErrorMessage _ }, _ -> assert false
+  | { content=Info _ }, _ -> assert false
+  | { content=TopWinReg _ }, _ -> assert false
+  | { content=RegKey _ }, _ -> assert false
+  | { content=RegValue _ }, _ -> assert false