2013-03-28 03:31:26 +00: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 01:19:11 +00: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 02:34:00 +00:00
|
|
|
#ifndef nsGZFileWriter_h
|
|
|
|
#define nsGZFileWriter_h
|
|
|
|
|
2012-10-03 01:19:11 +00:00
|
|
|
#include "nsIGZFileWriter.h"
|
|
|
|
#include "zlib.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A simple class for writing .gz files.
|
|
|
|
*/
|
2015-03-21 16:28:04 +00:00
|
|
|
class nsGZFileWriter final : public nsIGZFileWriter {
|
2014-06-30 22:11:53 +00:00
|
|
|
virtual ~nsGZFileWriter();
|
|
|
|
|
2012-10-03 01:19:11 +00:00
|
|
|
public:
|
2015-06-05 03:20:16 +00:00
|
|
|
enum Operation { Append, Create };
|
|
|
|
|
|
|
|
explicit nsGZFileWriter(Operation aMode = Create);
|
2012-10-03 01:19:11 +00:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIGZFILEWRITER
|
|
|
|
|
2020-11-18 09:05:59 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
[[nodiscard]] nsresult Write(const char* aStr) {
|
2012-10-03 01:19:11 +00:00
|
|
|
return nsIGZFileWriter::Write(aStr);
|
|
|
|
}
|
|
|
|
|
2020-03-27 17:21:48 +00:00
|
|
|
[[nodiscard]] nsresult Write(const char* aStr, uint32_t aLen) {
|
2012-10-03 01:19:11 +00:00
|
|
|
return nsIGZFileWriter::Write(aStr, aLen);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-06-05 03:20:16 +00:00
|
|
|
Operation mMode;
|
2012-10-03 01:19:11 +00:00
|
|
|
bool mInitialized;
|
|
|
|
bool mFinished;
|
|
|
|
gzFile mGZFile;
|
|
|
|
};
|
2013-11-19 02:34:00 +00:00
|
|
|
|
|
|
|
#endif
|