コード例 #1
0
 public ArchivedDirectoryNode(FileSystemNode parent, HeaderData info, HeaderData[] list)
     : base(parent)
 {
     this.Name = System.IO.Path.GetFileName(info.FileName.TrimEnd('\\', '/'));
     this.Path = System.IO.Path.Combine(info.ArcName, info.FileName.TrimEnd('\\', '/'));
     this.InternalPath = info.FileName.TrimEnd('\\', '/');
     this.Size = info.UnpSize;
     this.list = list;
 }
コード例 #2
0
 public ArchivedFileNode(FileSystemNode parent, HeaderData info)
     : base(parent)
 {
     this.Name = System.IO.Path.GetFileName(info.FileName);
     this.Path = System.IO.Path.Combine(info.ArcName, info.FileName);
     this.InternalPath = info.FileName;
     this.Size = info.UnpSize;
     this.Attributes = info.FileAttr;            
 }
コード例 #3
0
        protected override HeaderData[] GetList()
        {
            List<HeaderData> items = new List<HeaderData>(40);

            HeaderData data = new HeaderData { ArcName = new string((char)0, 260), FileName = new string((char)0, 260) };
            while (BZip2ArchiveHelper.ReadHeader(this.Handle, ref data) == 0)
            {
                BZip2ArchiveHelper.ProcessFile(this.Handle, OperationMode.Skip, null, null);

                items.Add(data);
            }

            return items.ToArray();
        }
コード例 #4
0
 public static extern int ReadHeader(int handle, ref HeaderData headerData);
コード例 #5
0
        protected override HeaderData[] GetList()
        {
            List<HeaderData> items = new List<HeaderData>(40);

            Dictionary<string, int> directories = new Dictionary<string, int>(10);
            
            using (ZipInputStream stream = new ZipInputStream(this.Path))
            {
                while (true)
                {
                    var item = stream.GetNextEntry();
                    if (item == null)
                    {
                        break;
                    }

                    HeaderData data = new HeaderData { ArcName = this.Path, FileName = item.FileName };
                    if (!item.IsDirectory)
                    {
                        string directory = System.IO.Path.GetDirectoryName(item.FileName);
                        if (!string.IsNullOrEmpty(directory) && !directories.ContainsKey(directory))
                        {
                            foreach (var sub in GetSubDirectories(directory))
                            {
                                if (!directories.ContainsKey(sub))
                                {
                                    directories.Add(sub, 0);
                                    items.Add(new HeaderData {ArcName = this.Path, FileName = directory, FileAttr = FileAttributes.Directory});
                                }
                            }                            
                        }
                    }
                    else
                    {
                        if (!directories.ContainsKey(item.FileName))
                        {
                            directories.Add(item.FileName, 0);
                        }
                    }
                    data.FileAttr = item.Attributes;
                    data.UnpSize = (int)item.UncompressedSize;
                    data.PackSize = (int)item.CompressedSize;

                    items.Add(data);
                }
            }


            /*using(ZipFile zip = new ZipFile(this.Path))
            {
                foreach(var item in zip.Entries)
                {
                    HeaderData data = new HeaderData { ArcName = this.Path, FileName = item.FileName };
                    if (item.IsDirectory)
                    {
                        data.FileAttr = FileAttributes.Directory;                        
                    }
                    data.UnpSize = (int)item.UncompressedSize;
                    data.PackSize = (int)item.CompressedSize;

                    items.Add(data);
                }
            }*/

            return items.ToArray();
        }