Ejemplo 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]);
        }
    }
Ejemplo n.º 2
0
    internal virtual void write(IList args)
    {
        DirectoryPrx dir  = (DirectoryPrx)_dirs[0];
        string       name = (string)args[0];

        args.RemoveAt(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 = new string[args.Count];
        args.CopyTo(l, 0);
        try
        {
            f.write(l);
        }
        catch (GenericError ex)
        {
            Console.WriteLine("`" + name + "': cannot write to file: " + ex.reason);
        }
    }
Ejemplo n.º 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);
                }
            }
        }
    }
Ejemplo n.º 4
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));
    }