SimpleNode createNode(String path, [ bool init = true ])

Creates a node at path. If a node already exists at this path, an exception is thrown. If init is false, onCreated() is not called.

Source

SimpleNode createNode(String path, [bool init = true]) {
  Path p = new Path(path);
  LocalNode existing = nodes[path];

  if (existing != null) {
    if (existing is SimpleNode) {
      if (existing._stub != true) {
        throw new Exception("Node at ${path} already exists.");
      } else {
        existing._stub = false;
      }
    } else {
      throw new Exception("Node at ${path} already exists.");
    }
  }

  SimpleNode node = existing == null ? new SimpleNode(path, this) : existing;
  nodes[path] = node;

  if (init) {
    node.onCreated();
  }

  SimpleNode pnode;

  if (p.parentPath != "") {
    pnode = getNode(p.parentPath);
  }

  if (pnode != null) {
    pnode.children[p.name] = node;
    pnode.onChildAdded(p.name, node);
    pnode.updateList(p.name);
  }

  return node;
}