コード例 #1
0
    // Recursively print the contents of directory "dir" in tree fashion.
    // For files, show the contents of each file. The "depth"
    // parameter is the current nesting level (for indentation).

    static void listRecursive(DirectoryPrx dir, int depth)
    {
        var indent = new string('\t', ++depth);

        NodePrx[] contents = dir.list();

        foreach (var node in contents)
        {
            var subdir = DirectoryPrxHelper.checkedCast(node);
            var file   = FilePrxHelper.uncheckedCast(node);
            Console.WriteLine(indent + node.name() + (subdir != null ? " (directory):" : " (file):"));
            if (subdir != null)
            {
                listRecursive(subdir, depth);
            }
            else
            {
                var text = file.read();
                for (int j = 0; j < text.Length; ++j)
                {
                    Console.WriteLine(indent + "\t" + text[j]);
                }
            }
        }
    }
コード例 #2
0
ファイル: Client.cs プロジェクト: RonsonNamek/ice-demos
    // Recursively print the contents of directory "dir" in tree fashion.
    // For files, show the contents of each file. The "depth"
    // parameter is the current nesting level (for indentation).

    static void listRecursive(DirectoryPrx dir, int depth)
    {
        string indent = new string('\t', ++depth);

        NodePrx[] contents = dir.list();

        foreach(NodePrx node in contents)
        {
            DirectoryPrx subdir = DirectoryPrxHelper.checkedCast(node);
            FilePrx file = FilePrxHelper.uncheckedCast(node);
            Console.WriteLine(indent + node.name() + (subdir != null ? " (directory):" : " (file):"));
            if(subdir != null)
            {
                listRecursive(subdir, depth);
            }
            else
            {
                string[] text = file.read();
                for(int j = 0; j < text.Length; ++j)
                {
                    Console.WriteLine(indent + "\t" + text[j]);
                }
            }
        }
    }
コード例 #3
0
    internal virtual void destroy(IList names)
    {
        DirectoryPrx dir = (DirectoryPrx)_dirs[0];

        foreach (string name in names)
        {
            if (name.Equals("*"))
            {
                NodeDesc[] nodes = dir.list();
                for (int j = 0; j < nodes.Length; ++j)
                {
                    try
                    {
                        nodes[j].proxy.destroy();
                    }
                    catch (PermissionDenied ex)
                    {
                        Console.WriteLine("cannot remove `" + nodes[j].name + "': " + ex.reason);
                    }
                }
                return;
            }
            else
            {
                NodeDesc d;
                try
                {
                    d = dir.find(name);
                }
                catch (NoSuchName)
                {
                    Console.WriteLine("`" + name + "': no such file or directory");
                    return;
                }
                try
                {
                    d.proxy.destroy();
                }
                catch (PermissionDenied ex)
                {
                    Console.WriteLine("cannot remove `" + name + "': " + ex.reason);
                }
            }
        }
    }