From 32832cbe47f991cc6d2b29824903181d8baaaa63 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Mon, 23 Jun 2014 14:37:34 +0200 Subject: [PATCH] Remove BPackageKit::BDataOutput Use BDataIO instead. --- headers/build/os/package/hpkg/DataOutput.h | 1 - headers/os/package/hpkg/DataOutput.h | 45 ---------------- headers/os/package/hpkg/DataReader.h | 12 ++--- headers/private/package/hpkg/DataWriters.h | 10 ++-- .../hpkg/PackageFileHeapAccessorBase.h | 6 +-- headers/private/package/hpkg/WriterImplBase.h | 1 - headers/private/package/hpkg/ZlibCompressor.h | 13 +++-- .../private/package/hpkg/ZlibDecompressor.h | 13 +++-- .../kernel/file_systems/packagefs/Jamfile | 1 - .../packagefs/package/CachedDataReader.cpp | 29 +++++----- .../packagefs/package/CachedDataReader.h | 9 ++-- .../packagefs/package/Package.cpp | 3 +- .../packagefs/package/PackageFile.cpp | 17 +++--- src/build/libpackage/Jamfile | 1 - src/kits/package/Jamfile | 1 - src/kits/package/hpkg/DataOutput.cpp | 54 ------------------- src/kits/package/hpkg/DataReader.cpp | 11 ++-- src/kits/package/hpkg/DataWriters.cpp | 9 ++-- src/kits/package/hpkg/PackageDataReader.cpp | 6 +-- .../hpkg/PackageFileHeapAccessorBase.cpp | 8 +-- .../package/hpkg/PackageFileHeapWriter.cpp | 4 +- src/kits/package/hpkg/PackageReaderImpl.cpp | 1 - src/kits/package/hpkg/PackageWriterImpl.cpp | 3 +- src/kits/package/hpkg/ReaderImplBase.cpp | 6 +-- src/kits/package/hpkg/ZlibCompressor.cpp | 10 ++-- src/kits/package/hpkg/ZlibDecompressor.cpp | 10 ++-- .../package/hpkg/v1/PackageDataReaderV1.cpp | 12 ++--- .../package/hpkg/v1/PackageReaderImplV1.cpp | 3 +- src/kits/package/hpkg/v1/ReaderImplBaseV1.cpp | 9 ++-- src/system/boot/loader/Jamfile | 3 +- .../loader/file_systems/packagefs/Jamfile | 1 - src/system/kernel/lib/Jamfile | 1 + 32 files changed, 102 insertions(+), 211 deletions(-) delete mode 100644 headers/build/os/package/hpkg/DataOutput.h delete mode 100644 headers/os/package/hpkg/DataOutput.h delete mode 100644 src/kits/package/hpkg/DataOutput.cpp diff --git a/headers/build/os/package/hpkg/DataOutput.h b/headers/build/os/package/hpkg/DataOutput.h deleted file mode 100644 index 565ceb4b01..0000000000 --- a/headers/build/os/package/hpkg/DataOutput.h +++ /dev/null @@ -1 +0,0 @@ -#include <../os/package/hpkg/DataOutput.h> diff --git a/headers/os/package/hpkg/DataOutput.h b/headers/os/package/hpkg/DataOutput.h deleted file mode 100644 index 290937adab..0000000000 --- a/headers/os/package/hpkg/DataOutput.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2009,2011, Haiku, Inc. - * Distributed under the terms of the MIT License. - */ -#ifndef _PACKAGE__HPKG__DATA_OUTPUT_H_ -#define _PACKAGE__HPKG__DATA_OUTPUT_H_ - - -#include - - -namespace BPackageKit { - -namespace BHPKG { - - -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 WriteData(const void* buffer, size_t size); - -private: - void* fBuffer; - size_t fSize; - size_t fBytesWritten; -}; - - -} // namespace BHPKG - -} // namespace BPackageKit - - -#endif // _PACKAGE__HPKG__DATA_OUTPUT_H_ diff --git a/headers/os/package/hpkg/DataReader.h b/headers/os/package/hpkg/DataReader.h index 2590415fba..fec3b20e22 100644 --- a/headers/os/package/hpkg/DataReader.h +++ b/headers/os/package/hpkg/DataReader.h @@ -1,5 +1,5 @@ /* - * Copyright 2009,2011, Haiku, Inc. + * Copyright 2009-2014, Haiku, Inc. * Distributed under the terms of the MIT License. */ #ifndef _PACKAGE__HPKG__DATA_READER_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..9ff394dd36 100644 --- a/headers/private/package/hpkg/DataWriters.h +++ b/headers/private/package/hpkg/DataWriters.h @@ -1,13 +1,13 @@ /* * Copyright 2011, Oliver Tappe - * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2013-2014, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ #ifndef _PACKAGE__HPKG__PRIVATE__DATA_WRITERS_H_ #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); @@ -70,8 +70,8 @@ public: size_t size); private: - // BDataOutput - virtual status_t WriteData(const void* buffer, size_t size); + // BDataIO + virtual ssize_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..2f180cd2f9 100644 --- a/headers/private/package/hpkg/PackageFileHeapAccessorBase.h +++ b/headers/private/package/hpkg/PackageFileHeapAccessorBase.h @@ -1,5 +1,5 @@ /* - * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2013-2014, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ #ifndef _PACKAGE__HPKG__PRIVATE__PACKAGE_FILE_HEAP_ACCESSOR_BASE_H_ @@ -48,8 +48,8 @@ public: { fFD = fd; } // BAbstractBufferedDataReader - virtual status_t ReadDataToOutput(off_t offset, size_t size, - BDataOutput* output); + virtual status_t ReadDataToOutput(off_t offset, + size_t size, 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..28496d19b8 100644 --- a/headers/private/package/hpkg/WriterImplBase.h +++ b/headers/private/package/hpkg/WriterImplBase.h @@ -10,7 +10,6 @@ #include -#include #include #include #include diff --git a/headers/private/package/hpkg/ZlibCompressor.h b/headers/private/package/hpkg/ZlibCompressor.h index 4f6dd141f7..baefd3b638 100644 --- a/headers/private/package/hpkg/ZlibCompressor.h +++ b/headers/private/package/hpkg/ZlibCompressor.h @@ -1,5 +1,5 @@ /* - * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2014, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ #ifndef _PACKAGE__HPKG__PRIVATE__ZLIB_COMPRESSOR_H_ @@ -11,20 +11,19 @@ #include +class BDataIO; + + namespace BPackageKit { namespace BHPKG { - -class BDataOutput; - - namespace BPrivate { class ZlibCompressor : public ZlibCompressionBase { public: - ZlibCompressor(BDataOutput* output); + ZlibCompressor(BDataIO* output); ~ZlibCompressor(); status_t Init(int compressionLevel = Z_BEST_COMPRESSION); @@ -39,7 +38,7 @@ public: private: z_stream fStream; - BDataOutput* fOutput; + BDataIO* fOutput; bool fStreamInitialized; }; diff --git a/headers/private/package/hpkg/ZlibDecompressor.h b/headers/private/package/hpkg/ZlibDecompressor.h index 8d4556b236..e045b4ee37 100644 --- a/headers/private/package/hpkg/ZlibDecompressor.h +++ b/headers/private/package/hpkg/ZlibDecompressor.h @@ -1,5 +1,5 @@ /* - * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2014, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ #ifndef _PACKAGE__HPKG__PRIVATE__ZLIB_DECOMPRESSOR_H_ @@ -11,20 +11,19 @@ #include +class BDataIO; + + namespace BPackageKit { namespace BHPKG { - -class BDataOutput; - - namespace BPrivate { class ZlibDecompressor : public ZlibCompressionBase { public: - ZlibDecompressor(BDataOutput* output); + ZlibDecompressor(BDataIO* output); ~ZlibDecompressor(); status_t Init(); @@ -39,7 +38,7 @@ public: private: z_stream fStream; - BDataOutput* fOutput; + BDataIO* fOutput; bool fStreamInitialized; bool fFinished; }; diff --git a/src/add-ons/kernel/file_systems/packagefs/Jamfile b/src/add-ons/kernel/file_systems/packagefs/Jamfile index 53907f2234..ae95075594 100644 --- a/src/add-ons/kernel/file_systems/packagefs/Jamfile +++ b/src/add-ons/kernel/file_systems/packagefs/Jamfile @@ -76,7 +76,6 @@ HAIKU_PACKAGE_FS_SHARED_SOURCES = HAIKU_PACKAGE_FS_PACKAGE_READER_SOURCES = BlockBufferPoolImpl.cpp BufferPool.cpp - DataOutput.cpp DataReader.cpp ErrorOutput.cpp FDDataReader.cpp 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..59bd8bc616 100644 --- a/src/add-ons/kernel/file_systems/packagefs/package/CachedDataReader.cpp +++ b/src/add-ons/kernel/file_systems/packagefs/package/CachedDataReader.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010-2013, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2010-2014, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -8,7 +8,7 @@ #include -#include +#include #include #include @@ -18,7 +18,6 @@ using BPackageKit::BHPKG::BBufferDataReader; -using BPackageKit::BHPKG::BBufferDataOutput; static inline bool @@ -31,7 +30,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,13 +39,15 @@ struct CachedDataReader::PagesDataOutput : public BDataOutput { { } - virtual status_t WriteData(const void* buffer, size_t size) + virtual ssize_t Write(const void* buffer, size_t size) { - while (size > 0) { + size_t bytesRemaining = size; + while (bytesRemaining > 0) { if (fPageCount == 0) return B_BAD_VALUE; - size_t toCopy = std::min(size, B_PAGE_SIZE - fInPageOffset); + size_t toCopy = std::min(bytesRemaining, + B_PAGE_SIZE - fInPageOffset); status_t error = vm_memcpy_to_physical( fPages[0]->physical_page_number * B_PAGE_SIZE + fInPageOffset, buffer, toCopy, false); @@ -61,10 +62,10 @@ struct CachedDataReader::PagesDataOutput : public BDataOutput { } buffer = (const char*)buffer + toCopy; - size -= toCopy; + bytesRemaining -= toCopy; } - return B_OK; + return size; } private: @@ -125,14 +126,14 @@ CachedDataReader::Init(BAbstractBufferedDataReader* reader, off_t size) status_t CachedDataReader::ReadData(off_t offset, void* buffer, size_t size) { - BBufferDataOutput output(buffer, size); + BMemoryIO output(buffer, size); return ReadDataToOutput(offset, size, &output); } 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 +169,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 +367,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 +390,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->WriteExactly((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..8cb87c6f0a 100644 --- a/src/add-ons/kernel/file_systems/packagefs/package/CachedDataReader.h +++ b/src/add-ons/kernel/file_systems/packagefs/package/CachedDataReader.h @@ -1,5 +1,5 @@ /* - * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2013-2014, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ #ifndef HEAP_CACHE_H @@ -15,7 +15,6 @@ using BPackageKit::BHPKG::BAbstractBufferedDataReader; -using BPackageKit::BHPKG::BDataOutput; using BPackageKit::BHPKG::BDataReader; @@ -30,7 +29,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 +120,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 +128,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 dd846226f3..b546632ca7 100644 --- a/src/add-ons/kernel/file_systems/packagefs/package/Package.cpp +++ b/src/add-ons/kernel/file_systems/packagefs/package/Package.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2014, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -39,7 +39,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..43b2790942 100644 --- a/src/add-ons/kernel/file_systems/packagefs/package/PackageFile.cpp +++ b/src/add-ons/kernel/file_systems/packagefs/package/PackageFile.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2009-2013, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2014, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -11,13 +11,13 @@ #include -#include -#include - -#include +#include #include #include +#include +#include + #include "DebugSupport.h" #include "GlobalFactory.h" #include "Package.h" @@ -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,9 +37,10 @@ public: { } - virtual status_t WriteData(const void* buffer, size_t size) + virtual ssize_t Write(const void* buffer, size_t size) { - RETURN_ERROR(write_to_io_request(fRequest, buffer, size)); + status_t error = write_to_io_request(fRequest, buffer, size); + RETURN_ERROR(error == B_OK ? (ssize_t)size : (ssize_t)error); } private: diff --git a/src/build/libpackage/Jamfile b/src/build/libpackage/Jamfile index ca37f93a9b..54d95fc3d3 100644 --- a/src/build/libpackage/Jamfile +++ b/src/build/libpackage/Jamfile @@ -35,7 +35,6 @@ HPKG_SOURCES = BlockBufferPoolNoLock.cpp BufferPool.cpp PoolBuffer.cpp - DataOutput.cpp DataReader.cpp DataWriters.cpp ErrorOutput.cpp diff --git a/src/kits/package/Jamfile b/src/kits/package/Jamfile index 7706f84263..5857263f7a 100644 --- a/src/kits/package/Jamfile +++ b/src/kits/package/Jamfile @@ -15,7 +15,6 @@ HPKG_SOURCES = BlockBufferPoolNoLock.cpp BufferPool.cpp CommitTransactionResult.cpp - DataOutput.cpp DataReader.cpp DataWriters.cpp ErrorOutput.cpp diff --git a/src/kits/package/hpkg/DataOutput.cpp b/src/kits/package/hpkg/DataOutput.cpp deleted file mode 100644 index 00694b31cd..0000000000 --- a/src/kits/package/hpkg/DataOutput.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. - * Distributed under the terms of the MIT License. - */ - - -#include - -#include - - -namespace BPackageKit { - -namespace BHPKG { - - -// #pragma mark - BDataOutput - - -BDataOutput::~BDataOutput() -{ -} - - -// #pragma mark - BBufferDataOutput - - -BBufferDataOutput::BBufferDataOutput(void* buffer, size_t size) - : - fBuffer(buffer), - fSize(size), - fBytesWritten(0) -{ -} - - -status_t -BBufferDataOutput::WriteData(const void* buffer, size_t size) -{ - if (size == 0) - return B_OK; - if (size > fSize - fBytesWritten) - return B_BAD_VALUE; - - memcpy((uint8*)fBuffer + fBytesWritten, buffer, size); - fBytesWritten += size; - - return B_OK; -} - - -} // namespace BHPKG - -} // namespace BPackageKit diff --git a/src/kits/package/hpkg/DataReader.cpp b/src/kits/package/hpkg/DataReader.cpp index b47f988a2f..664236c6d8 100644 --- a/src/kits/package/hpkg/DataReader.cpp +++ b/src/kits/package/hpkg/DataReader.cpp @@ -1,12 +1,12 @@ /* - * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2014, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ #include -#include +#include #include @@ -35,7 +35,7 @@ BAbstractBufferedDataReader::~BAbstractBufferedDataReader() status_t BAbstractBufferedDataReader::ReadData(off_t offset, void* buffer, size_t size) { - BBufferDataOutput output(buffer, size); + BMemoryIO output(buffer, size); return ReadDataToOutput(offset, size, &output); } @@ -69,8 +69,7 @@ BBufferDataReader::ReadData(off_t offset, void* buffer, size_t size) status_t -BBufferDataReader::ReadDataToOutput(off_t offset, size_t size, - BDataOutput* output) +BBufferDataReader::ReadDataToOutput(off_t offset, size_t size, BDataIO* output) { if (size == 0) return B_OK; @@ -81,7 +80,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->WriteExactly((const uint8*)fData + offset, size); } diff --git a/src/kits/package/hpkg/DataWriters.cpp b/src/kits/package/hpkg/DataWriters.cpp index 29318c890d..fdf4bdc071 100644 --- a/src/kits/package/hpkg/DataWriters.cpp +++ b/src/kits/package/hpkg/DataWriters.cpp @@ -1,6 +1,6 @@ /* * Copyright 2011, Oliver Tappe - * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2013-2014, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -111,10 +111,11 @@ ZlibDataWriter::WriteDataNoThrow(const void* buffer, } -status_t -ZlibDataWriter::WriteData(const void* buffer, size_t size) +ssize_t +ZlibDataWriter::Write(const void* buffer, size_t size) { - return fDataWriter->WriteDataNoThrow(buffer, size); + status_t error = fDataWriter->WriteDataNoThrow(buffer, size); + return error == B_OK ? (ssize_t)size : (ssize_t)error; } diff --git a/src/kits/package/hpkg/PackageDataReader.cpp b/src/kits/package/hpkg/PackageDataReader.cpp index 9c808fec44..af3ee05ed6 100644 --- a/src/kits/package/hpkg/PackageDataReader.cpp +++ b/src/kits/package/hpkg/PackageDataReader.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2009-2013, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2014, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -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; @@ -74,7 +74,7 @@ private: }; -// #pragma mark - PackageDataHeapReader +// #pragma mark - PackageDataInlineReader class PackageDataInlineReader : public BBufferDataReader { diff --git a/src/kits/package/hpkg/PackageFileHeapAccessorBase.cpp b/src/kits/package/hpkg/PackageFileHeapAccessorBase.cpp index 024b8f21e9..9c308d99f0 100644 --- a/src/kits/package/hpkg/PackageFileHeapAccessorBase.cpp +++ b/src/kits/package/hpkg/PackageFileHeapAccessorBase.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2013-2014, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include @@ -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,7 +174,7 @@ 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( + error = output->WriteExactly( (char*)uncompressedDataBuffer + inChunkOffset, toWrite); if (error != B_OK) return error; diff --git a/src/kits/package/hpkg/PackageFileHeapWriter.cpp b/src/kits/package/hpkg/PackageFileHeapWriter.cpp index d4a12e46e7..38b1c9cec4 100644 --- a/src/kits/package/hpkg/PackageFileHeapWriter.cpp +++ b/src/kits/package/hpkg/PackageFileHeapWriter.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2013-2014, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -461,7 +461,7 @@ PackageFileHeapWriter::ReadAndDecompressChunk(size_t chunkIndex, // The chunk has not been written to disk yet. Its data are still in the // pending data buffer. memcpy(uncompressedDataBuffer, fPendingDataBuffer, fPendingDataSize); - // TODO: This can be optimized. Since we write to a BDataOutput anyway, + // TODO: This can be optimized. Since we write to a BDataIO anyway, // there's no need to copy the data. return B_OK; } diff --git a/src/kits/package/hpkg/PackageReaderImpl.cpp b/src/kits/package/hpkg/PackageReaderImpl.cpp index 68425989c6..d1337b33b7 100644 --- a/src/kits/package/hpkg/PackageReaderImpl.cpp +++ b/src/kits/package/hpkg/PackageReaderImpl.cpp @@ -22,7 +22,6 @@ #include -#include #include #include #include diff --git a/src/kits/package/hpkg/PackageWriterImpl.cpp b/src/kits/package/hpkg/PackageWriterImpl.cpp index c57eebad0b..5d291dc5d1 100644 --- a/src/kits/package/hpkg/PackageWriterImpl.cpp +++ b/src/kits/package/hpkg/PackageWriterImpl.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2009-2013, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2014, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2011, Oliver Tappe * Distributed under the terms of the MIT License. */ @@ -37,7 +37,6 @@ #include -#include #include #include #include diff --git a/src/kits/package/hpkg/ReaderImplBase.cpp b/src/kits/package/hpkg/ReaderImplBase.cpp index af771ece4b..0a421b0e96 100644 --- a/src/kits/package/hpkg/ReaderImplBase.cpp +++ b/src/kits/package/hpkg/ReaderImplBase.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2014, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2011, Oliver Tappe * Distributed under the terms of the MIT License. */ @@ -16,10 +16,10 @@ #include #include +#include #include -#include #include #include @@ -1358,7 +1358,7 @@ ReaderImplBase::ReadBuffer(off_t offset, void* buffer, size_t size) status_t ReaderImplBase::ReadSection(const PackageFileSection& section) { - BBufferDataOutput output(section.data, section.uncompressedLength); + BMemoryIO output(section.data, section.uncompressedLength); return fHeapReader->ReadDataToOutput(section.offset, section.uncompressedLength, &output); } diff --git a/src/kits/package/hpkg/ZlibCompressor.cpp b/src/kits/package/hpkg/ZlibCompressor.cpp index a2a5dea5a8..deef959b71 100644 --- a/src/kits/package/hpkg/ZlibCompressor.cpp +++ b/src/kits/package/hpkg/ZlibCompressor.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2014, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -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->WriteExactly(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->WriteExactly(outputBuffer, sizeof(outputBuffer) - fStream.avail_out); if (error != B_OK) return error; diff --git a/src/kits/package/hpkg/ZlibDecompressor.cpp b/src/kits/package/hpkg/ZlibDecompressor.cpp index 2ab2d4c07b..0858dcad7f 100644 --- a/src/kits/package/hpkg/ZlibDecompressor.cpp +++ b/src/kits/package/hpkg/ZlibDecompressor.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2014, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -9,7 +9,7 @@ #include #include -#include +#include namespace BPackageKit { @@ -23,7 +23,7 @@ namespace BPrivate { static const size_t kOutputBufferSize = 1024; -ZlibDecompressor::ZlibDecompressor(BDataOutput* output) +ZlibDecompressor::ZlibDecompressor(BDataIO* output) : fOutput(output), fStreamInitialized(false), @@ -89,7 +89,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->WriteExactly(outputBuffer, sizeof(outputBuffer) - fStream.avail_out); if (error != B_OK) return error; @@ -118,7 +118,7 @@ ZlibDecompressor::Finish() return TranslateZlibError(zlibError); if (fStream.avail_out < sizeof(outputBuffer)) { - status_t error = fOutput->WriteData(outputBuffer, + status_t error = fOutput->WriteExactly(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 4c60352aac..4b85a01ab6 100644 --- a/src/kits/package/hpkg/v1/PackageDataReaderV1.cpp +++ b/src/kits/package/hpkg/v1/PackageDataReaderV1.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2014, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -11,9 +11,9 @@ #include #include +#include #include #include -#include #include #include #include @@ -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->WriteExactly(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->WriteExactly( (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..5178e3b9ba 100644 --- a/src/kits/package/hpkg/v1/PackageReaderImplV1.cpp +++ b/src/kits/package/hpkg/v1/PackageReaderImplV1.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2014, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2011, Oliver Tappe * Distributed under the terms of the MIT License. */ @@ -22,7 +22,6 @@ #include -#include #include #include #include diff --git a/src/kits/package/hpkg/v1/ReaderImplBaseV1.cpp b/src/kits/package/hpkg/v1/ReaderImplBaseV1.cpp index 74bf776baa..d15657d068 100644 --- a/src/kits/package/hpkg/v1/ReaderImplBaseV1.cpp +++ b/src/kits/package/hpkg/v1/ReaderImplBaseV1.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2014, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2011, Oliver Tappe * Distributed under the terms of the MIT License. */ @@ -16,10 +16,10 @@ #include #include +#include #include -#include #include #include @@ -1031,8 +1031,7 @@ ReaderImplBase::ReadCompressedBuffer(const SectionInfo& section) case B_HPKG_COMPRESSION_ZLIB: { // init the decompressor - BBufferDataOutput bufferOutput(section.data, - section.uncompressedLength); + BMemoryIO bufferOutput(section.data, section.uncompressedLength); ZlibDecompressor decompressor(&bufferOutput); status_t error = decompressor.Init(); if (error != B_OK) @@ -1060,7 +1059,7 @@ ReaderImplBase::ReadCompressedBuffer(const SectionInfo& section) return error; // verify that all data have been read - if (bufferOutput.BytesWritten() != section.uncompressedLength) { + if ((uint64)bufferOutput.Position() != section.uncompressedLength) { fErrorOutput->PrintError("Error: Missing bytes in uncompressed " "buffer!\n"); return B_BAD_DATA; diff --git a/src/system/boot/loader/Jamfile b/src/system/boot/loader/Jamfile index 324423ad25..6bee5caa8f 100644 --- a/src/system/boot/loader/Jamfile +++ b/src/system/boot/loader/Jamfile @@ -83,6 +83,7 @@ BootStaticLibrary boot_loader : safemode_settings.cpp StringHash.cpp + DataIO.cpp Referenceable.cpp : -fno-pic @@ -135,7 +136,7 @@ SEARCH on [ FGristFiles intel.cpp PartitionMap.cpp PartitionMapParser.cpp ] SEARCH on [ FGristFiles stage2_crt0.S ] = [ FDirName $(HAIKU_TOP) src system boot arch $(TARGET_KERNEL_ARCH) ] ; -SEARCH on [ FGristFiles Referenceable.cpp ] +SEARCH on [ FGristFiles DataIO.cpp Referenceable.cpp ] = [ FDirName $(HAIKU_TOP) src kits support ] ; diff --git a/src/system/boot/loader/file_systems/packagefs/Jamfile b/src/system/boot/loader/file_systems/packagefs/Jamfile index 2425fdf443..6929d56317 100644 --- a/src/system/boot/loader/file_systems/packagefs/Jamfile +++ b/src/system/boot/loader/file_systems/packagefs/Jamfile @@ -27,7 +27,6 @@ BootStaticLibrary boot_packagefs : BlockBufferPoolNoLock.cpp BufferPool.cpp PoolBuffer.cpp - DataOutput.cpp DataReader.cpp ErrorOutput.cpp FDDataReader.cpp diff --git a/src/system/kernel/lib/Jamfile b/src/system/kernel/lib/Jamfile index 5d0319dca5..cfb7b2a4f6 100644 --- a/src/system/kernel/lib/Jamfile +++ b/src/system/kernel/lib/Jamfile @@ -132,6 +132,7 @@ KernelMergeObject kernel_lib_posix.o : SEARCH_SOURCE = [ FDirName $(HAIKU_TOP) src kits support ] ; KernelMergeObject kernel_misc.o : + DataIO.cpp Referenceable.cpp : $(TARGET_KERNEL_PIC_CCFLAGS)