Ejemplo n.º 1
0
        public void MoveTo(IFuserFilesystemItem item, IFuserFilesystemDirectory destination, string newname)
        {
            if (item is SimRoot)
            {
                throw new Exception("Access error");
            }
            if (item is SimFile)
            {
                SimFile vFile = (SimFile)item;
                if (vFile.Name != newname)
                {
                    vFile.SetNewName(newname);
                }
            }

            if (item is SimSubdirectory)
            {
                SimSubdirectory vDir = (SimSubdirectory)item;
                if (vDir.Name != newname)
                {
                    vDir.SetNewName(newname);
                }
            }

            if (destination == null)
            {
                return;
            }



            if (destination is SimSubdirectory)
            {
                SimSubdirectory vDstDir = (SimSubdirectory)destination;
                directoryContent.Remove(item);
                vDstDir.AddItem(item);
                return;
            }

            if (destination is SimRoot)
            {
                SimRoot vDstRoot = (SimRoot)destination;
                directoryContent.Remove(item);
                vDstRoot.AddItem(item);
                return;
            }



            throw new Exception("Mode not supported");
        }
Ejemplo n.º 2
0
        private IFuserFilesystemDirectory getnewRoot()
        {
            SimRoot         root = new SimRoot();
            SimSubdirectory subA = new SimSubdirectory(null, "SubA");
            SimSubdirectory subB = new SimSubdirectory(null, "SubB");

            SimSubdirectory TestDir = new SimSubdirectory(null, "test");

            SimFile testFile = new SimFile("test.txt", getData("This is a test!"), FileAttributes.Archive);

            SimFile file1 = new SimFile("Datei 1.txt", getData(100), FileAttributes.Archive);
            SimFile file2 = new SimFile("Datei 2.dat", getData(2024), FileAttributes.Archive);
            SimFile file3 = new SimFile("Datei 3.bmp", getData(33333), FileAttributes.Archive);

            SimFile file4 = new SimFile("Ganz Neue Dat-Datei.dat", getData(123456), FileAttributes.Archive);



            root.AddDir(new SimSubdirectory(null, "Leeres Verzeichnis"));
            root.AddDir(new SimSubdirectory(null, "nochmals leer"));
            root.AddDir(subA);

            subA.AddDir(new SimSubdirectory(null, "Leer a1"));
            subA.AddDir(new SimSubdirectory(null, "Leer a2"));
            subA.AddDir(subB);

            subB.AddDir(new SimSubdirectory(null, "Leer b1"));
            subB.AddDir(new SimSubdirectory(null, "Leer b2"));


            root.AddFile(file1);
            root.AddFile(file2);
            root.AddFile(file3);
            subB.AddFile(file4);

            root.AddDir(TestDir);

            root.AddFile(testFile);

            return(root);
        }
Ejemplo n.º 3
0
 public void AddDir(SimSubdirectory newDir)
 {
     directoryContent.Add(newDir);
     newDir.SetParent(this);
 }