コード例 #1
0
ファイル: FileTree.cs プロジェクト: stachupl/MNFS
        public FileNode parent; // odniesienie do węzła nadrzędnego

        #endregion Fields

        #region Constructors

        public FileNode()
        {
            this.name = "";
            this.isDirectory = false;
            this.fileLocation = null;
            this.children = null;
            this.parent = null;
        }
コード例 #2
0
ファイル: FileTree.cs プロジェクト: stachupl/MNFS
 public FileNode(string name)
 {
     this.name = name;
     this.isDirectory = true;
     this.fileLocation = null;
     this.children = new List<FileNode>();
     this.parent = null;
 }
コード例 #3
0
ファイル: FileTree.cs プロジェクト: stachupl/MNFS
 public FileNode(string name, FileNetworkAddress address)
 {
     this.name = name;
     this.isDirectory = false;
     this.fileLocation = new ArrayList();
     this.fileLocation.Add(address);
     this.children = null;
     this.parent = null;
 }
コード例 #4
0
ファイル: FileTree.cs プロジェクト: stachupl/MNFS
 public FileTree()
 {
     root = new FileNode("/");
 }
コード例 #5
0
ファイル: FileTree.cs プロジェクト: stachupl/MNFS
        public string mkdir(string path, string name)
        {
            FileNode newDirectory = new FileNode(name);
            FileNode directory;
            bool exist = false;

            directory = locateDirectory(path);
            if (directory == null)
                return "Path doesn't exist. Can't create directory!";

            foreach (FileNode fn in directory.children)
                if (fn.name == name && fn.isDirectory == true)
                    exist = true;

            if (exist == true)
                return "Directory exist. Can't create!";
            else
            {
                newDirectory.parent = directory;
                directory.children.Add(newDirectory);
                return "Directory created.";
            }
        }
コード例 #6
0
ファイル: FileTree.cs プロジェクト: stachupl/MNFS
 private void delete()
 {
     root = new FileNode("/");
 }
コード例 #7
0
ファイル: FileTree.cs プロジェクト: stachupl/MNFS
        public void findDirectory(FileNode directory, string workingDirectory, string name, ArrayList result)
        {
            foreach (FileNode fn in directory.children)
            {
                Console.WriteLine("AAA {0}, {1}, {2},", fn.name, name, fn.isDirectory);
                if (fn.name == name && fn.isDirectory == true)
                {
                    result.Add(workingDirectory + "/" + name);
                    Console.WriteLine("ffff");
                }

                if (fn.isDirectory == true)
                    findDirectory(fn, workingDirectory + "/" + fn.name, name, result);
            }
        }
コード例 #8
0
ファイル: FileTree.cs プロジェクト: stachupl/MNFS
        public void findFile(FileNode directory, string workingDirectory, string name, ArrayList result)
        {
            foreach (FileNode fn in directory.children)
            {
                if (fn.name == name && fn.isDirectory == false)
                    result.Add(workingDirectory + "/" + name);

                if (fn.isDirectory == true)
                    findFile(fn, workingDirectory + "/" + fn.name, name, result);
            }
        }
コード例 #9
0
ファイル: FileTree.cs プロジェクト: stachupl/MNFS
        public string create(string path, string name, string locationIP, string locationPort, string id)
        {
            FileNode directory;
            bool exist = false;

            directory = locateDirectory(path);
            if (directory == null)
                return "Path doesn't exist. Can't create file!";

            foreach (FileNode fn in directory.children)
                if (fn.name == name && fn.isDirectory == false)
                    exist = true;

            if (exist == true)
                return "File exist. Can't create!";
            else
            {
                FileNetworkAddress address = new FileNetworkAddress(id, locationIP, locationPort);
                FileNode newFile = new FileNode(name, address);
                newFile.parent = directory;
                directory.children.Add(newFile);

                return "File successfully created.";
            }
        }
コード例 #10
0
ファイル: FileTree.cs プロジェクト: stachupl/MNFS
        public string cpdir(string sourcePath, string destinationPath)
        {
            FileNode file, newFile;
            FileNode destinationDiretory;
            bool exist = false;

            file = locateDirectory(sourcePath);
            if (file == null)
                return "Directory doesn't exist. Can't copy!";

            destinationDiretory = locateDirectory(destinationPath);
            if (destinationDiretory == null)
                return "Destination directory doesn't exist. Can't copy!";

            if (file.children.Count > 0)
                return "Source directory doesn't empty. Can't copy!";

            foreach (FileNode fn in destinationDiretory.children)
                if (fn.name == file.name && fn.isDirectory == true)
                    exist = true;

            if (exist == true)
                return "In destination directory exist directory with the same name. Can't copy!";

            newFile = new FileNode(file.name);
            newFile.parent = destinationDiretory;
            destinationDiretory.children.Add(newFile);

            return "Directory successfully copied.";
        }
コード例 #11
0
ファイル: FileTree.cs プロジェクト: stachupl/MNFS
        public string cp(string sourcePath, string destinationPath, FileNetworkAddress address)
        {
            FileNode file, newFile;
            FileNode destinationDiretory;
            bool exist = false;

            file = locateFile(sourcePath);
            if (file == null)
                return "File doesn't exist. Can't copy!";

            destinationDiretory = locateDirectory(destinationPath);
            if (destinationDiretory == null)
                return "Destination directory doesn't exist. Can't copy!";

            foreach (FileNode fn in destinationDiretory.children)
                if (fn.name == file.name && fn.isDirectory == false)
                    exist = true;

            if (exist == true)
                return "In destination directory exist file with the same name. Can't copy!";

            newFile = new FileNode(file.name, address);
            newFile.parent = destinationDiretory;
            destinationDiretory.children.Add(newFile);

            return "File successfully copied.";
        }
コード例 #12
0
ファイル: FileTree.cs プロジェクト: stachupl/MNFS
 private void delete()
 {
     root = new FileNode("/");
 }
コード例 #13
0
ファイル: FileTree.cs プロジェクト: stachupl/MNFS
 public FileTree()
 {
     root = new FileNode("/");
 }