// * do not move an xlink
        // * do not move between xlinks
        // * do not move a controlled item to a private path
        //   or add the private parents
        // * etc.
        int DokanOperations.MoveFile(
            string srcPath,
            string dstPath,
            bool replace,
            DokanFileInfo info)
        {
            mLog.InfoFormat(
                "*MoveFile* - [{0}] to [{1}] - replace [{2}]",
                srcPath, dstPath, replace);

            Node tree = GetRoot();

            Node parentSrc = WalkTree.Find(tree, Path.GetDirectoryName(srcPath));

            if (parentSrc == null)
            {
                return(-DokanNet.ERROR_PATH_NOT_FOUND);
            }

            Node node = WalkTree.GetChildByName(parentSrc.GetChildren(), Path.GetFileName(srcPath));

            if (node == null)
            {
                return(-DokanNet.ERROR_FILE_NOT_FOUND);
            }

            IVirtualFile virtualNode = mVirtualFiles.Get(node.GetNodeId());

            if (virtualNode != null)
            {
                mLog.ErrorFormat("We don't allow moving virtual files. [{0}]",
                                 node.GetName());

                return(-DokanNet.ERROR_ACCESS_DENIED);
            }

            Node parentDst = WalkTree.Find(tree, Path.GetDirectoryName(dstPath));

            if (parentDst == null)
            {
                return(-DokanNet.ERROR_PATH_NOT_FOUND);
            }

            if (WalkTree.GetChildByName(parentDst.GetChildren(), Path.GetFileName(dstPath)) != null)
            {
                return(-DokanNet.ERROR_ALREADY_EXISTS);
            }

            if (node.IsControlled())
            {
                mChangesTreeOperations.Move(
                    CmPath.FromWindows(srcPath), CmPath.FromWindows(dstPath));
            }

            parentSrc.DeleteChild(node);

            parentDst.AddChild(node, Path.GetFileName(dstPath));

            return(0);
        }
        static void Checkout(
            Node node,
            string path,
            ChangesTreeOperations changesTreeOperations)
        {
            changesTreeOperations.Checkout(CmPath.FromWindows(path));

            node.Checkout(3, new Codice.CM.Common.SEID("plasticdrive", false));
        }
        static int Delete(
            Node root,
            string path,
            VirtualFiles virtualFiles,
            ChangesTreeOperations changesTreeOperations)
        {
            Node parent = WalkTree.Find(root, Path.GetDirectoryName(path));

            if (parent == null)
            {
                return(-DokanNet.ERROR_PATH_NOT_FOUND);
            }

            Node node = WalkTree.GetChildByName(parent.GetChildren(), Path.GetFileName(path));

            if (node == null)
            {
                return(-DokanNet.ERROR_FILE_NOT_FOUND);
            }

            IVirtualFile virtualFile = virtualFiles.Get(node.GetNodeId());

            if (virtualFile != null)
            {
                mLog.ErrorFormat("We don't allow deleting virtual files. [{0}]",
                                 node.GetName());

                return(-DokanNet.ERROR_ACCESS_DENIED);
            }

            if (node.IsControlled())
            {
                changesTreeOperations.Delete(CmPath.FromWindows(path));
            }

            if (parent.DeleteChild(node))
            {
                return(0);
            }

            return(-DokanNet.ERROR_FILE_NOT_FOUND);
        }