Style cleanup.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22600 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2007-10-17 20:51:10 +00:00
parent b0e2e12f4f
commit 46b93b2cfd
4 changed files with 119 additions and 66 deletions
+15 -11
View File
@@ -1,13 +1,14 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
/*
* Copyright 2003-2007, Ingo Weinhold, [email protected].
* Copyright 2003, Tyler Akidau, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef _DISK_DEVICE_H
#define _DISK_DEVICE_H
#include <Partition.h>
struct user_disk_device_data;
class BDiskDevice : public BPartition {
@@ -43,18 +44,21 @@ private:
BDiskDevice(const BDiskDevice&);
BDiskDevice& operator=(const BDiskDevice&);
static status_t _GetData(partition_id id, bool deviceOnly, bool shadow,
size_t neededSize, user_disk_device_data **data);
static status_t _GetData(partition_id id, bool deviceOnly,
bool shadow, size_t neededSize,
user_disk_device_data** data);
status_t _SetTo(partition_id id, bool deviceOnly, bool shadow,
size_t neededSize);
status_t _SetTo(partition_id id, bool deviceOnly,
bool shadow, size_t neededSize);
status_t _SetTo(user_disk_device_data* data);
status_t _Update(bool shadow, bool* updated);
status_t _Update(user_disk_device_data *data, bool *updated);
status_t _Update(user_disk_device_data* data,
bool* updated);
static void _ClearUserData(user_partition_data* data);
virtual bool _AcceptVisitor(BDiskDeviceVisitor *visitor, int32 level);
virtual bool _AcceptVisitor(BDiskDeviceVisitor* visitor,
int32 level);
user_disk_device_data* fDeviceData;
};
+2 -1
View File
@@ -1,5 +1,6 @@
/*
* Copyright 2003-2007, Ingo Weinhold, [email protected].de.
* Copyright 2003-2007, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2003, Tyler Akidau, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef _PARTITION_H
+54 -6
View File
@@ -1,7 +1,7 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
/*
* Copyright 2003-2007, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#include <DiskDevice.h>
@@ -28,6 +28,7 @@
\brief A BDiskDevice object represents a storage device.
*/
// constructor
/*! \brief Creates an uninitialized BDiskDevice object.
*/
@@ -36,6 +37,7 @@ BDiskDevice::BDiskDevice()
{
}
// destructor
/*! \brief Frees all resources associated with this object.
*/
@@ -44,6 +46,7 @@ BDiskDevice::~BDiskDevice()
CancelModifications();
}
// HasMedia
/*! \brief Returns whether the device contains a media.
\return \c true, if the device contains a media, \c false otherwise.
@@ -55,6 +58,7 @@ BDiskDevice::HasMedia() const
&& fDeviceData->device_flags & B_DISK_DEVICE_HAS_MEDIA);
}
// IsRemovableMedia
/*! \brief Returns whether the device media are removable.
\return \c true, if the device media are removable, \c false otherwise.
@@ -66,6 +70,7 @@ BDiskDevice::IsRemovableMedia() const
&& fDeviceData->device_flags & B_DISK_DEVICE_REMOVABLE);
}
// IsReadOnlyMedia
bool
BDiskDevice::IsReadOnlyMedia() const
@@ -74,6 +79,7 @@ BDiskDevice::IsReadOnlyMedia() const
&& fDeviceData->device_flags & B_DISK_DEVICE_READ_ONLY);
}
// IsWriteOnceMedia
bool
BDiskDevice::IsWriteOnceMedia() const
@@ -82,6 +88,7 @@ BDiskDevice::IsWriteOnceMedia() const
&& fDeviceData->device_flags & B_DISK_DEVICE_WRITE_ONCE);
}
// Eject
/*! \brief Eject the device's media.
@@ -120,6 +127,7 @@ BDiskDevice::Eject(bool update)
return B_ERROR;
}
// SetTo
status_t
BDiskDevice::SetTo(partition_id id)
@@ -127,6 +135,7 @@ BDiskDevice::SetTo(partition_id id)
return _SetTo(id, true, false, 0);
}
// Update
/*! \brief Updates the object to reflect the latest changes to the device.
@@ -146,6 +155,7 @@ BDiskDevice::Update(bool *updated)
return _Update(_IsShadow(), updated);
}
// Unset
void
BDiskDevice::Unset()
@@ -155,6 +165,7 @@ BDiskDevice::Unset()
fDeviceData = NULL;
}
// InitCheck
status_t
BDiskDevice::InitCheck() const
@@ -162,6 +173,7 @@ BDiskDevice::InitCheck() const
return (fDeviceData ? B_OK : B_NO_INIT);
}
// GetPath
status_t
BDiskDevice::GetPath(BPath* path) const
@@ -171,6 +183,7 @@ BDiskDevice::GetPath(BPath *path) const
return path->SetTo(fDeviceData->path);
}
// IsModified
bool
BDiskDevice::IsModified() const
@@ -179,6 +192,7 @@ BDiskDevice::IsModified() const
&& _kern_is_disk_device_modified(ID()));
}
// PrepareModifications
/*! \brief Initializes the partition hierarchy for modifications.
*
@@ -197,19 +211,23 @@ BDiskDevice::PrepareModifications()
return error;
if (_IsShadow())
return B_ERROR;
// ask kernel to prepare for modifications
error = _kern_prepare_disk_device_modifications(ID());
if (error != B_OK)
return error;
// update
error = _Update(true, NULL);
if (error != B_OK) {
// bad -- cancelling the modifications is all we can do
_kern_cancel_disk_device_modifications(ID());
}
return error;
}
// CommitModifications
/*! \brief Commits modifications to device.
*
@@ -219,14 +237,14 @@ BDiskDevice::PrepareModifications()
*/
status_t
BDiskDevice::CommitModifications(bool synchronously,
BMessenger progressMessenger,
bool receiveCompleteProgressUpdates)
BMessenger progressMessenger, bool receiveCompleteProgressUpdates)
{
status_t error = InitCheck();
if (error != B_OK)
return error;
if (!_IsShadow())
return B_BAD_VALUE;
// TODO: Get port and token from the progressMessenger
// TODO: Respect "synchronously"!
port_id port = -1;
@@ -235,9 +253,11 @@ BDiskDevice::CommitModifications(bool synchronously,
receiveCompleteProgressUpdates);
if (error == B_OK)
error = _SetTo(ID(), true, false, 0);
return error;
}
// CancelModifications
/*! \brief Cancels all modifications performed on the device.
*
@@ -251,12 +271,15 @@ BDiskDevice::CancelModifications()
return error;
if (!_IsShadow())
return B_BAD_VALUE;
error = _kern_cancel_disk_device_modifications(ID());
if (error == B_OK)
error = _SetTo(ID(), true, false, 0);
return error;
}
// copy constructor
/*! \brief Privatized copy constructor to avoid usage.
*/
@@ -264,6 +287,7 @@ BDiskDevice::BDiskDevice(const BDiskDevice &)
{
}
// =
/*! \brief Privatized assignment operator to avoid usage.
*/
@@ -273,6 +297,7 @@ BDiskDevice::operator=(const BDiskDevice &)
return *this;
}
// _GetData
status_t
BDiskDevice::_GetData(partition_id id, bool deviceOnly, bool shadow,
@@ -288,6 +313,7 @@ BDiskDevice::_GetData(partition_id id, bool deviceOnly, bool shadow,
return B_NO_MEMORY;
bufferSize = neededSize;
}
status_t error = B_OK;
do {
error = _kern_get_disk_device_data(id, deviceOnly, shadow,
@@ -297,47 +323,60 @@ BDiskDevice::_GetData(partition_id id, bool deviceOnly, bool shadow,
// buffer to small re-allocate it
if (buffer)
free(buffer);
buffer = malloc(neededSize);
if (buffer)
bufferSize = neededSize;
else
error = B_NO_MEMORY;
}
} while (error == B_BUFFER_OVERFLOW);
// set result / cleanup on error
if (error == B_OK)
*data = (user_disk_device_data*)buffer;
else if (buffer)
free(buffer);
return error;
}
// _SetTo
status_t
BDiskDevice::_SetTo(partition_id id, bool deviceOnly, bool shadow,
size_t neededSize)
{
Unset();
// get the device data
user_disk_device_data* data = NULL;
status_t error = _GetData(id, deviceOnly, shadow, neededSize, &data);
// set the data
if (error == B_OK)
error = _SetTo(data);
// cleanup on error
if (error != B_OK && data)
free(data);
return error;
}
// _SetTo
status_t
BDiskDevice::_SetTo(user_disk_device_data* data)
{
Unset();
if (!data)
return B_BAD_VALUE;
fDeviceData = data;
status_t error = BPartition::_SetTo(this, NULL,
&fDeviceData->device_partition_data);
if (error != B_OK) {
@@ -346,27 +385,34 @@ BDiskDevice::_SetTo(user_disk_device_data *data)
fDeviceData = NULL;
Unset();
}
return error;
}
// _Update
status_t
BDiskDevice::_Update(bool shadow, bool* updated)
{
if (InitCheck() != B_OK)
return InitCheck();
// get the device data
user_disk_device_data* data = NULL;
status_t error = _GetData(ID(), true, shadow, 0, &data);
// set the data
if (error == B_OK)
error = _Update(data, updated);
// cleanup on error
if (error != B_OK && data)
free(data);
return error;
}
// _Update
status_t
BDiskDevice::_Update(user_disk_device_data* data, bool* updated)
@@ -399,9 +445,11 @@ BDiskDevice::_Update(user_disk_device_data *data, bool *updated)
}
free(oldData);
}
return error;
}
// _AcceptVisitor
bool
BDiskDevice::_AcceptVisitor(BDiskDeviceVisitor* visitor, int32 level)
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2007, Ingo Weinhold, [email protected].de.
* Copyright 2003-2007, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/