Skip to content

Commit

Permalink
Revert "Move ZlibDecompressor to libshared"
Browse files Browse the repository at this point in the history
This reverts commit 9af2105.

Conflicts:
	src/kits/package/Jamfile
  • Loading branch information
weinhold committed Jun 18, 2014
1 parent 5cd75b5 commit d2d1af8
Show file tree
Hide file tree
Showing 37 changed files with 148 additions and 131 deletions.
File renamed without changes.
1 change: 1 addition & 0 deletions headers/build/private/package/hpkg/ZlibCompressionBase.h
@@ -0,0 +1 @@
#include <../private/package/hpkg/ZlibCompressionBase.h>
1 change: 1 addition & 0 deletions headers/build/private/package/hpkg/ZlibDecompressor.h
@@ -0,0 +1 @@
#include <../private/package/hpkg/ZlibDecompressor.h>
1 change: 0 additions & 1 deletion headers/build/private/shared/ZlibCompressionBase.h

This file was deleted.

1 change: 0 additions & 1 deletion headers/build/private/shared/ZlibDecompressor.h

This file was deleted.

Expand Up @@ -6,7 +6,6 @@
#define _PACKAGE__HPKG__DATA_OUTPUT_H_


#include <DataIO.h>
#include <SupportDefs.h>


Expand All @@ -15,15 +14,21 @@ namespace BPackageKit {
namespace BHPKG {


class BBufferDataOutput : public BDataIO {
class BDataOutput {
public:
virtual ~BDataOutput();

virtual status_t WriteData(const void* buffer, size_t size) = 0;
};


class BBufferDataOutput : public BDataOutput {
public:
BBufferDataOutput(void* buffer, size_t size);

size_t BytesWritten() const { return fBytesWritten; }

virtual status_t Write(const void* buffer, size_t size);
virtual ssize_t Read(void* buffer, size_t size)
{ return B_NOT_SUPPORTED; }
virtual status_t WriteData(const void* buffer, size_t size);

private:
void* fBuffer;
Expand Down
10 changes: 5 additions & 5 deletions headers/os/package/hpkg/DataReader.h
Expand Up @@ -9,14 +9,14 @@
#include <SupportDefs.h>


class BDataIO;


namespace BPackageKit {

namespace BHPKG {


class BDataOutput;


class BDataReader {
public:
virtual ~BDataReader();
Expand All @@ -33,7 +33,7 @@ class BAbstractBufferedDataReader : public BDataReader {
virtual status_t ReadData(off_t offset, void* buffer,
size_t size);
virtual status_t ReadDataToOutput(off_t offset, size_t size,
BDataIO* output) = 0;
BDataOutput* output) = 0;
};


Expand Down Expand Up @@ -73,7 +73,7 @@ class BBufferDataReader : public BAbstractBufferedDataReader {
virtual status_t ReadData(off_t offset, void* buffer,
size_t size);
virtual status_t ReadDataToOutput(off_t offset, size_t size,
BDataIO* output);
BDataOutput* output);

private:
const void* fData;
Expand Down
6 changes: 3 additions & 3 deletions headers/private/package/hpkg/DataWriters.h
Expand Up @@ -7,7 +7,7 @@
#define _PACKAGE__HPKG__PRIVATE__DATA_WRITERS_H_


#include <package/hpkg/BufferDataOutput.h>
#include <package/hpkg/DataOutput.h>
#include <package/hpkg/ZlibCompressor.h>


Expand Down Expand Up @@ -59,7 +59,7 @@ class FDDataWriter : public AbstractDataWriter {
};


class ZlibDataWriter : public AbstractDataWriter, private BDataIO {
class ZlibDataWriter : public AbstractDataWriter, private BDataOutput {
public:
ZlibDataWriter(AbstractDataWriter* dataWriter);

Expand All @@ -71,7 +71,7 @@ class ZlibDataWriter : public AbstractDataWriter, private BDataIO {

private:
// BDataOutput
virtual status_t Write(const void* buffer, size_t size);
virtual status_t WriteData(const void* buffer, size_t size);

private:
AbstractDataWriter* fDataWriter;
Expand Down
2 changes: 1 addition & 1 deletion headers/private/package/hpkg/PackageFileHeapAccessorBase.h
Expand Up @@ -49,7 +49,7 @@ class PackageFileHeapAccessorBase : public BAbstractBufferedDataReader {

// BAbstractBufferedDataReader
virtual status_t ReadDataToOutput(off_t offset, size_t size,
BDataIO* output);
BDataOutput* output);

public:
static const size_t kChunkSize = 64 * 1024;
Expand Down
2 changes: 1 addition & 1 deletion headers/private/package/hpkg/WriterImplBase.h
Expand Up @@ -10,7 +10,7 @@

#include <package/hpkg/HPKGDefsPrivate.h>

#include <package/hpkg/BufferDataOutput.h>
#include <package/hpkg/DataOutput.h>
#include <package/hpkg/DataWriters.h>
#include <package/hpkg/PackageWriter.h>
#include <package/hpkg/Strings.h>
Expand Down
Expand Up @@ -2,13 +2,17 @@
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#ifndef _PRIVATE__ZLIB_COMPRESSION_BASE_H_
#define _PRIVATE__ZLIB_COMPRESSION_BASE_H_
#ifndef _PACKAGE__HPKG__PRIVATE__ZLIB_COMPRESSION_BASE_H_
#define _PACKAGE__HPKG__PRIVATE__ZLIB_COMPRESSION_BASE_H_


#include <SupportDefs.h>


namespace BPackageKit {

namespace BHPKG {

namespace BPrivate {


Expand All @@ -20,4 +24,9 @@ class ZlibCompressionBase {

} // namespace BPrivate

#endif // _PRIVATE__ZLIB_COMPRESSION_BASE_H_
} // namespace BHPKG

} // namespace BPackageKit


#endif // _PACKAGE__HPKG__PRIVATE__ZLIB_COMPRESSION_BASE_H_
14 changes: 7 additions & 7 deletions headers/private/package/hpkg/ZlibCompressor.h
Expand Up @@ -8,23 +8,23 @@

#include <zlib.h>

#include <ZlibCompressionBase.h>


class BDataIO;
#include <package/hpkg/ZlibCompressionBase.h>


namespace BPackageKit {

namespace BHPKG {


class BDataOutput;


namespace BPrivate {


class ZlibCompressor : public ::BPrivate::ZlibCompressionBase {
class ZlibCompressor : public ZlibCompressionBase {
public:
ZlibCompressor(BDataIO* output);
ZlibCompressor(BDataOutput* output);
~ZlibCompressor();

status_t Init(int compressionLevel = Z_BEST_COMPRESSION);
Expand All @@ -39,7 +39,7 @@ class ZlibCompressor : public ::BPrivate::ZlibCompressionBase {

private:
z_stream fStream;
BDataIO* fOutput;
BDataOutput* fOutput;
bool fStreamInitialized;
};

Expand Down
Expand Up @@ -2,24 +2,29 @@
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#ifndef _PRIVATE__ZLIB_DECOMPRESSOR_H_
#define _PRIVATE__ZLIB_DECOMPRESSOR_H_
#ifndef _PACKAGE__HPKG__PRIVATE__ZLIB_DECOMPRESSOR_H_
#define _PACKAGE__HPKG__PRIVATE__ZLIB_DECOMPRESSOR_H_


#include <zlib.h>

#include <ZlibCompressionBase.h>
#include <package/hpkg/ZlibCompressionBase.h>


class BDataIO;
namespace BPackageKit {

namespace BHPKG {


class BDataOutput;


namespace BPrivate {


class ZlibDecompressor : public ZlibCompressionBase {
public:
ZlibDecompressor(BDataIO* output);
ZlibDecompressor(BDataOutput* output);
~ZlibDecompressor();

status_t Init();
Expand All @@ -34,12 +39,17 @@ class ZlibDecompressor : public ZlibCompressionBase {

private:
z_stream fStream;
BDataIO* fOutput;
BDataOutput* fOutput;
bool fStreamInitialized;
bool fFinished;
};


} // namespace BPrivate

} // namespace BHPKG

} // namespace BPackageKit


#endif // _PACKAGE__HPKG__PRIVATE__ZLIB_DECOMPRESSOR_H_
17 changes: 5 additions & 12 deletions src/add-ons/kernel/file_systems/packagefs/Jamfile
Expand Up @@ -75,8 +75,8 @@ HAIKU_PACKAGE_FS_SHARED_SOURCES =

HAIKU_PACKAGE_FS_PACKAGE_READER_SOURCES =
BlockBufferPoolImpl.cpp
BufferDataOutput.cpp
BufferPool.cpp
DataOutput.cpp
DataReader.cpp
ErrorOutput.cpp
FDDataReader.cpp
Expand All @@ -91,6 +91,10 @@ HAIKU_PACKAGE_FS_PACKAGE_READER_SOURCES =
PackageFileHeapReader.cpp
PackageReaderImpl.cpp
ReaderImplBase.cpp

# compression
ZlibCompressionBase.cpp
ZlibDecompressor.cpp
;

HAIKU_PACKAGE_FS_PACKAGE_READER_SOURCES_V1 =
Expand All @@ -111,14 +115,6 @@ Includes

local libSharedSources =
NaturalCompare.cpp

# compression
ZlibCompressionBase.cpp
ZlibDecompressor.cpp
;

local supportKitSources =
DataIO.cpp
;


Expand All @@ -129,7 +125,6 @@ KernelAddon packagefs
$(HAIKU_PACKAGE_FS_PACKAGE_READER_SOURCES)
$(HAIKU_PACKAGE_FS_PACKAGE_READER_SOURCES_V1)
$(libSharedSources)
$(supportKitSources)

: $(TARGET_KERNEL_LIBSUPC++) kernel_libz.a
;
Expand All @@ -143,5 +138,3 @@ SEARCH on [ FGristFiles $(HAIKU_PACKAGE_FS_PACKAGE_READER_SOURCES_V1) ]
+= [ FDirName $(HAIKU_TOP) src kits package hpkg v1 ] ;
SEARCH on [ FGristFiles $(libSharedSources) ]
+= [ FDirName $(HAIKU_TOP) src kits shared ] ;
SEARCH on [ FGristFiles $(supportKitSources) ]
+= [ FDirName $(HAIKU_TOP) src kits support ] ;
Expand Up @@ -31,7 +31,7 @@ page_physical_number_less(const vm_page* a, const vm_page* b)
// #pragma mark - PagesDataOutput


struct CachedDataReader::PagesDataOutput : public BDataIO {
struct CachedDataReader::PagesDataOutput : public BDataOutput {
PagesDataOutput(vm_page** pages, size_t pageCount)
:
fPages(pages),
Expand All @@ -40,7 +40,7 @@ struct CachedDataReader::PagesDataOutput : public BDataIO {
{
}

virtual status_t Write(const void* buffer, size_t size)
virtual status_t WriteData(const void* buffer, size_t size)
{
while (size > 0) {
if (fPageCount == 0)
Expand All @@ -67,11 +67,6 @@ struct CachedDataReader::PagesDataOutput : public BDataIO {
return B_OK;
}

virtual ssize_t Read(void* buffer, size_t size)
{
return B_NOT_SUPPORTED;
}

private:
vm_page** fPages;
size_t fPageCount;
Expand Down Expand Up @@ -137,7 +132,7 @@ CachedDataReader::ReadData(off_t offset, void* buffer, size_t size)

status_t
CachedDataReader::ReadDataToOutput(off_t offset, size_t size,
BDataIO* output)
BDataOutput* output)
{
if (offset > fCache->virtual_end
|| (off_t)size > fCache->virtual_end - offset) {
Expand Down Expand Up @@ -173,7 +168,7 @@ CachedDataReader::ReadDataToOutput(off_t offset, size_t size,

status_t
CachedDataReader::_ReadCacheLine(off_t lineOffset, size_t lineSize,
off_t requestOffset, size_t requestLength, BDataIO* output)
off_t requestOffset, size_t requestLength, BDataOutput* output)
{
PRINT("CachedDataReader::_ReadCacheLine(%" B_PRIdOFF ", %zu, %" B_PRIdOFF
", %zu, %p\n", lineOffset, lineSize, requestOffset, requestLength,
Expand Down Expand Up @@ -371,7 +366,7 @@ CachedDataReader::_CachePages(vm_page** pages, size_t firstPage,
*/
status_t
CachedDataReader::_WritePages(vm_page** pages, size_t pagesRelativeOffset,
size_t requestLength, BDataIO* output)
size_t requestLength, BDataOutput* output)
{
PRINT("%p->CachedDataReader::_WritePages(%" B_PRIuSIZE ", %" B_PRIuSIZE
", %p)\n", this, pagesRelativeOffset, requestLength, output);
Expand All @@ -394,7 +389,7 @@ CachedDataReader::_WritePages(vm_page** pages, size_t pagesRelativeOffset,

// write the page's data
size_t toCopy = std::min(B_PAGE_SIZE - inPageOffset, requestLength);
error = output->Write((uint8*)(address + inPageOffset), toCopy);
error = output->WriteData((uint8*)(address + inPageOffset), toCopy);

// unmap the page
vm_put_physical_page(address, handle);
Expand Down

0 comments on commit d2d1af8

Please sign in to comment.