3 using System
.Collections
;
7 using ICSharpCode
.SharpZipLib
;
8 using ICSharpCode
.SharpZipLib
.BZip2
;
15 public class Bzip2FileObject
: FileObject
{
17 public Bzip2FileObject (FileObject bzip2ed_file
)
20 AddChild (bzip2ed_file
, null);
23 override protected string GetChildUri (FileSystemObject children
)
25 // FIXME: What is the uri scheme for bzip2 files?
26 return this.Uri
+ "#" + children
.Name
;
29 override public string MimeType
{
30 get { return "application/x-bzip2"; }
33 override public string Extension
{
34 get { return ".bz2"; }
37 override public void AddToStream (Stream stream
, EventTracker tracker
)
40 throw new Exception ("Bzip2 file " + Uri
+ " has " + ChildCount
+ " children");
43 tracker
.ExpectingAdded (this.Uri
);
45 UnclosableStream unclosable
;
46 unclosable
= new UnclosableStream (stream
);
48 BZip2OutputStream bz2_out
;
49 bz2_out
= new BZip2OutputStream (unclosable
);
52 memory
= new MemoryStream ();
53 // There should just be one child
54 foreach (FileObject file
in Children
)
55 file
.AddToStream (memory
, tracker
);
56 bz2_out
.Write (memory
.ToArray (), 0, (int) memory
.Length
);
62 override protected bool MatchesQueryPart (QueryPart part
)
64 // The only thing that could match is the name, and we check
65 // for that already in FileSystemObject.MatchesQuery.