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