Remove BPackageKit::BDataOutput

Use BDataIO instead.
This commit is contained in:
Ingo Weinhold 2014-06-23 14:37:34 +02:00
parent 0d8b44e25b
commit 32832cbe47
32 changed files with 102 additions and 211 deletions

View File

@ -1 +0,0 @@
#include <../os/package/hpkg/DataOutput.h>

View File

@ -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 <SupportDefs.h>
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_

View File

@ -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 <SupportDefs.h>
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;

View File

@ -1,13 +1,13 @@
/*
* Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
* 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 <package/hpkg/DataOutput.h>
#include <DataIO.h>
#include <package/hpkg/ZlibCompressor.h>
@ -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;

View File

@ -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;

View File

@ -10,7 +10,6 @@
#include <package/hpkg/HPKGDefsPrivate.h>
#include <package/hpkg/DataOutput.h>
#include <package/hpkg/DataWriters.h>
#include <package/hpkg/PackageWriter.h>
#include <package/hpkg/Strings.h>

View File

@ -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 <package/hpkg/ZlibCompressionBase.h>
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;
};

View File

@ -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 <package/hpkg/ZlibCompressionBase.h>
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;
};

View File

@ -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

View File

@ -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 <algorithm>
#include <package/hpkg/DataOutput.h>
#include <DataIO.h>
#include <util/AutoLock.h>
#include <vm/VMCache.h>
@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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 <fs_cache.h>
#include <AutoDeleter.h>
#include <util/AutoLock.h>
#include <package/hpkg/DataOutput.h>
#include <DataIO.h>
#include <package/hpkg/DataReader.h>
#include <package/hpkg/PackageDataReader.h>
#include <AutoDeleter.h>
#include <util/AutoLock.h>
#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:

View File

@ -35,7 +35,6 @@ HPKG_SOURCES =
BlockBufferPoolNoLock.cpp
BufferPool.cpp
PoolBuffer.cpp
DataOutput.cpp
DataReader.cpp
DataWriters.cpp
ErrorOutput.cpp

View File

@ -15,7 +15,6 @@ HPKG_SOURCES =
BlockBufferPoolNoLock.cpp
BufferPool.cpp
CommitTransactionResult.cpp
DataOutput.cpp
DataReader.cpp
DataWriters.cpp
ErrorOutput.cpp

View File

@ -1,54 +0,0 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#include <package/hpkg/DataOutput.h>
#include <string.h>
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

View File

@ -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 <package/hpkg/DataReader.h>
#include <package/hpkg/DataOutput.h>
#include <DataIO.h>
#include <string.h>
@ -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);
}

View File

@ -1,6 +1,6 @@
/*
* Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
* 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;
}

View File

@ -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 {

View File

@ -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 <new>
#include <ByteOrder.h>
#include <package/hpkg/DataOutput.h>
#include <DataIO.h>
#include <package/hpkg/ErrorOutput.h>
#include <AutoDeleter.h>
@ -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;

View File

@ -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;
}

View File

@ -22,7 +22,6 @@
#include <package/hpkg/HPKGDefsPrivate.h>
#include <package/hpkg/DataOutput.h>
#include <package/hpkg/PackageData.h>
#include <package/hpkg/PackageEntry.h>
#include <package/hpkg/PackageEntryAttribute.h>

View File

@ -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 <zooey@hirschkaefer.de>
* Distributed under the terms of the MIT License.
*/
@ -37,7 +37,6 @@
#include <package/hpkg/HPKGDefsPrivate.h>
#include <package/hpkg/DataOutput.h>
#include <package/hpkg/DataReader.h>
#include <package/hpkg/PackageFileHeapWriter.h>
#include <package/hpkg/PackageReaderImpl.h>

View File

@ -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 <zooey@hirschkaefer.de>
* Distributed under the terms of the MIT License.
*/
@ -16,10 +16,10 @@
#include <new>
#include <ByteOrder.h>
#include <DataIO.h>
#include <package/hpkg/HPKGDefsPrivate.h>
#include <package/hpkg/DataOutput.h>
#include <package/hpkg/PackageFileHeapReader.h>
#include <package/hpkg/ZlibDecompressor.h>
@ -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);
}

View File

@ -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 <errno.h>
#include <stdio.h>
#include <package/hpkg/DataOutput.h>
#include <DataIO.h>
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;

View File

@ -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 <errno.h>
#include <stdio.h>
#include <package/hpkg/DataOutput.h>
#include <DataIO.h>
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;

View File

@ -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 <algorithm>
#include <new>
#include <DataIO.h>
#include <package/hpkg/BufferPool.h>
#include <package/hpkg/PoolBuffer.h>
#include <package/hpkg/DataOutput.h>
#include <package/hpkg/v1/HPKGDefsPrivate.h>
#include <package/hpkg/v1/PackageData.h>
#include <package/hpkg/ZlibDecompressor.h>
@ -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;

View File

@ -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 <zooey@hirschkaefer.de>
* Distributed under the terms of the MIT License.
*/
@ -22,7 +22,6 @@
#include <package/hpkg/v1/HPKGDefsPrivate.h>
#include <package/hpkg/DataOutput.h>
#include <package/hpkg/ErrorOutput.h>
#include <package/hpkg/v1/PackageData.h>
#include <package/hpkg/v1/PackageEntry.h>

View File

@ -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 <zooey@hirschkaefer.de>
* Distributed under the terms of the MIT License.
*/
@ -16,10 +16,10 @@
#include <new>
#include <ByteOrder.h>
#include <DataIO.h>
#include <package/hpkg/v1/HPKGDefsPrivate.h>
#include <package/hpkg/DataOutput.h>
#include <package/hpkg/ErrorOutput.h>
#include <package/hpkg/ZlibDecompressor.h>
@ -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;

View File

@ -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 ] ;

View File

@ -27,7 +27,6 @@ BootStaticLibrary boot_packagefs :
BlockBufferPoolNoLock.cpp
BufferPool.cpp
PoolBuffer.cpp
DataOutput.cpp
DataReader.cpp
ErrorOutput.cpp
FDDataReader.cpp

View File

@ -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)