mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1154435 - [nsGZFileWriter] Add one more mode for writing a GZFile (Create/Append). r=froydnj
This commit is contained in:
parent
310eaefd94
commit
051f87490e
@ -18,8 +18,9 @@
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsGZFileWriter, nsIGZFileWriter)
|
||||
|
||||
nsGZFileWriter::nsGZFileWriter()
|
||||
: mInitialized(false)
|
||||
nsGZFileWriter::nsGZFileWriter(Operation aMode)
|
||||
: mMode(aMode)
|
||||
, mInitialized(false)
|
||||
, mFinished(false)
|
||||
{
|
||||
}
|
||||
@ -43,7 +44,8 @@ nsGZFileWriter::Init(nsIFile* aFile)
|
||||
// gzip can own. Then close our FILE, leaving only gzip's fd open.
|
||||
|
||||
FILE* file;
|
||||
nsresult rv = aFile->OpenANSIFileDesc("wb", &file);
|
||||
nsresult rv = aFile->OpenANSIFileDesc(mMode == Create ? "wb" : "ab", &file);
|
||||
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -53,7 +55,7 @@ nsGZFileWriter::Init(nsIFile* aFile)
|
||||
NS_IMETHODIMP
|
||||
nsGZFileWriter::InitANSIFileDesc(FILE* aFile)
|
||||
{
|
||||
mGZFile = gzdopen(dup(fileno(aFile)), "wb");
|
||||
mGZFile = gzdopen(dup(fileno(aFile)), mMode == Create ? "wb" : "ab");
|
||||
fclose(aFile);
|
||||
|
||||
// gzdopen returns nullptr on error.
|
||||
|
@ -18,7 +18,14 @@ class nsGZFileWriter final : public nsIGZFileWriter
|
||||
virtual ~nsGZFileWriter();
|
||||
|
||||
public:
|
||||
nsGZFileWriter();
|
||||
|
||||
enum Operation {
|
||||
Append,
|
||||
Create
|
||||
};
|
||||
|
||||
|
||||
explicit nsGZFileWriter(Operation aMode = Create);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIGZFILEWRITER
|
||||
@ -39,6 +46,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
Operation mMode;
|
||||
bool mInitialized;
|
||||
bool mFinished;
|
||||
gzFile mGZFile;
|
||||
|
Loading…
Reference in New Issue
Block a user