Exemplo n.º 1
0
    internal virtual void cat(string name)
    {
        DirectoryPrx dir = (DirectoryPrx)_dirs[0];
        NodeDesc     d;

        try
        {
            d = dir.find(name);
        }
        catch (NoSuchName)
        {
            Console.WriteLine("`" + name + "': no such file");
            return;
        }
        if (d.type == NodeType.DirType)
        {
            Console.WriteLine("`" + name + "': not a file");
            return;
        }
        FilePrx f = FilePrxHelper.uncheckedCast(d.proxy);

        string[] l = f.read();
        for (int i = 0; i < l.Length; ++i)
        {
            Console.WriteLine(l[i]);
        }
    }
Exemplo n.º 2
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)
    {
        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]);
                }
            }
        }
    }