1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/base/nsIGZFileWriter.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,74 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#include "nsISupports.idl" 1.11 + 1.12 +%{C++ 1.13 +#include "nsDependentString.h" 1.14 +%} 1.15 + 1.16 +interface nsIFile; 1.17 + 1.18 +/** 1.19 + * A simple interface for writing to a .gz file. 1.20 + * 1.21 + * Note that the file that this interface produces has a different format than 1.22 + * what you'd get if you compressed your data as a gzip stream and dumped the 1.23 + * result to a file. 1.24 + * 1.25 + * The standard gunzip tool cannot decompress a raw gzip stream, but can handle 1.26 + * the files produced by this interface. 1.27 + */ 1.28 +[scriptable, uuid(a256f26a-c603-459e-b5a4-53b4877f2cd8)] 1.29 +interface nsIGZFileWriter : nsISupports 1.30 +{ 1.31 + /** 1.32 + * Initialize this object. We'll write our gzip'ed data to the given file, 1.33 + * overwriting its contents if the file exists. 1.34 + * 1.35 + * init() will return an error if called twice. It's an error to call any 1.36 + * other method on this interface without first calling init(). 1.37 + */ 1.38 + void init(in nsIFile file); 1.39 + 1.40 + /** 1.41 + * Write the given string to the file. 1.42 + */ 1.43 + void write(in AUTF8String str); 1.44 + 1.45 + /* 1.46 + * The following two overloads of Write() are C++ because we can't overload 1.47 + * methods in XPIDL. Anyway, they don't add much functionality for JS 1.48 + * callers. 1.49 + */ 1.50 + %{C++ 1.51 + /** 1.52 + * Write the given char* to the file (not including the null-terminator). 1.53 + */ 1.54 + nsresult Write(const char* str) 1.55 + { 1.56 + return Write(str, strlen(str)); 1.57 + } 1.58 + 1.59 + /** 1.60 + * Write |length| bytes of |str| to the file. 1.61 + */ 1.62 + nsresult Write(const char* str, uint32_t len) 1.63 + { 1.64 + return Write(nsDependentCString(str, len)); 1.65 + } 1.66 + %} 1.67 + 1.68 + /** 1.69 + * Close this nsIGZFileWriter. Classes implementing nsIGZFileWriter will run 1.70 + * this method when the underlying object is destroyed, so it's not strictly 1.71 + * necessary to explicitly call it from your code. 1.72 + * 1.73 + * It's an error to call this method twice, and it's an error to call write() 1.74 + * after finish() has been called. 1.75 + */ 1.76 + void finish(); 1.77 +};