Пример #1
0
        public void ShowDirectories()
        {
            Console.WriteLine("\n" + new string('-', 53) + "Directories" + new string('-', 53) + "\n");

            foreach (var d in DirectoryI.GetDirectories())
            {
                Console.WriteLine("Directory: {0,-35}\tTime: {1}\t\tAtr: {2}", d.Name, d.CreationTime, d.Attributes);
            }
        }
Пример #2
0
        public void ShowFiles()
        {
            Console.WriteLine("\n" + new string('-', 56) + "Files" + new string('-', 56) + "\n");

            foreach (var file in DirectoryI.GetFiles())
            {
                Console.WriteLine("File: {0,-40}\tTime: {1}\t\tAtr: {2}", file.Name, file.CreationTime, file.Attributes);
            }
        }
Пример #3
0
    // DirectoryI constructor
    public DirectoryI(Ice.Communicator communicator, string name, DirectoryI parent)
    {
        _name = name;
        _parent = parent;

        //
        // Create an identity. The root directory has the fixed identity "RootDir"
        //
        _id = new Ice.Identity();
        _id.name = _parent != null ? System.Guid.NewGuid().ToString() : "RootDir";
    }
Пример #4
0
    // DirectoryI constructor
    public DirectoryI(string name, DirectoryI parent)
    {
        _name   = name;
        _parent = parent;

        //
        // Create an identity. The root directory has the fixed identity "RootDir"
        //
        _id      = new Ice.Identity();
        _id.name = _parent != null?System.Guid.NewGuid().ToString() : "RootDir";
    }
Пример #5
0
    // FileI constructor
    public FileI(Ice.Communicator communicator, string name, DirectoryI parent)
    {
        _name = name;
        _parent = parent;

        Debug.Assert(_parent != null);

        //
        // Create an identity
        //
        _id = new Ice.Identity();
        _id.name = System.Guid.NewGuid().ToString();
    }
Пример #6
0
    // FileI constructor

    public FileI(Ice.Communicator communicator, string name, DirectoryI parent)
    {
        _name   = name;
        _parent = parent;

        Debug.Assert(_parent != null);

        //
        // Create an identity
        //
        _id      = new Ice.Identity();
        _id.name = System.Guid.NewGuid().ToString();
    }
Пример #7
0
    public static int Main(string[] args)
    {
        int status = 0;

        try
        {
            //
            // using statement - communicator is automatically destroyed
            // at the end of this statement
            //
            using (var communicator = Ice.Util.initialize(ref args))
            {
                //
                // Destroy the communicator on Ctrl+C or Ctrl+Break
                //
                Console.CancelKeyPress += (sender, eventArgs) => communicator.destroy();

                //
                // Create an object adapter
                //
                var adapter = communicator.createObjectAdapterWithEndpoints(
                    "LifecycleFilesystem", "default -h localhost -p 10000");

                //
                // Create the root directory.
                //
                var root = new DirectoryI();
                var id   = new Ice.Identity();
                id.name = "RootDir";
                adapter.add(root, id);

                //
                // All objects are created, allow client requests now.
                //
                adapter.activate();

                //
                // Wait until we are done.
                //
                communicator.waitForShutdown();
            }
        }
        catch (Exception ex)
        {
            Console.Error.WriteLine(ex);
            status = 1;
        }

        return(status);
    }
Пример #8
0
        public DirMessage(string path)
        {
            try
            {
                Path = path;

                if (Path == "<drives>")
                {
                    Path = "";
                    var drives = DriveInfo.GetDrives();
                    int count  = 0;
                    for (int i = 0; i < drives.Length; i++)
                    {
                        if (drives[i].IsReady)
                        {
                            count++;
                        }
                    }
                    Drives = new DriveI[count];
                    for (int i = 0, id = 0; i < Drives.Length; i++)
                    {
                        if (drives[i].IsReady)
                        {
                            Drives[id] = new DriveI(drives[i]);
                            id++;
                        }
                    }
                    return;
                }

                DirectoryInfo dir  = new DirectoryInfo(Path);
                var           dirs = dir.GetDirectories();
                Directories = new DirectoryI[dirs.Length];
                for (int i = 0; i < Directories.Length; i++)
                {
                    Directories[i] = new DirectoryI(dirs[i]);
                }

                var files = dir.GetFiles();
                Files = new FileI[files.Length];
                for (int i = 0; i < Files.Length; i++)
                {
                    Files[i] = new FileI(files[i]);
                }
            }
            catch (Exception e)
            {
                Path = "<Error>\n" + e.Message;
            }
        }
Пример #9
0
        public DirectoryControll(DirectoryI info)
        {
            InitializeComponent();

            if (info.Attributes.HasFlag(FileAttributes.Hidden))
            {
                FolderIcon.Opacity = 0.5;
            }
            else
            {
                FolderIcon.Opacity = 1;
            }

            FullName          = info.FullName;
            NameLabel.Content = info.Name;
        }
Пример #10
0
        public override int run(string[] args)
        {
            //
            // Terminate cleanly on receipt of a signal.
            //
            shutdownOnInterrupt();

            //
            // Create an object adapter
            //
            var adapter = communicator().createObjectAdapterWithEndpoints(
                "LifecycleFilesystem", "default -h localhost -p 10000");

            //
            // Create the root directory.
            //
            var root = new DirectoryI();
            var id   = new Ice.Identity();

            id.name = "RootDir";
            adapter.add(root, id);

            //
            // All objects are created, allow client requests now.
            //
            adapter.activate();

            //
            // Wait until we are done.
            //
            communicator().waitForShutdown();
            if (interrupted())
            {
                Console.Error.WriteLine(appName() + ": received signal, shutting down");
            }

            return(0);
        }
Пример #11
0
        public override int run(string[] args)
        {
            //
            // Terminate cleanly on receipt of a signal.
            //
            shutdownOnInterrupt();

            //
            // Create an object adapter
            //
            Ice.ObjectAdapter adapter = communicator().createObjectAdapterWithEndpoints(
                "LifecycleFilesystem", "default -h localhost -p 10000");

            //
            // Create the root directory.
            //
            DirectoryI root = new DirectoryI();
            Ice.Identity id = new Ice.Identity();
            id.name = "RootDir";
            adapter.add(root, id);

            //
            // All objects are created, allow client requests now.
            //
            adapter.activate();

            //
            // Wait until we are done.
            //
            communicator().waitForShutdown();
            if(interrupted())
            {
                System.Console.Error.WriteLine(appName() + ": received signal, shutting down");
            }

            return 0;
        }
Пример #12
0
    private static int run(Ice.Communicator communicator)
    {
        //
        // Create an object adapter.
        //
        var adapter =
            communicator.createObjectAdapterWithEndpoints("SimpleFilesystem", "default -h localhost -p 10000");

        //
        // Create the root directory (with name "/" and no parent)
        //
        var root = new DirectoryI("/", null);

        root.activate(adapter);

        //
        // Create a file called "README" in the root directory
        //
        var file = new FileI("README", root);
        var text = new string[] { "This file system contains a collection of poetry." };

        try
        {
            file.write(text);
        }
        catch (GenericError e)
        {
            Console.Error.WriteLine(e.reason);
        }
        file.activate(adapter);

        //
        // Create a directory called "Coleridge" in the root directory
        //
        var coleridge = new DirectoryI("Coleridge", root);

        coleridge.activate(adapter);

        //
        // Create a file called "Kubla_Khan" in the Coleridge directory
        //
        file = new FileI("Kubla_Khan", coleridge);
        text = new string[] { "In Xanadu did Kubla Khan",
                              "A stately pleasure-dome decree:",
                              "Where Alph, the sacred river, ran",
                              "Through caverns measureless to man",
                              "Down to a sunless sea." };
        try
        {
            file.write(text);
        }
        catch (GenericError e)
        {
            Console.Error.WriteLine(e.reason);
        }
        file.activate(adapter);

        //
        // All objects are created, allow client requests now
        //
        adapter.activate();

        //
        // Wait until we are done
        //
        communicator.waitForShutdown();

        return(0);
    }
Пример #13
0
        public override int run(string[] args)
        {
            //
            // Terminate cleanly on receipt of a signal
            //
            shutdownOnInterrupt();

            //
            // Create an object adapter.
            //
            var adapter =
                communicator().createObjectAdapterWithEndpoints("SimpleFilesystem", "default -h localhost -p 10000");

            //
            // Create the root directory (with name "/" and no parent)
            //
            var root = new DirectoryI(communicator(), "/", null);
            root.activate(adapter);

            //
            // Create a file called "README" in the root directory
            //
            var file = new FileI(communicator(), "README", root);
            var text = new string[]{ "This file system contains a collection of poetry." };
            try
            {
                file.write(text);
            }
            catch(GenericError e)
            {
                Console.Error.WriteLine(e.reason);
            }
            file.activate(adapter);

            //
            // Create a directory called "Coleridge" in the root directory
            //
            var coleridge = new DirectoryI(communicator(), "Coleridge", root);
            coleridge.activate(adapter);

            //
            // Create a file called "Kubla_Khan" in the Coleridge directory
            //
            file = new FileI(communicator(), "Kubla_Khan", coleridge);
            text = new string[]{ "In Xanadu did Kubla Khan",
                                 "A stately pleasure-dome decree:",
                                 "Where Alph, the sacred river, ran",
                                 "Through caverns measureless to man",
                                 "Down to a sunless sea." };
            try
            {
                file.write(text);
            }
            catch(GenericError e)
            {
                Console.Error.WriteLine(e.reason);
            }
            file.activate(adapter);

            //
            // All objects are created, allow client requests now
            //
            adapter.activate();

            //
            // Wait until we are done
            //
            communicator().waitForShutdown();

            if(interrupted())
            {
                Console.Error.WriteLine(appName() + ": terminating");
            }

            return 0;
        }
Пример #14
0
        public override int run(string[] args)
        {
            //
            // Terminate cleanly on receipt of a signal
            //
            shutdownOnInterrupt();

            //
            // Create an object adapter.
            //
            Ice.ObjectAdapter adapter =
                communicator().createObjectAdapterWithEndpoints("SimpleFilesystem", "default -h localhost -p 10000");

            //
            // Create the root directory (with name "/" and no parent)
            //
            DirectoryI root = new DirectoryI(communicator(), "/", null);

            root.activate(adapter);

            //
            // Create a file called "README" in the root directory
            //
            FileI file = new FileI(communicator(), "README", root);

            string[] text;
            text = new string[] { "This file system contains a collection of poetry." };
            try
            {
                file.write(text);
            }
            catch (GenericError e)
            {
                Console.Error.WriteLine(e.reason);
            }
            file.activate(adapter);

            //
            // Create a directory called "Coleridge" in the root directory
            //
            DirectoryI coleridge = new DirectoryI(communicator(), "Coleridge", root);

            coleridge.activate(adapter);

            //
            // Create a file called "Kubla_Khan" in the Coleridge directory
            //
            file = new FileI(communicator(), "Kubla_Khan", coleridge);
            text = new string[] { "In Xanadu did Kubla Khan",
                                  "A stately pleasure-dome decree:",
                                  "Where Alph, the sacred river, ran",
                                  "Through caverns measureless to man",
                                  "Down to a sunless sea." };
            try
            {
                file.write(text);
            }
            catch (GenericError e)
            {
                Console.Error.WriteLine(e.reason);
            }
            file.activate(adapter);

            //
            // All objects are created, allow client requests now
            //
            adapter.activate();

            //
            // Wait until we are done
            //
            communicator().waitForShutdown();

            if (interrupted())
            {
                Console.Error.WriteLine(appName() + ": terminating");
            }

            return(0);
        }