public void UnMount(string path)
 {
     lock (mounts)
     {
         if (mounts.Remove(path))
         {
             ManagedNode node = root.Find(path) as ManagedNode;
             node.SetAsMountNode(null);
         }
         else
         {
             throw new UnMountException("The path " + path +
                                        " is not a mount point, cannot be unmounted.");
         }
     }
 }
Esempio n. 2
0
        public INode Find(string inPath)
        {
            // First validate path.
            if (!PathHelper.ValidatePath(ref inPath))
            {
                throw new InvalidPathException("The path " + inPath + " is invalid.");
            }

            // A special case of root linking.
            if (inPath == PathHelper.Slash)
            {
                return(common.Manager.Root);
            }

            // We do processing out of lock if possible.
            string part;
            string path = PathHelper.SeperatePath(inPath, out part);

            // We process root links.
            if (path == string.Empty)
            {
                if (part == null)
                {
                    return(common.Manager.Root);
                }
                return(common.Manager.Find(part));
            }

            // We process back links.
            if (path == PathHelper.ParentLink)
            {
                // Cannot find it.
                if (common.Parent == null)
                {
                    return(null);
                }

                if (part == null)
                {
                    return(common.Parent.CurrentVersion);
                }
                else
                {
                    return(common.Parent.CurrentVersion.Find(part));
                }
            }

            lock (SyncRoot)
            {
                AssertNotDisposed();
                ManagedNode child = common.GetChild(node, path);

                // We check if child cannot be found.
                if (child == null)
                {
                    ManagedNode b = CacheBase();
                    if (b != null)
                    {
                        return(b.Find(inPath));
                    }

                    // Cannot be found.
                    return(null);
                }
                else
                {
                    // We return child if no more to search.
                    if (part == null)
                    {
                        return(child);
                    }
                    return(child.Find(part));
                }
            }
        }