Fixed #374055:Only the first "tag" is detected in digikam.
[beagle.git] / bludgeon / GzipFileObject.cs
blob8d82ff987e82ed1585dfd869be6a032eb8986720
2 using System;
3 using System.Collections;
4 using System.IO;
5 using System.Text;
7 using ICSharpCode.SharpZipLib;
8 using ICSharpCode.SharpZipLib.GZip;
10 using Beagle.Util;
11 using Beagle;
13 namespace Bludgeon {
15 public class GzipFileObject : FileObject {
17 public GzipFileObject (FileObject gzipped_file)
19 AllowChildren ();
20 AddChild (gzipped_file, null);
23 override protected string GetChildUri (FileSystemObject children)
25 // FIXME: What is the uri scheme for gzip files?
26 return this.Uri + "#" + children.Name;
29 override public string MimeType {
30 get { return "application/x-gzip"; }
33 override public string Extension {
34 get { return ".gz"; }
37 override public void AddToStream (Stream stream, EventTracker tracker)
39 if (ChildCount > 1)
40 throw new Exception ("Gzip file " + Uri + " has " + ChildCount + " children");
42 if (tracker != null)
43 tracker.ExpectingAdded (this.Uri);
45 UnclosableStream unclosable;
46 unclosable = new UnclosableStream (stream);
48 GZipOutputStream gz_out;
49 gz_out = new GZipOutputStream (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 gz_out.Write (memory.ToArray (), 0, (int) memory.Length);
57 memory.Close ();
59 gz_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;