Switch to c++ type casts, some cleanups.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1127 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+63
-83
@@ -48,16 +48,20 @@
|
|||||||
|
|
||||||
|
|
||||||
// *** BDataIO ***
|
// *** BDataIO ***
|
||||||
|
|
||||||
|
// Construction
|
||||||
BDataIO::BDataIO()
|
BDataIO::BDataIO()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Destruction
|
||||||
BDataIO::~BDataIO()
|
BDataIO::~BDataIO()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Private or Reserved
|
||||||
BDataIO::BDataIO(const BDataIO &)
|
BDataIO::BDataIO(const BDataIO &)
|
||||||
{
|
{
|
||||||
//Copying not allowed
|
//Copying not allowed
|
||||||
@@ -71,55 +75,40 @@ BDataIO::operator=(const BDataIO &)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
BDataIO::_ReservedDataIO1(){}
|
|
||||||
|
|
||||||
void
|
// FBC
|
||||||
BDataIO::_ReservedDataIO2(){}
|
void BDataIO::_ReservedDataIO1(){}
|
||||||
|
void BDataIO::_ReservedDataIO2(){}
|
||||||
void
|
void BDataIO::_ReservedDataIO3(){}
|
||||||
BDataIO::_ReservedDataIO3(){}
|
void BDataIO::_ReservedDataIO4(){}
|
||||||
|
|
||||||
void
|
|
||||||
BDataIO::_ReservedDataIO4(){}
|
|
||||||
|
|
||||||
#if !_PR3_COMPATIBLE_
|
#if !_PR3_COMPATIBLE_
|
||||||
void
|
void BDataIO::_ReservedDataIO5(){}
|
||||||
BDataIO::_ReservedDataIO5(){}
|
void BDataIO::_ReservedDataIO6(){}
|
||||||
|
void BDataIO::_ReservedDataIO7(){}
|
||||||
void
|
void BDataIO::_ReservedDataIO8(){}
|
||||||
BDataIO::_ReservedDataIO6(){}
|
void BDataIO::_ReservedDataIO9(){}
|
||||||
|
void BDataIO::_ReservedDataIO10(){}
|
||||||
void
|
void BDataIO::_ReservedDataIO11(){}
|
||||||
BDataIO::_ReservedDataIO7(){}
|
void BDataIO::_ReservedDataIO12(){}
|
||||||
|
|
||||||
void
|
|
||||||
BDataIO::_ReservedDataIO8(){}
|
|
||||||
|
|
||||||
void
|
|
||||||
BDataIO::_ReservedDataIO9(){}
|
|
||||||
|
|
||||||
void
|
|
||||||
BDataIO::_ReservedDataIO10(){}
|
|
||||||
|
|
||||||
void
|
|
||||||
BDataIO::_ReservedDataIO11(){}
|
|
||||||
|
|
||||||
void
|
|
||||||
BDataIO::_ReservedDataIO12(){}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// *** BPositionIO ***
|
// *** BPositionIO ***
|
||||||
|
|
||||||
|
// Construction
|
||||||
BPositionIO::BPositionIO()
|
BPositionIO::BPositionIO()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Destruction
|
||||||
BPositionIO::~BPositionIO()
|
BPositionIO::~BPositionIO()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Read
|
||||||
ssize_t
|
ssize_t
|
||||||
BPositionIO::Read(void *buffer, size_t size)
|
BPositionIO::Read(void *buffer, size_t size)
|
||||||
{
|
{
|
||||||
@@ -132,6 +121,7 @@ BPositionIO::Read(void *buffer, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Write
|
||||||
ssize_t
|
ssize_t
|
||||||
BPositionIO::Write(const void *buffer, size_t size)
|
BPositionIO::Write(const void *buffer, size_t size)
|
||||||
{
|
{
|
||||||
@@ -144,54 +134,38 @@ BPositionIO::Write(const void *buffer, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// SetSize
|
||||||
status_t
|
status_t
|
||||||
BPositionIO::SetSize(off_t size)
|
BPositionIO::SetSize(off_t size)
|
||||||
{
|
{
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
BPositionIO::_ReservedPositionIO1(){}
|
|
||||||
|
|
||||||
void
|
// FBC
|
||||||
BPositionIO::_ReservedPositionIO2(){}
|
void BPositionIO::_ReservedPositionIO1(){}
|
||||||
|
void BPositionIO::_ReservedPositionIO2(){}
|
||||||
void
|
void BPositionIO::_ReservedPositionIO3(){}
|
||||||
BPositionIO::_ReservedPositionIO3(){}
|
void BPositionIO::_ReservedPositionIO4(){}
|
||||||
|
|
||||||
void
|
|
||||||
BPositionIO::_ReservedPositionIO4(){}
|
|
||||||
|
|
||||||
#if !_PR3_COMPATIBLE_
|
#if !_PR3_COMPATIBLE_
|
||||||
void
|
void BPositionIO::_ReservedPositionIO5(){}
|
||||||
BPositionIO::_ReservedPositionIO5(){}
|
void BPositionIO::_ReservedPositionIO6(){}
|
||||||
|
void BPositionIO::_ReservedPositionIO7(){}
|
||||||
void
|
void BPositionIO::_ReservedPositionIO8(){}
|
||||||
BPositionIO::_ReservedPositionIO6(){}
|
void BPositionIO::_ReservedPositionIO9(){}
|
||||||
|
void BPositionIO::_ReservedPositionIO10(){}
|
||||||
void
|
void BPositionIO::_ReservedPositionIO11(){}
|
||||||
BPositionIO::_ReservedPositionIO7(){}
|
void BPositionIO::_ReservedPositionIO12(){}
|
||||||
|
|
||||||
void
|
|
||||||
BPositionIO::_ReservedPositionIO8(){}
|
|
||||||
|
|
||||||
void
|
|
||||||
BPositionIO::_ReservedPositionIO9(){}
|
|
||||||
|
|
||||||
void
|
|
||||||
BPositionIO::_ReservedPositionIO10(){}
|
|
||||||
|
|
||||||
void
|
|
||||||
BPositionIO::_ReservedPositionIO11(){}
|
|
||||||
|
|
||||||
void
|
|
||||||
BPositionIO::_ReservedPositionIO12(){}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// *** BMemoryIO ***
|
// *** BMemoryIO ***
|
||||||
|
|
||||||
|
// Construction
|
||||||
BMemoryIO::BMemoryIO(void *p, size_t len)
|
BMemoryIO::BMemoryIO(void *p, size_t len)
|
||||||
:fReadOnly(false),
|
:fReadOnly(false),
|
||||||
fBuf((char*)p),
|
fBuf(static_cast<char*>(p)),
|
||||||
fLen(len),
|
fLen(len),
|
||||||
fPhys(len),
|
fPhys(len),
|
||||||
fPos(0)
|
fPos(0)
|
||||||
@@ -210,11 +184,13 @@ BMemoryIO::BMemoryIO(const void *p, size_t len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Destruction
|
||||||
BMemoryIO::~BMemoryIO()
|
BMemoryIO::~BMemoryIO()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ReadAt
|
||||||
ssize_t
|
ssize_t
|
||||||
BMemoryIO::ReadAt(off_t pos, void *buffer, size_t size)
|
BMemoryIO::ReadAt(off_t pos, void *buffer, size_t size)
|
||||||
{
|
{
|
||||||
@@ -223,13 +199,14 @@ BMemoryIO::ReadAt(off_t pos, void *buffer, size_t size)
|
|||||||
|
|
||||||
ssize_t sizeRead = 0;
|
ssize_t sizeRead = 0;
|
||||||
if (pos >= 0 && pos < fLen) {
|
if (pos >= 0 && pos < fLen) {
|
||||||
sizeRead = min((off_t)size, fLen - pos);
|
sizeRead = min(static_cast<off_t>(size), fLen - pos);
|
||||||
memcpy(buffer, fBuf + pos, sizeRead);
|
memcpy(buffer, fBuf + pos, sizeRead);
|
||||||
}
|
}
|
||||||
return sizeRead;
|
return sizeRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// WriteAt
|
||||||
ssize_t
|
ssize_t
|
||||||
BMemoryIO::WriteAt(off_t pos, const void *buffer, size_t size)
|
BMemoryIO::WriteAt(off_t pos, const void *buffer, size_t size)
|
||||||
{
|
{
|
||||||
@@ -241,7 +218,7 @@ BMemoryIO::WriteAt(off_t pos, const void *buffer, size_t size)
|
|||||||
|
|
||||||
ssize_t sizeWritten = 0;
|
ssize_t sizeWritten = 0;
|
||||||
if (pos >= 0 && pos < fPhys) {
|
if (pos >= 0 && pos < fPhys) {
|
||||||
sizeWritten = min((off_t)size, fPhys - pos);
|
sizeWritten = min(static_cast<off_t>(size), fPhys - pos);
|
||||||
memcpy(fBuf + pos, buffer, sizeWritten);
|
memcpy(fBuf + pos, buffer, sizeWritten);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,6 +229,7 @@ BMemoryIO::WriteAt(off_t pos, const void *buffer, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Seek
|
||||||
off_t
|
off_t
|
||||||
BMemoryIO::Seek(off_t position, uint32 seek_mode)
|
BMemoryIO::Seek(off_t position, uint32 seek_mode)
|
||||||
{
|
{
|
||||||
@@ -272,6 +250,7 @@ BMemoryIO::Seek(off_t position, uint32 seek_mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Position
|
||||||
off_t
|
off_t
|
||||||
BMemoryIO::Position() const
|
BMemoryIO::Position() const
|
||||||
{
|
{
|
||||||
@@ -279,6 +258,7 @@ BMemoryIO::Position() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// SetSize
|
||||||
status_t
|
status_t
|
||||||
BMemoryIO::SetSize(off_t size)
|
BMemoryIO::SetSize(off_t size)
|
||||||
{
|
{
|
||||||
@@ -295,6 +275,7 @@ BMemoryIO::SetSize(off_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Private or Reserved
|
||||||
BMemoryIO::BMemoryIO(const BMemoryIO &)
|
BMemoryIO::BMemoryIO(const BMemoryIO &)
|
||||||
{
|
{
|
||||||
//Copying not allowed
|
//Copying not allowed
|
||||||
@@ -308,15 +289,15 @@ BMemoryIO::operator=(const BMemoryIO &)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
BMemoryIO::_ReservedMemoryIO1(){}
|
|
||||||
|
|
||||||
void
|
// FBC
|
||||||
BMemoryIO::_ReservedMemoryIO2(){}
|
void BMemoryIO::_ReservedMemoryIO1(){}
|
||||||
|
void BMemoryIO::_ReservedMemoryIO2(){}
|
||||||
|
|
||||||
|
|
||||||
// *** BMallocIO ***
|
// *** BMallocIO ***
|
||||||
// constructor
|
|
||||||
|
// Construction
|
||||||
BMallocIO::BMallocIO()
|
BMallocIO::BMallocIO()
|
||||||
: fBlockSize(256),
|
: fBlockSize(256),
|
||||||
fMallocSize(0),
|
fMallocSize(0),
|
||||||
@@ -327,7 +308,7 @@ BMallocIO::BMallocIO()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// destructor
|
// Destruction
|
||||||
BMallocIO::~BMallocIO()
|
BMallocIO::~BMallocIO()
|
||||||
{
|
{
|
||||||
if (fData)
|
if (fData)
|
||||||
@@ -344,7 +325,7 @@ BMallocIO::ReadAt(off_t pos, void *buffer, size_t size)
|
|||||||
|
|
||||||
ssize_t sizeRead = 0;
|
ssize_t sizeRead = 0;
|
||||||
if (pos >= 0 && pos < fLength) {
|
if (pos >= 0 && pos < fLength) {
|
||||||
sizeRead = min((off_t)size, fLength - pos);
|
sizeRead = min(static_cast<off_t>(size), fLength - pos);
|
||||||
memcpy(buffer, fData + pos, sizeRead);
|
memcpy(buffer, fData + pos, sizeRead);
|
||||||
}
|
}
|
||||||
return sizeRead;
|
return sizeRead;
|
||||||
@@ -358,7 +339,7 @@ BMallocIO::WriteAt(off_t pos, const void *buffer, size_t size)
|
|||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
size_t newSize = max(pos + size, (off_t)fLength);
|
size_t newSize = max(pos + size, static_cast<off_t>(fLength));
|
||||||
status_t error = _Resize(newSize);
|
status_t error = _Resize(newSize);
|
||||||
if (error == B_OK)
|
if (error == B_OK)
|
||||||
memcpy(fData + pos, buffer, size);
|
memcpy(fData + pos, buffer, size);
|
||||||
@@ -450,12 +431,11 @@ BMallocIO::_Resize(off_t size)
|
|||||||
size_t newSize = (size + fBlockSize - 1) / fBlockSize * fBlockSize;
|
size_t newSize = (size + fBlockSize - 1) / fBlockSize * fBlockSize;
|
||||||
if (newSize != fMallocSize) {
|
if (newSize != fMallocSize) {
|
||||||
// we need to resize
|
// we need to resize
|
||||||
if (char *newData = (char*)realloc(fData, newSize)) {
|
if (char *newData = (char*)(realloc(fData, newSize)) {
|
||||||
// set the new area to 0
|
// set the new area to 0
|
||||||
if (fMallocSize < newSize) {
|
if (fMallocSize < newSize)
|
||||||
memset(newData + fMallocSize, 0,
|
memset(newData + fMallocSize, 0,
|
||||||
newSize - fMallocSize);
|
newSize - fMallocSize);
|
||||||
}
|
|
||||||
fData = newData;
|
fData = newData;
|
||||||
fMallocSize = newSize;
|
fMallocSize = newSize;
|
||||||
} else // couldn't alloc the memory
|
} else // couldn't alloc the memory
|
||||||
@@ -473,14 +453,14 @@ BMallocIO::_Resize(off_t size)
|
|||||||
void BMallocIO::_ReservedMallocIO1() {}
|
void BMallocIO::_ReservedMallocIO1() {}
|
||||||
void BMallocIO::_ReservedMallocIO2() {}
|
void BMallocIO::_ReservedMallocIO2() {}
|
||||||
|
|
||||||
// copy constructor
|
|
||||||
|
// Private or Reserved
|
||||||
BMallocIO::BMallocIO(const BMallocIO &)
|
BMallocIO::BMallocIO(const BMallocIO &)
|
||||||
{
|
{
|
||||||
// copying not allowed...
|
// copying not allowed...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// assignment operator
|
|
||||||
BMallocIO &
|
BMallocIO &
|
||||||
BMallocIO::operator=(const BMallocIO &)
|
BMallocIO::operator=(const BMallocIO &)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user