2012-07-28 00:21:34 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_file_domarchivefile_h__
|
|
|
|
#define mozilla_dom_file_domarchivefile_h__
|
|
|
|
|
|
|
|
#include "nsDOMFile.h"
|
|
|
|
|
|
|
|
#include "ArchiveReader.h"
|
|
|
|
|
|
|
|
#include "FileCommon.h"
|
|
|
|
#include "zipstruct.h"
|
|
|
|
|
|
|
|
BEGIN_FILE_NAMESPACE
|
|
|
|
|
2012-11-06 23:23:13 +00:00
|
|
|
/**
|
|
|
|
* ZipFile to DOMFileCC
|
|
|
|
*/
|
2012-07-28 00:21:34 +00:00
|
|
|
class ArchiveZipFile : public nsDOMFileCC
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ArchiveZipFile(const nsAString& aName,
|
|
|
|
const nsAString& aContentType,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint64_t aLength,
|
2012-07-28 00:21:34 +00:00
|
|
|
ZipCentral& aCentral,
|
|
|
|
ArchiveReader* aReader)
|
|
|
|
: nsDOMFileCC(aName, aContentType, aLength),
|
|
|
|
mCentral(aCentral),
|
|
|
|
mArchiveReader(aReader),
|
|
|
|
mFilename(aName)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mArchiveReader, "must have a reader");
|
2012-08-08 18:11:15 +00:00
|
|
|
MOZ_COUNT_CTOR(ArchiveZipFile);
|
2012-07-28 00:21:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ArchiveZipFile(const nsAString& aName,
|
|
|
|
const nsAString& aContentType,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint64_t aStart,
|
|
|
|
uint64_t aLength,
|
2012-07-28 00:21:34 +00:00
|
|
|
ZipCentral& aCentral,
|
|
|
|
ArchiveReader* aReader)
|
|
|
|
: nsDOMFileCC(aContentType, aStart, aLength),
|
|
|
|
mCentral(aCentral),
|
|
|
|
mArchiveReader(aReader),
|
|
|
|
mFilename(aName)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mArchiveReader, "must have a reader");
|
2012-08-08 18:11:15 +00:00
|
|
|
MOZ_COUNT_CTOR(ArchiveZipFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~ArchiveZipFile()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(ArchiveZipFile);
|
2012-07-28 00:21:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Overrides:
|
|
|
|
NS_IMETHOD GetInternalStream(nsIInputStream**);
|
|
|
|
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(ArchiveZipFile, nsIDOMFile)
|
|
|
|
|
|
|
|
protected:
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual already_AddRefed<nsIDOMBlob> CreateSlice(uint64_t aStart,
|
|
|
|
uint64_t aLength,
|
2012-07-28 00:21:34 +00:00
|
|
|
const nsAString& aContentType);
|
|
|
|
|
|
|
|
private: // Data
|
|
|
|
ZipCentral mCentral;
|
|
|
|
nsRefPtr<ArchiveReader> mArchiveReader;
|
|
|
|
|
|
|
|
nsString mFilename;
|
|
|
|
};
|
|
|
|
|
|
|
|
END_FILE_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_file_domarchivefile_h__
|