Esempio n. 1
0
        public bool ExtractTo(CBackupReader BackupFile, string TargetPath)
        {
            // Ensure that the target path has a trailing '\'
            if (TargetPath[TargetPath.Length - 1] != '\\')
            {
                TargetPath += '\\';
            }

            if ((mType == ENodeType.Root) || (mType == ENodeType.Set))
            {
                throw new System.Exception("Tape and set nodes can not be extracted. Only volume, folder or file nodes can be extracted.");
            }
            else if (mType == ENodeType.Volume)
            {
                System.IO.DirectoryInfo dirinfo = System.IO.Directory.CreateDirectory(TargetPath);
                foreach (CCatalogNode node in mNodes)
                {
                    node.ExtractTo(BackupFile, TargetPath);
                }
            }
            else if (mType == ENodeType.Folder)
            {
                System.IO.DirectoryInfo dirinfo = System.IO.Directory.CreateDirectory(TargetPath + mName);
                foreach (CCatalogNode node in mNodes)
                {
                    node.ExtractTo(BackupFile, dirinfo.FullName);
                }
            }
            else if (mType == ENodeType.File)
            {
                // Create the target directory if it does not exist
                System.IO.Directory.CreateDirectory(TargetPath);
                BackupFile.Stream.BaseStream.Seek(mOffset, System.IO.SeekOrigin.Begin);
                System.IO.FileStream file = new System.IO.FileStream(TargetPath + mName, System.IO.FileMode.Create);
                CFileDescriptorBlock fil  = (CFileDescriptorBlock)BackupFile.Stream.ReadDBLK();
                foreach (CDataStream data in fil.Streams)
                {
                    if (data.Header.StreamID == "STAN")
                    {
                        file.Write(data.Data, 0, data.Data.Length);
                    }
                }
                file.Close();
            }

            return(true);
        }
Esempio n. 2
0
        public bool ExtractTo(CBackupReader BackupFile, string TargetPath)
        {
            // Ensure that the target path has a trailing '\'
            if (TargetPath[TargetPath.Length - 1] != '\\')
                TargetPath += '\\';

            if ((mType == ENodeType.Root) || (mType == ENodeType.Set))
            {
                throw new System.Exception("Tape and set nodes can not be extracted. Only volume, folder or file nodes can be extracted.");
            }
            else if (mType == ENodeType.Volume)
            {
                System.IO.DirectoryInfo dirinfo = System.IO.Directory.CreateDirectory(TargetPath);
                foreach (CCatalogNode node in mNodes)
                    node.ExtractTo(BackupFile, TargetPath);
            }
            else if (mType == ENodeType.Folder)
            {
                System.IO.DirectoryInfo dirinfo = System.IO.Directory.CreateDirectory(TargetPath + mName);
                foreach (CCatalogNode node in mNodes)
                    node.ExtractTo(BackupFile, dirinfo.FullName);
            }
            else if (mType == ENodeType.File)
            {
                // Create the target directory if it does not exist
                System.IO.Directory.CreateDirectory(TargetPath);
                BackupFile.Stream.BaseStream.Seek(mOffset, System.IO.SeekOrigin.Begin);
                System.IO.FileStream file = new System.IO.FileStream(TargetPath + mName, System.IO.FileMode.Create);
                CFileDescriptorBlock fil = (CFileDescriptorBlock)BackupFile.Stream.ReadDBLK();
                foreach (CDataStream data in fil.Streams)
                {
                    if (data.Header.StreamID == "STAN")
                    {
                        file.Write(data.Data, 0, data.Data.Length);
                    }
                }
                file.Close();
            }

            return true;
        }