2013-03-27 20:31:26 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-10-02 18:19:11 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
|
|
|
|
%{C++
|
|
|
|
#include "nsDependentString.h"
|
2014-07-02 15:59:02 -07:00
|
|
|
#include <stdio.h>
|
2012-10-02 18:19:11 -07:00
|
|
|
%}
|
|
|
|
|
|
|
|
interface nsIFile;
|
2014-07-02 15:59:02 -07:00
|
|
|
[ptr] native FILE(FILE);
|
2012-10-02 18:19:11 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A simple interface for writing to a .gz file.
|
|
|
|
*
|
|
|
|
* Note that the file that this interface produces has a different format than
|
|
|
|
* what you'd get if you compressed your data as a gzip stream and dumped the
|
|
|
|
* result to a file.
|
|
|
|
*
|
|
|
|
* The standard gunzip tool cannot decompress a raw gzip stream, but can handle
|
|
|
|
* the files produced by this interface.
|
|
|
|
*/
|
2014-07-02 15:59:02 -07:00
|
|
|
[scriptable, uuid(6bd5642c-1b90-4499-ba4b-199f27efaba5)]
|
2012-10-02 18:19:11 -07:00
|
|
|
interface nsIGZFileWriter : nsISupports
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Initialize this object. We'll write our gzip'ed data to the given file,
|
|
|
|
* overwriting its contents if the file exists.
|
|
|
|
*
|
|
|
|
* init() will return an error if called twice. It's an error to call any
|
|
|
|
* other method on this interface without first calling init().
|
|
|
|
*/
|
|
|
|
void init(in nsIFile file);
|
|
|
|
|
2014-07-02 15:59:02 -07:00
|
|
|
/**
|
|
|
|
* Alternate version of init() for use when the file is already opened;
|
|
|
|
* e.g., with a FileDescriptor passed over IPC.
|
|
|
|
*/
|
|
|
|
[noscript] void initANSIFileDesc(in FILE file);
|
|
|
|
|
2012-10-02 18:19:11 -07:00
|
|
|
/**
|
|
|
|
* Write the given string to the file.
|
|
|
|
*/
|
|
|
|
void write(in AUTF8String str);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The following two overloads of Write() are C++ because we can't overload
|
|
|
|
* methods in XPIDL. Anyway, they don't add much functionality for JS
|
|
|
|
* callers.
|
|
|
|
*/
|
|
|
|
%{C++
|
|
|
|
/**
|
|
|
|
* Write the given char* to the file (not including the null-terminator).
|
|
|
|
*/
|
|
|
|
nsresult Write(const char* str)
|
|
|
|
{
|
|
|
|
return Write(str, strlen(str));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Write |length| bytes of |str| to the file.
|
|
|
|
*/
|
|
|
|
nsresult Write(const char* str, uint32_t len)
|
|
|
|
{
|
|
|
|
return Write(nsDependentCString(str, len));
|
|
|
|
}
|
|
|
|
%}
|
|
|
|
|
|
|
|
/**
|
2013-03-27 20:31:26 -07:00
|
|
|
* Close this nsIGZFileWriter. Classes implementing nsIGZFileWriter will run
|
|
|
|
* this method when the underlying object is destroyed, so it's not strictly
|
|
|
|
* necessary to explicitly call it from your code.
|
2012-10-02 18:19:11 -07:00
|
|
|
*
|
|
|
|
* It's an error to call this method twice, and it's an error to call write()
|
|
|
|
* after finish() has been called.
|
|
|
|
*/
|
|
|
|
void finish();
|
|
|
|
};
|