public void Unpack()
 {
     if (_folder != null)
     {
         if (_folder.GetSkelleton() == DefaultStructure.GetSkelleton(filename))
         {
             _folder.Link(this);
         }                                                                                           //TODO - Decide on what to actually make this comparison behave like
         else
         {
             throw new InvalidOperationException(string.Format("Corrupted Structure at {0}", _folder.ToString()));
         }
     }
     else
     {
         string asocfolder = AssociatedFolder(filename);
         Directory.CreateDirectory(asocfolder);
         format.Unpack(filename, asocfolder);
         Format nextformat = format.LowerLevel();
         if (nextformat.Unpackable())
         {
             _folder = new FileContainer(Path.GetDirectoryName(asocfolder), Path.GetFileName(asocfolder), nextformat);
             _folder.Link(this);
             _folder.Unpack();
         }
     }
 }
Exemplo n.º 2
0
 public DirectoryTree(string root, DirectoryTree _parent = null)
 {
     if (!Directory.Exists(root))
     {
         throw new ArgumentException(string.Format("Directory does not exist at {1}", root));
     }
     Expanded = false;
     node     = new FileContainer(Path.GetDirectoryName(root), Path.GetFileName(root), new Format());
     Parent   = _parent;
     string[] directories = HelperFunctions.GetTrueDirectories(root);
     children = new List <DirectoryTree>();
     foreach (string folder in directories)
     {
         children.Add(new DirectoryTree(Path.Combine(root, folder)));
     }
 }
        public SymbolicFile(string filename, SymbolicFile parent = null)
        {
            this.parent = parent;
            if (!File.Exists(filename))
            {
                throw new ArgumentException(string.Format("File {0} does not exist", filename));
            }
            this.filename = filename;
            format        = Format.Guess(filename);

            _folder = null;
            string asocfolder = AssociatedFolder(filename);

            if (Directory.Exists(asocfolder))
            {
                _folder = new FileContainer(Path.GetDirectoryName(asocfolder), Path.GetFileName(asocfolder), format.LowerLevel());
            }

            DisplayName = DefaultStructure.GetDisplayName(filename); //TODO - DefaultStructure class
        }