Ejemplo n.º 1
0
        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.");
            }
        }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
        public string addLocation(string path, string id, string ip, string port)
        {
            FileNode           file;
            FileNetworkAddress address = new FileNetworkAddress(id, ip, port);

            file = locateFile(path);
            if (file == null)
            {
                return("File doesn't exist. Can't add new location");
            }

            file.fileLocation.Add(address);

            return("New location successfully added");
        }
Ejemplo n.º 5
0
        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.");
        }
Ejemplo n.º 6
0
        static void write(string path)
        {
            FileNetworkAddress servers = new FileNetworkAddress();

            try
            {
                //servers = (FileNetworkAddress) nameServer.write(path);
            }
            catch (Exception)
            {
                Console.WriteLine("Device temporarily unavailable. Try again later.");
            }
        }
Ejemplo n.º 7
0
        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.";
            }
        }
Ejemplo n.º 8
0
        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.";
        }
Ejemplo n.º 9
0
        public string addLocation(string path, string id, string ip, string port)
        {
            FileNode file;
            FileNetworkAddress address = new FileNetworkAddress(id, ip, port);

            file = locateFile(path);
            if (file == null)
                return "File doesn't exist. Can't add new location";

            file.fileLocation.Add(address);

            return "New location successfully added";
        }