Esempio n. 1
0
        private void loadLeafs(string path, IComponent root)
        {

            string[] files = Directory.GetFiles(path);

            foreach (string file in files)
            {
                this.id++;
                FileInfo fileInfo = new FileInfo(file);

                file dat = new file { path = file, name = fileInfo.Name, size = fileInfo.Length, id = this.id, folder = false, root = root, permitWriting = !fileInfo.IsReadOnly, link = System.IO.File.GetAttributes(file).HasFlag(FileAttributes.ReparsePoint) };
                root.AddComponent(dat);
            }
        }
Esempio n. 2
0
        public bool CopyComponent(int what, int where)
        {
            IComponent _what  = main.FindComponent(what);
            IComponent _where = main.FindComponent(where);

            if (_what == null || _where == null)
            {
                Console.WriteLine("Can't find an object!");
                return(false);
            }
            if (_where.folder)
            {
                if (_where.FindComponentInFolder(_what.name) == null)
                {
                    IComponent temp;
                    this.id++;
                    if (_what.folder)
                    {
                        DirectoryInfo dir = Directory.CreateDirectory(_where.path + '\\' + _what.name);
                        CopyDirectory(_what.path, dir.FullName, _where);
                    }
                    else
                    {
                        string destination = System.IO.Path.Combine(_where.path, _what.name);
                        System.IO.File.Copy(_what.path, destination, true);

                        FileInfo fileInfo = new FileInfo(destination);

                        temp = new file {
                            id = this.id, name = _what.name, root = _where, path = destination, size = _what.size, permitWriting = !fileInfo.IsReadOnly
                        };
                        _where.AddComponent(temp);
                    }

                    _where.CalculateSize();

                    return(true);
                }
                else
                {
                    Console.WriteLine("Error, check the name.");
                }
            }
            else
            {
                Console.WriteLine("Error, can't copy the object.");
            }
            return(false);
        }
Esempio n. 3
0
        private void copyFolder(string what, string where, IComponent root)
        {
            DirectoryInfo dir = new DirectoryInfo(what);

            DirectoryInfo[] dirs = dir.GetDirectories();

            DirectoryInfo _dir = Directory.CreateDirectory(where);

            this.id++;
            dir folder = null;

            if (DS_Type == "NTFS")
            {
                folder = new dir {
                    path = _dir.FullName, id = this.id, name = _dir.Name, folder = true, root = root, link = System.IO.File.GetAttributes(_dir.FullName).HasFlag(FileAttributes.ReparsePoint)
                };
            }
            else if (DS_Type == "exFAT")
            {
                if (!System.IO.File.GetAttributes(_dir.FullName).HasFlag(FileAttributes.ReparsePoint))
                {
                    folder = new dir {
                        path = _dir.FullName, id = this.id, name = new DirectoryInfo(_dir.FullName).Name, folder = true, root = root, link = false
                    }
                }
                ;
            }

            root.AddComponent(folder);

            foreach (DirectoryInfo subdir in dirs)
            {
                string temppath = Path.Combine(where, subdir.Name);
                copyFolder(subdir.FullName, temppath, folder);
            }
            FileInfo[] files = dir.GetFiles();
            foreach (FileInfo file in files)
            {
                this.id++;
                string   temppath = Path.Combine(where, file.Name);
                FileInfo temp     = file.CopyTo(temppath, false);

                file dat = new file {
                    path = temp.FullName, name = temp.Name, size = temp.Length, id = this.id, folder = false, root = folder, permitWriting = !temp.IsReadOnly, link = System.IO.File.GetAttributes(temp.FullName).HasFlag(FileAttributes.ReparsePoint)
                };
                folder.AddComponent(dat);
            }
        }
    }
Esempio n. 4
0
        private void loadLeafs(string path, IComponent root)
        {
            string[] files = Directory.GetFiles(path);

            foreach (string file in files)
            {
                this.id++;
                FileInfo fileInfo = new FileInfo(file);

                file dat = new file {
                    path = file, name = fileInfo.Name, size = fileInfo.Length, id = this.id, folder = false, root = root, permitWriting = !fileInfo.IsReadOnly, link = System.IO.File.GetAttributes(file).HasFlag(FileAttributes.ReparsePoint)
                };
                root.AddComponent(dat);
            }
        }
Esempio n. 5
0
        public bool CopyComponent(int what, int where)
        {
            IComponent _what = main.FindComponent(what);
            IComponent _where = main.FindComponent(where);

            if (_what == null || _where == null)
            {
                Console.WriteLine("Can't find an object!");
                return false;
            }
            if (_where.folder)
                if (_where.FindComponentInFolder(_what.name) == null)
                {

                    IComponent temp;
                    this.id++;
                    if (_what.folder)
                    {
                        DirectoryInfo dir = Directory.CreateDirectory(_where.path + '\\' + _what.name);
                        CopyDirectory(_what.path, dir.FullName, _where);

                    }
                    else
                    {
                        string destination = System.IO.Path.Combine(_where.path, _what.name);
                        System.IO.File.Copy(_what.path, destination, true);

                        FileInfo fileInfo = new FileInfo(destination);

                        temp = new file { id = this.id, name = _what.name, root = _where, path = destination, size = _what.size, permitWriting = !fileInfo.IsReadOnly };
                        _where.AddComponent(temp);
                    }

                    _where.CalculateSize();

                    return true;
                }
                else
                    Console.WriteLine("Error, check the name.");
            else
                Console.WriteLine("Error, can't copy the object.");
            return false;
        }
Esempio n. 6
0
        private void loadLeafs(string path, IComponent root)
        {

            string[] folders = Directory.GetFiles(path);

            foreach (string file in folders)
            {
                this.id++;
                FileInfo temp = new FileInfo(file);
                file dat;
                if (System.IO.File.GetAttributes(file).HasFlag(FileAttributes.ReparsePoint))
                {
                    continue;
                }
                else
                {
                    dat = new file { path = file, name = temp.Name, size = temp.Length, id = this.id, folder = false, root = root, permitWriting = !temp.IsReadOnly };
                }
                root.AddComponent(dat);
            }
        }
Esempio n. 7
0
        private void loadLeafs(string path, IComponent root)
        {
            string[] folders = Directory.GetFiles(path);

            foreach (string file in folders)
            {
                this.id++;
                FileInfo temp = new FileInfo(file);
                file     dat;
                if (System.IO.File.GetAttributes(file).HasFlag(FileAttributes.ReparsePoint))
                {
                    continue;
                }
                else
                {
                    dat = new file {
                        path = file, name = temp.Name, size = temp.Length, id = this.id, folder = false, root = root, permitWriting = !temp.IsReadOnly
                    };
                }
                root.AddComponent(dat);
            }
        }
Esempio n. 8
0
        public bool CreateComponent(int where, string name, bool isDirectory)
        {
            IComponent _where = main.FindComponent(where);

            if (!_where.folder)
            {
                Console.WriteLine("Destination has to be a directory!");
                return(false);
            }
            else
            {
                this.id++;
                IComponent root = null;
                if (isDirectory)
                {
                    root = new dir {
                        path = _where.path + '\\' + name, id = this.id, name = name, folder = true, root = _where, link = false
                    };
                }
                else
                {
                    root = new file {
                        path = _where.path + '\\' + name, id = this.id, name = name, folder = false, root = _where, link = false, permitWriting = true
                    };
                }
                if (root == null)
                {
                    return(false);
                }
                else
                {
                    _where.AddComponent(root);
                    _where.CalculateSize();
                }
            }
            return(true);
        }
Esempio n. 9
0
        private void copyFolder(string what, string where, IComponent root)
        {

            DirectoryInfo dir = new DirectoryInfo(what);
            DirectoryInfo[] dirs = dir.GetDirectories();

            DirectoryInfo _dir = Directory.CreateDirectory(where);

            this.id++;
            dir folder = null;
            if (DS_Type == "NTFS")
            {
                folder = new dir { path = _dir.FullName, id = this.id, name = _dir.Name, folder = true, root = root, link = System.IO.File.GetAttributes(_dir.FullName).HasFlag(FileAttributes.ReparsePoint) };
            }
            else if (DS_Type == "exFAT")
            {
                if (!System.IO.File.GetAttributes(_dir.FullName).HasFlag(FileAttributes.ReparsePoint))
                    folder = new dir { path = _dir.FullName, id = this.id, name = new DirectoryInfo(_dir.FullName).Name, folder = true, root = root, link = false };
            }

            root.AddComponent(folder);

            foreach (DirectoryInfo subdir in dirs)
            {
                string temppath = Path.Combine(where, subdir.Name);
                copyFolder(subdir.FullName, temppath, folder);
            }
            FileInfo[] files = dir.GetFiles();
            foreach (FileInfo file in files)
            {
                this.id++;
                string temppath = Path.Combine(where, file.Name);
                FileInfo temp = file.CopyTo(temppath, false);

                file dat = new file { path = temp.FullName, name = temp.Name, size = temp.Length, id = this.id, folder = false, root = folder, permitWriting = !temp.IsReadOnly, link = System.IO.File.GetAttributes(temp.FullName).HasFlag(FileAttributes.ReparsePoint) };
                folder.AddComponent(dat);

            }
        }
Esempio n. 10
0
 public bool CreateComponent(int where, string name, bool isDirectory)
 {
     IComponent _where = main.FindComponent(where);
     if (!_where.folder)
     {
         Console.WriteLine("Destination has to be a directory!");
         return false;
     }
     else
     {
         this.id++;
         IComponent root = null;
         if (isDirectory)
         {
             root = new dir { path = _where.path + '\\' + name, id = this.id, name = name, folder = true, root = _where, link = false };
         }
         else
         {
             root = new file { path = _where.path + '\\' + name, id = this.id, name = name, folder = false, root = _where, link = false, permitWriting = true };
         }
         if (root == null)
             return false;
         else
         {
             _where.AddComponent(root);
             _where.CalculateSize();
         }
     }
     return true;
 }