Add --enable-deletion option to buildindex. If used, buildindex will remove deleted...
[beagle.git] / bludgeon / Bzip2FileObject.cs
blob7b6659e8a00ec604e9dff6c54c697b2655330c22
2 using System;
3 using System.Collections;
4 using System.IO;
5 using System.Text;
7 using ICSharpCode.SharpZipLib;
8 using ICSharpCode.SharpZipLib.BZip2;
10 using Beagle.Util;
11 using Beagle;
13 namespace Bludgeon {
15 public class Bzip2FileObject : FileObject {
17 public Bzip2FileObject (FileObject bzip2ed_file)
19 AllowChildren ();
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)
39 if (ChildCount > 1)
40 throw new Exception ("Bzip2 file " + Uri + " has " + ChildCount + " children");
42 if (tracker != null)
43 tracker.ExpectingAdded (this.Uri);
45 UnclosableStream unclosable;
46 unclosable = new UnclosableStream (stream);
48 BZip2OutputStream bz2_out;
49 bz2_out = new BZip2OutputStream (unclosable);
51 MemoryStream memory;
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);
57 memory.Close ();
59 bz2_out.Close ();
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.
66 return false;