From 9af2105d36856be60528c361edf14a263f242338 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 10 Feb 2014 18:21:50 +0100 Subject: [PATCH] Move ZlibDecompressor to libshared * This will be used to implement compressed http streams * Remove the custom BDataOutput class, and use BDataIO instead, for easier integration with existing code. --- .../hpkg/{DataOutput.h => BufferDataOutput.h} | 0 .../package/hpkg/ZlibCompressionBase.h | 1 - .../private/package/hpkg/ZlibDecompressor.h | 1 - .../private/shared/ZlibCompressionBase.h | 1 + .../build/private/shared/ZlibDecompressor.h | 1 + .../hpkg/{DataOutput.h => BufferDataOutput.h} | 15 +++++-------- headers/os/package/hpkg/DataReader.h | 10 ++++----- headers/private/package/hpkg/DataWriters.h | 6 ++--- .../hpkg/PackageFileHeapAccessorBase.h | 2 +- headers/private/package/hpkg/WriterImplBase.h | 2 +- headers/private/package/hpkg/ZlibCompressor.h | 14 ++++++------ .../hpkg => shared}/ZlibCompressionBase.h | 15 +++---------- .../hpkg => shared}/ZlibDecompressor.h | 22 +++++-------------- .../kernel/file_systems/packagefs/Jamfile | 17 +++++++++----- .../packagefs/package/CachedDataReader.cpp | 17 +++++++++----- .../packagefs/package/CachedDataReader.h | 10 +++++---- .../packagefs/package/Package.cpp | 1 - .../packagefs/package/PackageFile.cpp | 9 ++++++-- src/build/libpackage/Jamfile | 6 ++--- src/build/libshared/Jamfile | 4 ++++ src/kits/package/Jamfile | 4 +--- .../{DataOutput.cpp => BufferDataOutput.cpp} | 12 ++-------- src/kits/package/hpkg/DataReader.cpp | 7 +++--- src/kits/package/hpkg/DataWriters.cpp | 2 +- src/kits/package/hpkg/PackageDataReader.cpp | 4 ++-- .../hpkg/PackageFileHeapAccessorBase.cpp | 12 +++++----- src/kits/package/hpkg/PackageReaderImpl.cpp | 4 ++-- src/kits/package/hpkg/PackageWriterImpl.cpp | 2 +- src/kits/package/hpkg/ReaderImplBase.cpp | 4 ++-- src/kits/package/hpkg/ZlibCompressor.cpp | 8 +++---- .../package/hpkg/v1/PackageDataReaderV1.cpp | 14 ++++++------ .../package/hpkg/v1/PackageReaderImplV1.cpp | 4 ++-- src/kits/package/hpkg/v1/ReaderImplBaseV1.cpp | 6 ++--- src/kits/shared/Jamfile | 9 ++++++++ .../hpkg => shared}/ZlibCompressionBase.cpp | 10 +-------- .../hpkg => shared}/ZlibDecompressor.cpp | 18 +++++---------- .../loader/file_systems/packagefs/Jamfile | 5 ++++- 37 files changed, 131 insertions(+), 148 deletions(-) rename headers/build/os/package/hpkg/{DataOutput.h => BufferDataOutput.h} (100%) delete mode 100644 headers/build/private/package/hpkg/ZlibCompressionBase.h delete mode 100644 headers/build/private/package/hpkg/ZlibDecompressor.h create mode 100644 headers/build/private/shared/ZlibCompressionBase.h create mode 100644 headers/build/private/shared/ZlibDecompressor.h rename headers/os/package/hpkg/{DataOutput.h => BufferDataOutput.h} (69%) rename headers/private/{package/hpkg => shared}/ZlibCompressionBase.h (50%) rename headers/private/{package/hpkg => shared}/ZlibDecompressor.h (67%) rename src/kits/package/hpkg/{DataOutput.cpp => BufferDataOutput.cpp} (78%) rename src/kits/{package/hpkg => shared}/ZlibCompressionBase.cpp (84%) rename src/kits/{package/hpkg => shared}/ZlibDecompressor.cpp (91%) diff --git a/headers/build/os/package/hpkg/DataOutput.h b/headers/build/os/package/hpkg/BufferDataOutput.h similarity index 100% rename from headers/build/os/package/hpkg/DataOutput.h rename to headers/build/os/package/hpkg/BufferDataOutput.h diff --git a/headers/build/private/package/hpkg/ZlibCompressionBase.h b/headers/build/private/package/hpkg/ZlibCompressionBase.h deleted file mode 100644 index 052cfd0bde..0000000000 --- a/headers/build/private/package/hpkg/ZlibCompressionBase.h +++ /dev/null @@ -1 +0,0 @@ -#include <../private/package/hpkg/ZlibCompressionBase.h> diff --git a/headers/build/private/package/hpkg/ZlibDecompressor.h b/headers/build/private/package/hpkg/ZlibDecompressor.h deleted file mode 100644 index 698aca62f9..0000000000 --- a/headers/build/private/package/hpkg/ZlibDecompressor.h +++ /dev/null @@ -1 +0,0 @@ -#include <../private/package/hpkg/ZlibDecompressor.h> diff --git a/headers/build/private/shared/ZlibCompressionBase.h b/headers/build/private/shared/ZlibCompressionBase.h new file mode 100644 index 0000000000..09353da0ea --- /dev/null +++ b/headers/build/private/shared/ZlibCompressionBase.h @@ -0,0 +1 @@ +#include <../private/shared/ZlibCompressionBase.h> diff --git a/headers/build/private/shared/ZlibDecompressor.h b/headers/build/private/shared/ZlibDecompressor.h new file mode 100644 index 0000000000..a1706144f7 --- /dev/null +++ b/headers/build/private/shared/ZlibDecompressor.h @@ -0,0 +1 @@ +#include <../private/shared/ZlibDecompressor.h> diff --git a/headers/os/package/hpkg/DataOutput.h b/headers/os/package/hpkg/BufferDataOutput.h similarity index 69% rename from headers/os/package/hpkg/DataOutput.h rename to headers/os/package/hpkg/BufferDataOutput.h index 290937adab..10af41c40f 100644 --- a/headers/os/package/hpkg/DataOutput.h +++ b/headers/os/package/hpkg/BufferDataOutput.h @@ -6,6 +6,7 @@ #define _PACKAGE__HPKG__DATA_OUTPUT_H_ +#include #include @@ -14,21 +15,15 @@ namespace BPackageKit { namespace BHPKG { -class BDataOutput { -public: - virtual ~BDataOutput(); - - virtual status_t WriteData(const void* buffer, size_t size) = 0; -}; - - -class BBufferDataOutput : public BDataOutput { +class BBufferDataOutput : public BDataIO { public: BBufferDataOutput(void* buffer, size_t size); size_t BytesWritten() const { return fBytesWritten; } - virtual status_t WriteData(const void* buffer, size_t size); + virtual status_t Write(const void* buffer, size_t size); + virtual ssize_t Read(void* buffer, size_t size) + { return B_NOT_SUPPORTED; } private: void* fBuffer; diff --git a/headers/os/package/hpkg/DataReader.h b/headers/os/package/hpkg/DataReader.h index 2590415fba..6d103ec68e 100644 --- a/headers/os/package/hpkg/DataReader.h +++ b/headers/os/package/hpkg/DataReader.h @@ -9,14 +9,14 @@ #include +class BDataIO; + + namespace BPackageKit { namespace BHPKG { -class BDataOutput; - - class BDataReader { public: virtual ~BDataReader(); @@ -33,7 +33,7 @@ public: virtual status_t ReadData(off_t offset, void* buffer, size_t size); virtual status_t ReadDataToOutput(off_t offset, size_t size, - BDataOutput* output) = 0; + BDataIO* output) = 0; }; @@ -73,7 +73,7 @@ public: virtual status_t ReadData(off_t offset, void* buffer, size_t size); virtual status_t ReadDataToOutput(off_t offset, size_t size, - BDataOutput* output); + BDataIO* output); private: const void* fData; diff --git a/headers/private/package/hpkg/DataWriters.h b/headers/private/package/hpkg/DataWriters.h index 26f67cf411..20e0729997 100644 --- a/headers/private/package/hpkg/DataWriters.h +++ b/headers/private/package/hpkg/DataWriters.h @@ -7,7 +7,7 @@ #define _PACKAGE__HPKG__PRIVATE__DATA_WRITERS_H_ -#include +#include #include @@ -59,7 +59,7 @@ private: }; -class ZlibDataWriter : public AbstractDataWriter, private BDataOutput { +class ZlibDataWriter : public AbstractDataWriter, private BDataIO { public: ZlibDataWriter(AbstractDataWriter* dataWriter); @@ -71,7 +71,7 @@ public: private: // BDataOutput - virtual status_t WriteData(const void* buffer, size_t size); + virtual status_t Write(const void* buffer, size_t size); private: AbstractDataWriter* fDataWriter; diff --git a/headers/private/package/hpkg/PackageFileHeapAccessorBase.h b/headers/private/package/hpkg/PackageFileHeapAccessorBase.h index 47ae47f161..84ce06ee76 100644 --- a/headers/private/package/hpkg/PackageFileHeapAccessorBase.h +++ b/headers/private/package/hpkg/PackageFileHeapAccessorBase.h @@ -49,7 +49,7 @@ public: // BAbstractBufferedDataReader virtual status_t ReadDataToOutput(off_t offset, size_t size, - BDataOutput* output); + BDataIO* output); public: static const size_t kChunkSize = 64 * 1024; diff --git a/headers/private/package/hpkg/WriterImplBase.h b/headers/private/package/hpkg/WriterImplBase.h index 0686335ca6..66c6e0a556 100644 --- a/headers/private/package/hpkg/WriterImplBase.h +++ b/headers/private/package/hpkg/WriterImplBase.h @@ -10,7 +10,7 @@ #include -#include +#include #include #include #include diff --git a/headers/private/package/hpkg/ZlibCompressor.h b/headers/private/package/hpkg/ZlibCompressor.h index 4f6dd141f7..9d73f2bb67 100644 --- a/headers/private/package/hpkg/ZlibCompressor.h +++ b/headers/private/package/hpkg/ZlibCompressor.h @@ -8,7 +8,10 @@ #include -#include +#include + + +class BDataIO; namespace BPackageKit { @@ -16,15 +19,12 @@ namespace BPackageKit { namespace BHPKG { -class BDataOutput; - - namespace BPrivate { -class ZlibCompressor : public ZlibCompressionBase { +class ZlibCompressor : public ::BPrivate::ZlibCompressionBase { public: - ZlibCompressor(BDataOutput* output); + ZlibCompressor(BDataIO* output); ~ZlibCompressor(); status_t Init(int compressionLevel = Z_BEST_COMPRESSION); @@ -39,7 +39,7 @@ public: private: z_stream fStream; - BDataOutput* fOutput; + BDataIO* fOutput; bool fStreamInitialized; }; diff --git a/headers/private/package/hpkg/ZlibCompressionBase.h b/headers/private/shared/ZlibCompressionBase.h similarity index 50% rename from headers/private/package/hpkg/ZlibCompressionBase.h rename to headers/private/shared/ZlibCompressionBase.h index 786e579908..2ebfbb0ce9 100644 --- a/headers/private/package/hpkg/ZlibCompressionBase.h +++ b/headers/private/shared/ZlibCompressionBase.h @@ -2,17 +2,13 @@ * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ -#ifndef _PACKAGE__HPKG__PRIVATE__ZLIB_COMPRESSION_BASE_H_ -#define _PACKAGE__HPKG__PRIVATE__ZLIB_COMPRESSION_BASE_H_ +#ifndef _PRIVATE__ZLIB_COMPRESSION_BASE_H_ +#define _PRIVATE__ZLIB_COMPRESSION_BASE_H_ #include -namespace BPackageKit { - -namespace BHPKG { - namespace BPrivate { @@ -24,9 +20,4 @@ public: } // namespace BPrivate -} // namespace BHPKG - -} // namespace BPackageKit - - -#endif // _PACKAGE__HPKG__PRIVATE__ZLIB_COMPRESSION_BASE_H_ +#endif // _PRIVATE__ZLIB_COMPRESSION_BASE_H_ diff --git a/headers/private/package/hpkg/ZlibDecompressor.h b/headers/private/shared/ZlibDecompressor.h similarity index 67% rename from headers/private/package/hpkg/ZlibDecompressor.h rename to headers/private/shared/ZlibDecompressor.h index 8d4556b236..2d1efab4cc 100644 --- a/headers/private/package/hpkg/ZlibDecompressor.h +++ b/headers/private/shared/ZlibDecompressor.h @@ -2,21 +2,16 @@ * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ -#ifndef _PACKAGE__HPKG__PRIVATE__ZLIB_DECOMPRESSOR_H_ -#define _PACKAGE__HPKG__PRIVATE__ZLIB_DECOMPRESSOR_H_ +#ifndef _PRIVATE__ZLIB_DECOMPRESSOR_H_ +#define _PRIVATE__ZLIB_DECOMPRESSOR_H_ #include -#include +#include -namespace BPackageKit { - -namespace BHPKG { - - -class BDataOutput; +class BDataIO; namespace BPrivate { @@ -24,7 +19,7 @@ namespace BPrivate { class ZlibDecompressor : public ZlibCompressionBase { public: - ZlibDecompressor(BDataOutput* output); + ZlibDecompressor(BDataIO* output); ~ZlibDecompressor(); status_t Init(); @@ -39,7 +34,7 @@ public: private: z_stream fStream; - BDataOutput* fOutput; + BDataIO* fOutput; bool fStreamInitialized; bool fFinished; }; @@ -47,9 +42,4 @@ private: } // namespace BPrivate -} // namespace BHPKG - -} // namespace BPackageKit - - #endif // _PACKAGE__HPKG__PRIVATE__ZLIB_DECOMPRESSOR_H_ diff --git a/src/add-ons/kernel/file_systems/packagefs/Jamfile b/src/add-ons/kernel/file_systems/packagefs/Jamfile index 2f3004a288..601bea20e7 100644 --- a/src/add-ons/kernel/file_systems/packagefs/Jamfile +++ b/src/add-ons/kernel/file_systems/packagefs/Jamfile @@ -74,8 +74,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 @@ -90,10 +90,6 @@ HAIKU_PACKAGE_FS_PACKAGE_READER_SOURCES = PackageFileHeapReader.cpp PackageReaderImpl.cpp ReaderImplBase.cpp - - # compression - ZlibCompressionBase.cpp - ZlibDecompressor.cpp ; HAIKU_PACKAGE_FS_PACKAGE_READER_SOURCES_V1 = @@ -114,6 +110,14 @@ Includes local libSharedSources = NaturalCompare.cpp + + # compression + ZlibCompressionBase.cpp + ZlibDecompressor.cpp +; + +local supportKitSources = + DataIO.cpp ; @@ -124,6 +128,7 @@ KernelAddon packagefs $(HAIKU_PACKAGE_FS_PACKAGE_READER_SOURCES) $(HAIKU_PACKAGE_FS_PACKAGE_READER_SOURCES_V1) $(libSharedSources) + $(supportKitSources) : $(TARGET_KERNEL_LIBSUPC++) kernel_libz.a ; @@ -137,3 +142,5 @@ 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 ] ; diff --git a/src/add-ons/kernel/file_systems/packagefs/package/CachedDataReader.cpp b/src/add-ons/kernel/file_systems/packagefs/package/CachedDataReader.cpp index fa6f3fc990..ac7c2463c3 100644 --- a/src/add-ons/kernel/file_systems/packagefs/package/CachedDataReader.cpp +++ b/src/add-ons/kernel/file_systems/packagefs/package/CachedDataReader.cpp @@ -31,7 +31,7 @@ page_physical_number_less(const vm_page* a, const vm_page* b) // #pragma mark - PagesDataOutput -struct CachedDataReader::PagesDataOutput : public BDataOutput { +struct CachedDataReader::PagesDataOutput : public BDataIO { PagesDataOutput(vm_page** pages, size_t pageCount) : fPages(pages), @@ -40,7 +40,7 @@ struct CachedDataReader::PagesDataOutput : public BDataOutput { { } - virtual status_t WriteData(const void* buffer, size_t size) + virtual status_t Write(const void* buffer, size_t size) { while (size > 0) { if (fPageCount == 0) @@ -67,6 +67,11 @@ struct CachedDataReader::PagesDataOutput : public BDataOutput { return B_OK; } + virtual ssize_t Read(void* buffer, size_t size) + { + return B_NOT_SUPPORTED; + } + private: vm_page** fPages; size_t fPageCount; @@ -132,7 +137,7 @@ CachedDataReader::ReadData(off_t offset, void* buffer, size_t size) status_t CachedDataReader::ReadDataToOutput(off_t offset, size_t size, - BDataOutput* output) + BDataIO* output) { if (offset > fCache->virtual_end || (off_t)size > fCache->virtual_end - offset) { @@ -168,7 +173,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, BDataOutput* output) + off_t requestOffset, size_t requestLength, BDataIO* output) { PRINT("CachedDataReader::_ReadCacheLine(%" B_PRIdOFF ", %zu, %" B_PRIdOFF ", %zu, %p\n", lineOffset, lineSize, requestOffset, requestLength, @@ -366,7 +371,7 @@ CachedDataReader::_CachePages(vm_page** pages, size_t firstPage, */ status_t CachedDataReader::_WritePages(vm_page** pages, size_t pagesRelativeOffset, - size_t requestLength, BDataOutput* output) + size_t requestLength, BDataIO* output) { PRINT("%p->CachedDataReader::_WritePages(%" B_PRIuSIZE ", %" B_PRIuSIZE ", %p)\n", this, pagesRelativeOffset, requestLength, output); @@ -389,7 +394,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->WriteData((uint8*)(address + inPageOffset), toCopy); + error = output->Write((uint8*)(address + inPageOffset), toCopy); // unmap the page vm_put_physical_page(address, handle); diff --git a/src/add-ons/kernel/file_systems/packagefs/package/CachedDataReader.h b/src/add-ons/kernel/file_systems/packagefs/package/CachedDataReader.h index 7cba87ca4e..847e16d28d 100644 --- a/src/add-ons/kernel/file_systems/packagefs/package/CachedDataReader.h +++ b/src/add-ons/kernel/file_systems/packagefs/package/CachedDataReader.h @@ -15,10 +15,12 @@ using BPackageKit::BHPKG::BAbstractBufferedDataReader; -using BPackageKit::BHPKG::BDataOutput; using BPackageKit::BHPKG::BDataReader; +class BDataIO; + + class CachedDataReader : public BAbstractBufferedDataReader { public: CachedDataReader(); @@ -30,7 +32,7 @@ public: virtual status_t ReadData(off_t offset, void* buffer, size_t size); virtual status_t ReadDataToOutput(off_t offset, size_t size, - BDataOutput* output); + BDataIO* output); private: class CacheLineLocker @@ -121,7 +123,7 @@ private: private: status_t _ReadCacheLine(off_t lineOffset, size_t lineSize, off_t requestOffset, - size_t requestLength, BDataOutput* output); + size_t requestLength, BDataIO* output); void _DiscardPages(vm_page** pages, size_t firstPage, size_t pageCount); @@ -129,7 +131,7 @@ private: size_t pageCount); status_t _WritePages(vm_page** pages, size_t pagesRelativeOffset, - size_t requestLength, BDataOutput* output); + size_t requestLength, BDataIO* output); status_t _ReadIntoPages(vm_page** pages, size_t firstPage, size_t pageCount); diff --git a/src/add-ons/kernel/file_systems/packagefs/package/Package.cpp b/src/add-ons/kernel/file_systems/packagefs/package/Package.cpp index 8d54f7891a..f42db7014e 100644 --- a/src/add-ons/kernel/file_systems/packagefs/package/Package.cpp +++ b/src/add-ons/kernel/file_systems/packagefs/package/Package.cpp @@ -38,7 +38,6 @@ using namespace BPackageKit; -using BPackageKit::BHPKG::BDataOutput; using BPackageKit::BHPKG::BErrorOutput; using BPackageKit::BHPKG::BFDDataReader; using BPackageKit::BHPKG::BPackageInfoAttributeValue; diff --git a/src/add-ons/kernel/file_systems/packagefs/package/PackageFile.cpp b/src/add-ons/kernel/file_systems/packagefs/package/PackageFile.cpp index 01abec7ee1..0db672df5c 100644 --- a/src/add-ons/kernel/file_systems/packagefs/package/PackageFile.cpp +++ b/src/add-ons/kernel/file_systems/packagefs/package/PackageFile.cpp @@ -29,7 +29,7 @@ using namespace BPackageKit::BHPKG; // #pragma mark - DataAccessor -struct PackageFile::IORequestOutput : BDataOutput { +struct PackageFile::IORequestOutput : BDataIO { public: IORequestOutput(io_request* request) : @@ -37,11 +37,16 @@ public: { } - virtual status_t WriteData(const void* buffer, size_t size) + virtual status_t Write(const void* buffer, size_t size) { RETURN_ERROR(write_to_io_request(fRequest, buffer, size)); } + virtual ssize_t Read(void* buffer, size_t size) + { + return B_NOT_SUPPORTED; + } + private: io_request* fRequest; }; diff --git a/src/build/libpackage/Jamfile b/src/build/libpackage/Jamfile index 464f40625b..be248fd836 100644 --- a/src/build/libpackage/Jamfile +++ b/src/build/libpackage/Jamfile @@ -1,6 +1,6 @@ SubDir HAIKU_TOP src build libpackage ; -UsePrivateBuildHeaders kernel package shared storage ; +UsePrivateBuildHeaders kernel package shared storage support ; SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src kits package ] ; SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src kits package hpkg ] ; @@ -33,9 +33,9 @@ HPKG_SOURCES = BlockBufferPool.cpp BlockBufferPoolImpl.cpp BlockBufferPoolNoLock.cpp + BufferDataOutput.cpp BufferPool.cpp PoolBuffer.cpp - DataOutput.cpp DataReader.cpp DataWriters.cpp ErrorOutput.cpp @@ -77,9 +77,7 @@ HPKG_SOURCES = ReaderImplBaseV1.cpp # compression - ZlibCompressionBase.cpp ZlibCompressor.cpp - ZlibDecompressor.cpp ; # TODO: remove this hack once gcc2 has -iquote implemented diff --git a/src/build/libshared/Jamfile b/src/build/libshared/Jamfile index 44984b7097..f42f7f7b8e 100644 --- a/src/build/libshared/Jamfile +++ b/src/build/libshared/Jamfile @@ -10,4 +10,8 @@ BuildPlatformStaticLibraryPIC libshared_build.a : Keymap.cpp NaturalCompare.cpp SHA256.cpp + + # compression + ZlibCompressionBase.cpp + ZlibDecompressor.cpp ; diff --git a/src/kits/package/Jamfile b/src/kits/package/Jamfile index d63e86b0af..d17dac71e0 100644 --- a/src/kits/package/Jamfile +++ b/src/kits/package/Jamfile @@ -12,8 +12,8 @@ HPKG_SOURCES = BlockBufferPool.cpp BlockBufferPoolImpl.cpp BlockBufferPoolNoLock.cpp + BufferDataOutput.cpp BufferPool.cpp - DataOutput.cpp DataReader.cpp DataWriters.cpp ErrorOutput.cpp @@ -56,9 +56,7 @@ HPKG_SOURCES = ReaderImplBaseV1.cpp # compression - ZlibCompressionBase.cpp ZlibCompressor.cpp - ZlibDecompressor.cpp ; local architectureObject ; diff --git a/src/kits/package/hpkg/DataOutput.cpp b/src/kits/package/hpkg/BufferDataOutput.cpp similarity index 78% rename from src/kits/package/hpkg/DataOutput.cpp rename to src/kits/package/hpkg/BufferDataOutput.cpp index 00694b31cd..8ae25437a4 100644 --- a/src/kits/package/hpkg/DataOutput.cpp +++ b/src/kits/package/hpkg/BufferDataOutput.cpp @@ -4,7 +4,7 @@ */ -#include +#include #include @@ -14,14 +14,6 @@ namespace BPackageKit { namespace BHPKG { -// #pragma mark - BDataOutput - - -BDataOutput::~BDataOutput() -{ -} - - // #pragma mark - BBufferDataOutput @@ -35,7 +27,7 @@ BBufferDataOutput::BBufferDataOutput(void* buffer, size_t size) status_t -BBufferDataOutput::WriteData(const void* buffer, size_t size) +BBufferDataOutput::Write(const void* buffer, size_t size) { if (size == 0) return B_OK; diff --git a/src/kits/package/hpkg/DataReader.cpp b/src/kits/package/hpkg/DataReader.cpp index b47f988a2f..eb1a81c762 100644 --- a/src/kits/package/hpkg/DataReader.cpp +++ b/src/kits/package/hpkg/DataReader.cpp @@ -6,7 +6,8 @@ #include -#include +#include +#include #include @@ -70,7 +71,7 @@ BBufferDataReader::ReadData(off_t offset, void* buffer, size_t size) status_t BBufferDataReader::ReadDataToOutput(off_t offset, size_t size, - BDataOutput* output) + BDataIO* output) { if (size == 0) return B_OK; @@ -81,7 +82,7 @@ BBufferDataReader::ReadDataToOutput(off_t offset, size_t size, if (size > fSize || offset > (off_t)fSize - (off_t)size) return B_ERROR; - return output->WriteData((const uint8*)fData + offset, size); + return output->Write((const uint8*)fData + offset, size); } diff --git a/src/kits/package/hpkg/DataWriters.cpp b/src/kits/package/hpkg/DataWriters.cpp index 29318c890d..a22dcd01eb 100644 --- a/src/kits/package/hpkg/DataWriters.cpp +++ b/src/kits/package/hpkg/DataWriters.cpp @@ -112,7 +112,7 @@ ZlibDataWriter::WriteDataNoThrow(const void* buffer, status_t -ZlibDataWriter::WriteData(const void* buffer, size_t size) +ZlibDataWriter::Write(const void* buffer, size_t size) { return fDataWriter->WriteDataNoThrow(buffer, size); } diff --git a/src/kits/package/hpkg/PackageDataReader.cpp b/src/kits/package/hpkg/PackageDataReader.cpp index 9c808fec44..3f0d32653c 100644 --- a/src/kits/package/hpkg/PackageDataReader.cpp +++ b/src/kits/package/hpkg/PackageDataReader.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include namespace BPackageKit { @@ -53,7 +53,7 @@ public: } virtual status_t ReadDataToOutput(off_t offset, size_t size, - BDataOutput* output) + BDataIO* output) { if (size == 0) return B_OK; diff --git a/src/kits/package/hpkg/PackageFileHeapAccessorBase.cpp b/src/kits/package/hpkg/PackageFileHeapAccessorBase.cpp index 024b8f21e9..3ffa2a8756 100644 --- a/src/kits/package/hpkg/PackageFileHeapAccessorBase.cpp +++ b/src/kits/package/hpkg/PackageFileHeapAccessorBase.cpp @@ -14,11 +14,11 @@ #include #include -#include +#include #include #include -#include +#include namespace BPackageKit { @@ -140,7 +140,7 @@ PackageFileHeapAccessorBase::~PackageFileHeapAccessorBase() status_t PackageFileHeapAccessorBase::ReadDataToOutput(off_t offset, size_t size, - BDataOutput* output) + BDataIO* output) { if (size == 0) return B_OK; @@ -174,8 +174,8 @@ PackageFileHeapAccessorBase::ReadDataToOutput(off_t offset, size_t size, // The last chunk may be shorter than kChunkSize, but since // size (and thus remainingSize) had been clamped, that doesn't // harm. - error = output->WriteData( - (char*)uncompressedDataBuffer + inChunkOffset, toWrite); + error = output->Write((char*)uncompressedDataBuffer + inChunkOffset, + toWrite); if (error != B_OK) return error; @@ -213,7 +213,7 @@ PackageFileHeapAccessorBase::DecompressChunkData(void* compressedDataBuffer, size_t uncompressedSize) { size_t actualSize; - status_t error = ZlibDecompressor::DecompressSingleBuffer( + status_t error = ::BPrivate::ZlibDecompressor::DecompressSingleBuffer( compressedDataBuffer, compressedSize, uncompressedDataBuffer, uncompressedSize, actualSize); if (error != B_OK) { diff --git a/src/kits/package/hpkg/PackageReaderImpl.cpp b/src/kits/package/hpkg/PackageReaderImpl.cpp index 68425989c6..b821d4c7c1 100644 --- a/src/kits/package/hpkg/PackageReaderImpl.cpp +++ b/src/kits/package/hpkg/PackageReaderImpl.cpp @@ -22,11 +22,11 @@ #include -#include +#include #include #include #include -#include +#include namespace BPackageKit { diff --git a/src/kits/package/hpkg/PackageWriterImpl.cpp b/src/kits/package/hpkg/PackageWriterImpl.cpp index c57eebad0b..a9348dbac4 100644 --- a/src/kits/package/hpkg/PackageWriterImpl.cpp +++ b/src/kits/package/hpkg/PackageWriterImpl.cpp @@ -37,7 +37,7 @@ #include -#include +#include #include #include #include diff --git a/src/kits/package/hpkg/ReaderImplBase.cpp b/src/kits/package/hpkg/ReaderImplBase.cpp index af771ece4b..e5c156498a 100644 --- a/src/kits/package/hpkg/ReaderImplBase.cpp +++ b/src/kits/package/hpkg/ReaderImplBase.cpp @@ -19,9 +19,9 @@ #include -#include +#include #include -#include +#include namespace BPackageKit { diff --git a/src/kits/package/hpkg/ZlibCompressor.cpp b/src/kits/package/hpkg/ZlibCompressor.cpp index a2a5dea5a8..b9e6e6fc64 100644 --- a/src/kits/package/hpkg/ZlibCompressor.cpp +++ b/src/kits/package/hpkg/ZlibCompressor.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include namespace BPackageKit { @@ -22,7 +22,7 @@ namespace BPrivate { static const size_t kOutputBufferSize = 1024; -ZlibCompressor::ZlibCompressor(BDataOutput* output) +ZlibCompressor::ZlibCompressor(BDataIO* output) : fOutput(output), fStreamInitialized(false) @@ -82,7 +82,7 @@ ZlibCompressor::CompressNext(const void* input, size_t inputSize) return TranslateZlibError(zlibError); if (fStream.avail_out < sizeof(outputBuffer)) { - status_t error = fOutput->WriteData(outputBuffer, + status_t error = fOutput->Write(outputBuffer, sizeof(outputBuffer) - fStream.avail_out); if (error != B_OK) return error; @@ -109,7 +109,7 @@ ZlibCompressor::Finish() return TranslateZlibError(zlibError); if (fStream.avail_out < sizeof(outputBuffer)) { - status_t error = fOutput->WriteData(outputBuffer, + status_t error = fOutput->Write(outputBuffer, sizeof(outputBuffer) - fStream.avail_out); if (error != B_OK) return error; diff --git a/src/kits/package/hpkg/v1/PackageDataReaderV1.cpp b/src/kits/package/hpkg/v1/PackageDataReaderV1.cpp index 9fc006319f..6fd4f4ae42 100644 --- a/src/kits/package/hpkg/v1/PackageDataReaderV1.cpp +++ b/src/kits/package/hpkg/v1/PackageDataReaderV1.cpp @@ -11,12 +11,12 @@ #include #include +#include #include #include -#include #include #include -#include +#include namespace BPackageKit { @@ -27,7 +27,7 @@ namespace V1 { using BHPKG::BPrivate::PoolBufferPutter; -using BHPKG::BPrivate::ZlibDecompressor; +using ::BPrivate::ZlibDecompressor; // minimum/maximum zlib chunk size we consider sane @@ -98,7 +98,7 @@ public: } virtual status_t ReadDataToOutput(off_t offset, size_t size, - BDataOutput* output) + BDataIO* output) { if (size == 0) return B_OK; @@ -125,7 +125,7 @@ public: return error; // write to the output - error = output->WriteData(buffer->Buffer(), toRead); + error = output->Write(buffer->Buffer(), toRead); if (error != B_OK) return error; @@ -205,7 +205,7 @@ public: } virtual status_t ReadDataToOutput(off_t offset, size_t size, - BDataOutput* output) + BDataIO* output) { // check offset and size if (size == 0) @@ -244,7 +244,7 @@ public: // write data to output size_t toCopy = std::min(size, (size_t)fChunkSize - inChunkOffset); - error = output->WriteData( + error = output->Write( (uint8*)fUncompressBuffer->Buffer() + inChunkOffset, toCopy); if (error != B_OK) return error; diff --git a/src/kits/package/hpkg/v1/PackageReaderImplV1.cpp b/src/kits/package/hpkg/v1/PackageReaderImplV1.cpp index 5fa75d5218..8541f84e5b 100644 --- a/src/kits/package/hpkg/v1/PackageReaderImplV1.cpp +++ b/src/kits/package/hpkg/v1/PackageReaderImplV1.cpp @@ -22,12 +22,12 @@ #include -#include +#include #include #include #include #include -#include +#include namespace BPackageKit { diff --git a/src/kits/package/hpkg/v1/ReaderImplBaseV1.cpp b/src/kits/package/hpkg/v1/ReaderImplBaseV1.cpp index 74bf776baa..9768c33cad 100644 --- a/src/kits/package/hpkg/v1/ReaderImplBaseV1.cpp +++ b/src/kits/package/hpkg/v1/ReaderImplBaseV1.cpp @@ -19,9 +19,9 @@ #include -#include +#include #include -#include +#include namespace BPackageKit { @@ -33,7 +33,7 @@ namespace V1 { namespace BPrivate { -using BHPKG::BPrivate::ZlibDecompressor; +using ::BPrivate::ZlibDecompressor; static const size_t kScratchBufferSize = 64 * 1024; diff --git a/src/kits/shared/Jamfile b/src/kits/shared/Jamfile index 6a44e76084..869f90a4ea 100644 --- a/src/kits/shared/Jamfile +++ b/src/kits/shared/Jamfile @@ -11,6 +11,8 @@ for architectureObject in [ MultiArchSubDirSetup ] { on $(architectureObject) { local architecture = $(TARGET_PACKAGING_ARCH) ; + UseBuildFeatureHeaders zlib ; + UseHeaders [ FDirName $(TARGET_COMMON_DEBUG_OBJECT_DIR_$(TARGET_PACKAGING_ARCHS[1])) servers input ] ; @@ -21,6 +23,9 @@ for architectureObject in [ MultiArchSubDirSetup ] { # for RWLockManager only UsePrivateSystemHeaders ; UsePrivateHeaders kernel libroot ; + + Includes [ FGristFiles $(HPKG_SOURCES) ] + : [ BuildFeatureAttribute zlib : headers ] ; StaticLibrary [ MultiArchDefaultGristFiles libshared.a ] : AboutMenuItem.cpp @@ -48,6 +53,10 @@ for architectureObject in [ MultiArchSubDirSetup ] { TextTable.cpp Thread.cpp Variant.cpp + + # compression + ZlibCompressionBase.cpp + ZlibDecompressor.cpp ; Includes [ FGristFiles Keymap.cpp ] diff --git a/src/kits/package/hpkg/ZlibCompressionBase.cpp b/src/kits/shared/ZlibCompressionBase.cpp similarity index 84% rename from src/kits/package/hpkg/ZlibCompressionBase.cpp rename to src/kits/shared/ZlibCompressionBase.cpp index 4fe43377a9..2377353f76 100644 --- a/src/kits/package/hpkg/ZlibCompressionBase.cpp +++ b/src/kits/shared/ZlibCompressionBase.cpp @@ -4,17 +4,13 @@ */ -#include +#include #include #include -namespace BPackageKit { - -namespace BHPKG { - namespace BPrivate { @@ -48,7 +44,3 @@ ZlibCompressionBase::TranslateZlibError(int error) } // namespace BPrivate - -} // namespace BHPKG - -} // namespace BPackageKit diff --git a/src/kits/package/hpkg/ZlibDecompressor.cpp b/src/kits/shared/ZlibDecompressor.cpp similarity index 91% rename from src/kits/package/hpkg/ZlibDecompressor.cpp rename to src/kits/shared/ZlibDecompressor.cpp index 2ab2d4c07b..17552a827b 100644 --- a/src/kits/package/hpkg/ZlibDecompressor.cpp +++ b/src/kits/shared/ZlibDecompressor.cpp @@ -4,18 +4,14 @@ */ -#include +#include #include #include -#include +#include -namespace BPackageKit { - -namespace BHPKG { - namespace BPrivate { @@ -23,7 +19,7 @@ namespace BPrivate { static const size_t kOutputBufferSize = 1024; -ZlibDecompressor::ZlibDecompressor(BDataOutput* output) +ZlibDecompressor::ZlibDecompressor(BDataIO* output) : fOutput(output), fStreamInitialized(false), @@ -89,7 +85,7 @@ ZlibDecompressor::DecompressNext(const void* input, size_t inputSize) return TranslateZlibError(zlibError); if (fStream.avail_out < sizeof(outputBuffer)) { - status_t error = fOutput->WriteData(outputBuffer, + status_t error = fOutput->Write(outputBuffer, sizeof(outputBuffer) - fStream.avail_out); if (error != B_OK) return error; @@ -118,7 +114,7 @@ ZlibDecompressor::Finish() return TranslateZlibError(zlibError); if (fStream.avail_out < sizeof(outputBuffer)) { - status_t error = fOutput->WriteData(outputBuffer, + status_t error = fOutput->Write(outputBuffer, sizeof(outputBuffer) - fStream.avail_out); if (error != B_OK) return error; @@ -186,7 +182,3 @@ ZlibDecompressor::DecompressSingleBuffer(const void* input, size_t inputSize, } // namespace BPrivate - -} // namespace BHPKG - -} // namespace BPackageKit diff --git a/src/system/boot/loader/file_systems/packagefs/Jamfile b/src/system/boot/loader/file_systems/packagefs/Jamfile index 2425fdf443..7fadf511ee 100644 --- a/src/system/boot/loader/file_systems/packagefs/Jamfile +++ b/src/system/boot/loader/file_systems/packagefs/Jamfile @@ -13,6 +13,8 @@ SubDirC++Flags -fno-rtti -include $(kernelC++Header) ; SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src kits package ] ; SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src kits package hpkg ] ; +SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src kits shared ] ; +SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src kits support ] ; BootStaticLibrary boot_packagefs : @@ -25,9 +27,9 @@ BootStaticLibrary boot_packagefs : BlockBufferPool.cpp BlockBufferPoolImpl.cpp BlockBufferPoolNoLock.cpp + BufferDataOutput.cpp BufferPool.cpp PoolBuffer.cpp - DataOutput.cpp DataReader.cpp ErrorOutput.cpp FDDataReader.cpp @@ -42,6 +44,7 @@ BootStaticLibrary boot_packagefs : ReaderImplBase.cpp # compression + DataIO.cpp ZlibCompressionBase.cpp ZlibDecompressor.cpp