2013-03-28 07:31:26 +04: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-03 05:19:11 +04: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/. */
|
|
|
|
|
2013-11-19 06:34:00 +04:00
|
|
|
#ifndef nsGZFileWriter_h
|
|
|
|
#define nsGZFileWriter_h
|
|
|
|
|
2012-10-03 05:19:11 +04:00
|
|
|
#include "nsIGZFileWriter.h"
|
|
|
|
#include "zlib.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A simple class for writing .gz files.
|
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsGZFileWriter final : public nsIGZFileWriter
|
2012-10-03 05:19:11 +04:00
|
|
|
{
|
2014-07-01 02:11:53 +04:00
|
|
|
virtual ~nsGZFileWriter();
|
|
|
|
|
2012-10-03 05:19:11 +04:00
|
|
|
public:
|
2015-06-05 06:20:16 +03:00
|
|
|
|
|
|
|
enum Operation {
|
|
|
|
Append,
|
|
|
|
Create
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
explicit nsGZFileWriter(Operation aMode = Create);
|
2012-10-03 05:19:11 +04:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIGZFILEWRITER
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nsIGZFileWriter exposes two non-virtual overloads of Write(). We
|
|
|
|
* duplicate them here so that you can call these overloads on a pointer to
|
|
|
|
* the concrete nsGZFileWriter class.
|
|
|
|
*/
|
|
|
|
nsresult Write(const char* aStr)
|
|
|
|
{
|
|
|
|
return nsIGZFileWriter::Write(aStr);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult Write(const char* aStr, uint32_t aLen)
|
|
|
|
{
|
|
|
|
return nsIGZFileWriter::Write(aStr, aLen);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-06-05 06:20:16 +03:00
|
|
|
Operation mMode;
|
2012-10-03 05:19:11 +04:00
|
|
|
bool mInitialized;
|
|
|
|
bool mFinished;
|
|
|
|
gzFile mGZFile;
|
|
|
|
};
|
2013-11-19 06:34:00 +04:00
|
|
|
|
|
|
|
#endif
|