Coding style cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22587 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the Haiku distribution and is covered
|
||||
// by the MIT license.
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* Copyright 2003-2007, Ingo Weinhold, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _PARTITION_H
|
||||
#define _PARTITION_H
|
||||
|
||||
@@ -11,6 +10,7 @@
|
||||
#include <Mime.h>
|
||||
#include <ObjectList.h>
|
||||
|
||||
|
||||
class BBitmap;
|
||||
class BDiskDevice;
|
||||
class BDiskDeviceParameterEditor;
|
||||
@@ -22,6 +22,7 @@ class BPath;
|
||||
class BVolume;
|
||||
struct user_partition_data;
|
||||
|
||||
|
||||
class BPartition {
|
||||
public:
|
||||
// Partition Info
|
||||
@@ -48,7 +49,6 @@ public:
|
||||
const char* Type() const; // See DiskDeviceTypes.h
|
||||
const char* ContentType() const; // See DiskDeviceTypes.h
|
||||
partition_id ID() const;
|
||||
|
||||
const char* Parameters() const;
|
||||
const char* ContentParameters() const;
|
||||
|
||||
@@ -59,7 +59,8 @@ public:
|
||||
status_t GetIcon(BBitmap* icon, icon_size which) const;
|
||||
status_t GetMountPoint(BPath* mountPoint) const;
|
||||
|
||||
dev_t Mount(const char *mountPoint = NULL, uint32 mountFlags = 0,
|
||||
dev_t Mount(const char* mountPoint = NULL,
|
||||
uint32 mountFlags = 0,
|
||||
const char* parameters = NULL);
|
||||
status_t Unmount(uint32 unmountFlags = 0);
|
||||
|
||||
@@ -71,17 +72,20 @@ public:
|
||||
int32 CountChildren() const;
|
||||
BPartition* FindDescendant(partition_id id) const;
|
||||
|
||||
status_t GetPartitioningInfo(BPartitioningInfo *info) const;
|
||||
status_t GetPartitioningInfo(
|
||||
BPartitioningInfo* info) const;
|
||||
|
||||
BPartition* VisitEachChild(BDiskDeviceVisitor* visitor);
|
||||
virtual BPartition *VisitEachDescendant(BDiskDeviceVisitor *visitor);
|
||||
virtual BPartition* VisitEachDescendant(
|
||||
BDiskDeviceVisitor* visitor);
|
||||
|
||||
// Self Modification
|
||||
|
||||
bool CanDefragment(bool* whileMounted = NULL) const;
|
||||
status_t Defragment() const;
|
||||
|
||||
bool CanRepair(bool checkOnly, bool *whileMounted = NULL) const;
|
||||
bool CanRepair(bool checkOnly,
|
||||
bool* whileMounted = NULL) const;
|
||||
status_t Repair(bool checkOnly) const;
|
||||
|
||||
bool CanResize(bool* canResizeContents = NULL,
|
||||
@@ -89,8 +93,10 @@ public:
|
||||
status_t ValidateResize(off_t* size) const;
|
||||
status_t Resize(off_t size);
|
||||
|
||||
bool CanMove(BObjectList<BPartition> *unmovableDescendants = NULL,
|
||||
BObjectList<BPartition> *movableOnlyIfUnmounted = NULL) const;
|
||||
bool CanMove(BObjectList<BPartition>*
|
||||
unmovableDescendants = NULL,
|
||||
BObjectList<BPartition>*
|
||||
movableOnlyIfUnmounted = NULL) const;
|
||||
status_t ValidateMove(off_t* newOffset) const;
|
||||
status_t Move(off_t newOffset);
|
||||
|
||||
@@ -99,43 +105,52 @@ public:
|
||||
// adjusts name to be suitable
|
||||
status_t SetName(const char* name);
|
||||
|
||||
bool CanSetContentName(bool *whileMounted = NULL) const;
|
||||
bool CanSetContentName(
|
||||
bool* whileMounted = NULL) const;
|
||||
status_t ValidateSetContentName(BString* name) const;
|
||||
// adjusts name to be suitable
|
||||
status_t SetContentName(const char* name);
|
||||
|
||||
bool CanSetType() const;
|
||||
status_t ValidateSetType(const char* type) const;
|
||||
// type must be one the parent disk system's GetNextSupportedType()
|
||||
// returns.
|
||||
// type must be one the parent disk system's
|
||||
// GetNextSupportedType() returns.
|
||||
status_t SetType(const char* type);
|
||||
|
||||
bool CanEditParameters() const;
|
||||
status_t GetParameterEditor(BDiskDeviceParameterEditor **editor);
|
||||
status_t GetParameterEditor(
|
||||
BDiskDeviceParameterEditor** editor);
|
||||
status_t SetParameters(const char* parameters);
|
||||
|
||||
bool CanEditContentParameters(bool *whileMounted = NULL) const;
|
||||
status_t GetContentParameterEditor(BDiskDeviceParameterEditor **editor);
|
||||
bool CanEditContentParameters(
|
||||
bool* whileMounted = NULL) const;
|
||||
status_t GetContentParameterEditor(
|
||||
BDiskDeviceParameterEditor** editor);
|
||||
status_t SetContentParameters(const char* parameters);
|
||||
|
||||
bool CanInitialize(const char* diskSystem) const;
|
||||
status_t GetInitializationParameterEditor(const char *system,
|
||||
status_t GetInitializationParameterEditor(
|
||||
const char* system,
|
||||
BDiskDeviceParameterEditor** editor) const;
|
||||
status_t ValidateInitialize(const char *diskSystem, BString* name,
|
||||
const char *parameters);
|
||||
status_t Initialize(const char *diskSystem, const char *name,
|
||||
const char *parameters);
|
||||
status_t ValidateInitialize(const char* diskSystem,
|
||||
BString* name, const char* parameters);
|
||||
status_t Initialize(const char* diskSystem,
|
||||
const char* name, const char* parameters);
|
||||
status_t Uninitialize();
|
||||
|
||||
// Modification of child partitions
|
||||
|
||||
bool CanCreateChild() const;
|
||||
status_t GetChildCreationParameterEditor(const char *type,
|
||||
status_t GetChildCreationParameterEditor(
|
||||
const char* type,
|
||||
BDiskDeviceParameterEditor** editor) const;
|
||||
status_t ValidateCreateChild(off_t* start, off_t* size,
|
||||
const char* type, BString* name, const char* parameters) const;
|
||||
status_t CreateChild(off_t start, off_t size, const char* type,
|
||||
const char* name, const char* parameters, BPartition** child = NULL);
|
||||
const char* type, BString* name,
|
||||
const char* parameters) const;
|
||||
status_t CreateChild(off_t start, off_t size,
|
||||
const char* type, const char* name,
|
||||
const char* parameters,
|
||||
BPartition** child = NULL);
|
||||
|
||||
bool CanDeleteChild(int32 index) const;
|
||||
status_t DeleteChild(int32 index);
|
||||
@@ -146,14 +161,16 @@ private:
|
||||
BPartition();
|
||||
BPartition(const BPartition&);
|
||||
virtual ~BPartition();
|
||||
|
||||
BPartition& operator=(const BPartition&);
|
||||
|
||||
status_t _SetTo(BDiskDevice* device, BPartition* parent,
|
||||
user_partition_data* data);
|
||||
void _Unset();
|
||||
status_t _RemoveObsoleteDescendants(user_partition_data *data,
|
||||
status_t _RemoveObsoleteDescendants(
|
||||
user_partition_data* data, bool* updated);
|
||||
status_t _Update(user_partition_data* data,
|
||||
bool* updated);
|
||||
status_t _Update(user_partition_data *data, bool *updated);
|
||||
void _RemoveChild(int32 index);
|
||||
|
||||
bool _IsShadow() const;
|
||||
@@ -163,16 +180,20 @@ private:
|
||||
|
||||
int32 _CountDescendants() const;
|
||||
int32 _Level() const;
|
||||
virtual bool _AcceptVisitor(BDiskDeviceVisitor *visitor, int32 level);
|
||||
BPartition *_VisitEachDescendant(BDiskDeviceVisitor *visitor,
|
||||
virtual bool _AcceptVisitor(BDiskDeviceVisitor* visitor,
|
||||
int32 level);
|
||||
BPartition* _VisitEachDescendant(
|
||||
BDiskDeviceVisitor* visitor,
|
||||
int32 level = -1);
|
||||
|
||||
const user_partition_data* _PartitionData() const;
|
||||
|
||||
bool _HasContent() const;
|
||||
bool _SupportsOperation(uint32 flag, uint32 whileMountedFlag,
|
||||
bool _SupportsOperation(uint32 flag,
|
||||
uint32 whileMountedFlag,
|
||||
bool* whileMounted) const;
|
||||
bool _SupportsChildOperation(const BPartition* child, uint32 flag) const;
|
||||
bool _SupportsChildOperation(const BPartition* child,
|
||||
uint32 flag) const;
|
||||
|
||||
friend class BDiskDevice;
|
||||
friend class BDiskSystem;
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
/*
|
||||
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2007, Ingo Weinhold, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Ingo Weinhold, [email protected]
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
@@ -57,8 +54,7 @@ using std::nothrow;
|
||||
0, if they are equal, or a value greater than 0, if
|
||||
\a str1 is greater \a str2.
|
||||
*/
|
||||
static inline
|
||||
int
|
||||
static inline int
|
||||
compare_string(const char* str1, const char* str2)
|
||||
{
|
||||
if (str1 == NULL) {
|
||||
@@ -1215,6 +1211,7 @@ BPartition::_SetTo(BDiskDevice *device, BPartition *parent,
|
||||
fDevice = device;
|
||||
fParent = parent;
|
||||
fPartitionData->user_data = this;
|
||||
|
||||
// create and init children
|
||||
status_t error = B_OK;
|
||||
for (int32 i = 0; error == B_OK && i < fPartitionData->child_count; i++) {
|
||||
@@ -1226,6 +1223,7 @@ BPartition::_SetTo(BDiskDevice *device, BPartition *parent,
|
||||
} else
|
||||
error = B_NO_MEMORY;
|
||||
}
|
||||
|
||||
// cleanup on error
|
||||
if (error != B_OK)
|
||||
_Unset();
|
||||
@@ -1245,6 +1243,7 @@ BPartition::_Unset()
|
||||
}
|
||||
fPartitionData->user_data = NULL;
|
||||
}
|
||||
|
||||
fDevice = NULL;
|
||||
fParent = NULL;
|
||||
fPartitionData = NULL;
|
||||
@@ -1253,8 +1252,7 @@ BPartition::_Unset()
|
||||
|
||||
// _RemoveObsoleteDescendants
|
||||
status_t
|
||||
BPartition::_RemoveObsoleteDescendants(user_partition_data *data,
|
||||
bool *updated)
|
||||
BPartition::_RemoveObsoleteDescendants(user_partition_data* data, bool* updated)
|
||||
{
|
||||
// remove all children not longer persistent
|
||||
// Not exactly efficient: O(n^2), considering BList::RemoveItem()
|
||||
@@ -1273,12 +1271,14 @@ BPartition::_RemoveObsoleteDescendants(user_partition_data *data,
|
||||
data->children[k], updated);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
// set the user data to the BPartition object to find it
|
||||
// quicker later
|
||||
data->children[k]->user_data = child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if partition is obsolete, remove it
|
||||
if (!found) {
|
||||
*updated = true;
|
||||
@@ -1312,6 +1312,7 @@ BPartition::_Update(user_partition_data *data, bool *updated)
|
||||
oldData->content_parameters)) {
|
||||
*updated = true;
|
||||
}
|
||||
|
||||
// add new children and update existing ones
|
||||
status_t error = B_OK;
|
||||
for (int32 i = 0; i < data->child_count; i++) {
|
||||
@@ -1326,12 +1327,15 @@ BPartition::_Update(user_partition_data *data, bool *updated)
|
||||
// new partition
|
||||
*updated = true;
|
||||
child = new(nothrow) BPartition;
|
||||
if (child) {
|
||||
error = child->_SetTo(fDevice, this, data->children[i]);
|
||||
if (error != B_OK)
|
||||
delete child;
|
||||
} else
|
||||
if (!child)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
error = child->_SetTo(fDevice, this, data->children[i]);
|
||||
if (error != B_OK) {
|
||||
delete child;
|
||||
return error;
|
||||
}
|
||||
|
||||
childData->user_data = child;
|
||||
}
|
||||
}
|
||||
@@ -1346,8 +1350,10 @@ BPartition::_RemoveChild(int32 index)
|
||||
int32 count = CountChildren();
|
||||
if (!fPartitionData || index < 0 || index >= count)
|
||||
return;
|
||||
|
||||
// delete the BPartition and its children
|
||||
delete ChildAt(index);
|
||||
|
||||
// compact the children array
|
||||
for (int32 i = index + 1; i < count; i++)
|
||||
fPartitionData->children[i - 1] = fPartitionData->children[i];
|
||||
|
||||
Reference in New Issue
Block a user