Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "nsISupports.idl" |
michael@0 | 8 | |
michael@0 | 9 | %{C++ |
michael@0 | 10 | #include "nsDependentString.h" |
michael@0 | 11 | %} |
michael@0 | 12 | |
michael@0 | 13 | interface nsIFile; |
michael@0 | 14 | |
michael@0 | 15 | /** |
michael@0 | 16 | * A simple interface for writing to a .gz file. |
michael@0 | 17 | * |
michael@0 | 18 | * Note that the file that this interface produces has a different format than |
michael@0 | 19 | * what you'd get if you compressed your data as a gzip stream and dumped the |
michael@0 | 20 | * result to a file. |
michael@0 | 21 | * |
michael@0 | 22 | * The standard gunzip tool cannot decompress a raw gzip stream, but can handle |
michael@0 | 23 | * the files produced by this interface. |
michael@0 | 24 | */ |
michael@0 | 25 | [scriptable, uuid(a256f26a-c603-459e-b5a4-53b4877f2cd8)] |
michael@0 | 26 | interface nsIGZFileWriter : nsISupports |
michael@0 | 27 | { |
michael@0 | 28 | /** |
michael@0 | 29 | * Initialize this object. We'll write our gzip'ed data to the given file, |
michael@0 | 30 | * overwriting its contents if the file exists. |
michael@0 | 31 | * |
michael@0 | 32 | * init() will return an error if called twice. It's an error to call any |
michael@0 | 33 | * other method on this interface without first calling init(). |
michael@0 | 34 | */ |
michael@0 | 35 | void init(in nsIFile file); |
michael@0 | 36 | |
michael@0 | 37 | /** |
michael@0 | 38 | * Write the given string to the file. |
michael@0 | 39 | */ |
michael@0 | 40 | void write(in AUTF8String str); |
michael@0 | 41 | |
michael@0 | 42 | /* |
michael@0 | 43 | * The following two overloads of Write() are C++ because we can't overload |
michael@0 | 44 | * methods in XPIDL. Anyway, they don't add much functionality for JS |
michael@0 | 45 | * callers. |
michael@0 | 46 | */ |
michael@0 | 47 | %{C++ |
michael@0 | 48 | /** |
michael@0 | 49 | * Write the given char* to the file (not including the null-terminator). |
michael@0 | 50 | */ |
michael@0 | 51 | nsresult Write(const char* str) |
michael@0 | 52 | { |
michael@0 | 53 | return Write(str, strlen(str)); |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | /** |
michael@0 | 57 | * Write |length| bytes of |str| to the file. |
michael@0 | 58 | */ |
michael@0 | 59 | nsresult Write(const char* str, uint32_t len) |
michael@0 | 60 | { |
michael@0 | 61 | return Write(nsDependentCString(str, len)); |
michael@0 | 62 | } |
michael@0 | 63 | %} |
michael@0 | 64 | |
michael@0 | 65 | /** |
michael@0 | 66 | * Close this nsIGZFileWriter. Classes implementing nsIGZFileWriter will run |
michael@0 | 67 | * this method when the underlying object is destroyed, so it's not strictly |
michael@0 | 68 | * necessary to explicitly call it from your code. |
michael@0 | 69 | * |
michael@0 | 70 | * It's an error to call this method twice, and it's an error to call write() |
michael@0 | 71 | * after finish() has been called. |
michael@0 | 72 | */ |
michael@0 | 73 | void finish(); |
michael@0 | 74 | }; |