Beispiel #1
0
    internal virtual void list(Filesystem.DirectoryPrx dir, bool recursive, int depth)
    {
        StringBuilder b = new StringBuilder();

        for (int i = 0; i < depth; ++i)
        {
            b.Append('\t');
        }
        string indent = b.ToString();

        NodeDesc[] contents = dir.list();

        for (int i = 0; i < contents.Length; ++i)
        {
            DirectoryPrx d = contents[i].type == NodeType.DirType
                                ? DirectoryPrxHelper.uncheckedCast(contents[i].proxy) : null;
            Console.Write(indent + contents[i].name + (d != null ? " (directory)" : " (file)"));
            if (d != null && recursive)
            {
                Console.WriteLine(":");
                list(d, true, ++depth);
            }
            else
            {
                Console.WriteLine();
            }
        }
    }
Beispiel #2
0
        // Slice createDirectory() operation.

        public override DirectoryPrx createDirectory(string name, Current c)
        {
            lock (this)
            {
                if (_destroyed)
                {
                    throw new ObjectNotExistException();
                }

                if (name.Length == 0 || _contents.ContainsKey(name))
                {
                    throw new NameInUse(name);
                }

                var d    = new DirectoryI(name, this);
                var node = c.adapter.add(d, d.id());
                _contents.Add(name, d);
                return(DirectoryPrxHelper.uncheckedCast(node));
            }
        }
Beispiel #3
0
    internal virtual void cd(string name)
    {
        if (name.Equals("/"))
        {
            while (_dirs.Count > 1)
            {
                _dirs.RemoveAt(0);
            }
            return;
        }

        if (name.Equals(".."))
        {
            if (_dirs.Count > 1)
            {
                _dirs.RemoveAt(0);
            }
            return;
        }

        DirectoryPrx dir = (DirectoryPrx)_dirs[0];
        NodeDesc     d;

        try
        {
            d = dir.find(name);
        }
        catch (NoSuchName)
        {
            Console.WriteLine("`" + name + "': no such directory");
            return;
        }
        if (d.type == NodeType.FileType)
        {
            Console.WriteLine("`" + name + "': not a directory");
            return;
        }
        _dirs.Insert(0, DirectoryPrxHelper.uncheckedCast(d.proxy));
    }