Coding style cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22587 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+144
-123
@@ -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,166 +22,187 @@ class BPath;
|
|||||||
class BVolume;
|
class BVolume;
|
||||||
struct user_partition_data;
|
struct user_partition_data;
|
||||||
|
|
||||||
|
|
||||||
class BPartition {
|
class BPartition {
|
||||||
public:
|
public:
|
||||||
// Partition Info
|
// Partition Info
|
||||||
|
|
||||||
off_t Offset() const; // 0 for devices
|
off_t Offset() const; // 0 for devices
|
||||||
off_t Size() const;
|
off_t Size() const;
|
||||||
off_t ContentSize() const; // 0 if uninitialized
|
off_t ContentSize() const; // 0 if uninitialized
|
||||||
uint32 BlockSize() const;
|
uint32 BlockSize() const;
|
||||||
int32 Index() const; // 0 for devices
|
int32 Index() const; // 0 for devices
|
||||||
uint32 Status() const;
|
uint32 Status() const;
|
||||||
|
|
||||||
bool ContainsFileSystem() const;
|
bool ContainsFileSystem() const;
|
||||||
bool ContainsPartitioningSystem() const;
|
bool ContainsPartitioningSystem() const;
|
||||||
|
|
||||||
bool IsDevice() const;
|
bool IsDevice() const;
|
||||||
bool IsReadOnly() const;
|
bool IsReadOnly() const;
|
||||||
bool IsMounted() const;
|
bool IsMounted() const;
|
||||||
bool IsBusy() const;
|
bool IsBusy() const;
|
||||||
|
|
||||||
uint32 Flags() const;
|
uint32 Flags() const;
|
||||||
|
|
||||||
const char *Name() const;
|
const char* Name() const;
|
||||||
const char *ContentName() const;
|
const char* ContentName() const;
|
||||||
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* ContentParameters() const;
|
||||||
|
|
||||||
const char* Parameters() const;
|
status_t GetDiskSystem(BDiskSystem* diskSystem) const;
|
||||||
const char* ContentParameters() const;
|
|
||||||
|
|
||||||
status_t GetDiskSystem(BDiskSystem *diskSystem) const;
|
|
||||||
|
|
||||||
virtual status_t GetPath(BPath *path) const;
|
virtual status_t GetPath(BPath* path) const;
|
||||||
status_t GetVolume(BVolume *volume) const;
|
status_t GetVolume(BVolume* volume) const;
|
||||||
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,
|
||||||
const char *parameters = NULL);
|
uint32 mountFlags = 0,
|
||||||
status_t Unmount(uint32 unmountFlags = 0);
|
const char* parameters = NULL);
|
||||||
|
status_t Unmount(uint32 unmountFlags = 0);
|
||||||
|
|
||||||
// Hierarchy Info
|
// Hierarchy Info
|
||||||
|
|
||||||
BDiskDevice *Device() const;
|
BDiskDevice* Device() const;
|
||||||
BPartition *Parent() const;
|
BPartition* Parent() const;
|
||||||
BPartition *ChildAt(int32 index) const;
|
BPartition* ChildAt(int32 index) const;
|
||||||
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,
|
||||||
status_t Repair(bool checkOnly) const;
|
bool* whileMounted = NULL) const;
|
||||||
|
status_t Repair(bool checkOnly) const;
|
||||||
|
|
||||||
bool CanResize(bool *canResizeContents = NULL,
|
bool CanResize(bool* canResizeContents = NULL,
|
||||||
bool *whileMounted = NULL) const;
|
bool* whileMounted = NULL) const;
|
||||||
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,
|
||||||
status_t ValidateMove(off_t *newOffset) const;
|
BObjectList<BPartition>*
|
||||||
status_t Move(off_t newOffset);
|
movableOnlyIfUnmounted = NULL) const;
|
||||||
|
status_t ValidateMove(off_t* newOffset) const;
|
||||||
|
status_t Move(off_t newOffset);
|
||||||
|
|
||||||
bool CanSetName() const;
|
bool CanSetName() const;
|
||||||
status_t ValidateSetName(BString* name) const;
|
status_t ValidateSetName(BString* name) const;
|
||||||
// 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(
|
||||||
status_t ValidateSetContentName(BString* name) const;
|
bool* whileMounted = NULL) const;
|
||||||
// adjusts name to be suitable
|
status_t ValidateSetContentName(BString* name) const;
|
||||||
status_t SetContentName(const char *name);
|
// adjusts name to be suitable
|
||||||
|
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(
|
||||||
status_t SetParameters(const char *parameters);
|
BDiskDeviceParameterEditor** editor);
|
||||||
|
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 SetContentParameters(const char *parameters);
|
status_t GetContentParameterEditor(
|
||||||
|
BDiskDeviceParameterEditor** editor);
|
||||||
|
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(
|
||||||
BDiskDeviceParameterEditor **editor) const;
|
const char* system,
|
||||||
status_t ValidateInitialize(const char *diskSystem, BString* name,
|
BDiskDeviceParameterEditor** editor) const;
|
||||||
const char *parameters);
|
status_t ValidateInitialize(const char* diskSystem,
|
||||||
status_t Initialize(const char *diskSystem, const char *name,
|
BString* name, const char* parameters);
|
||||||
const char *parameters);
|
status_t Initialize(const char* diskSystem,
|
||||||
status_t Uninitialize();
|
const char* name, const char* parameters);
|
||||||
|
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(
|
||||||
BDiskDeviceParameterEditor **editor) const;
|
const char* type,
|
||||||
status_t ValidateCreateChild(off_t* start, off_t* size,
|
BDiskDeviceParameterEditor** editor) const;
|
||||||
const char* type, BString* name, const char* parameters) const;
|
status_t ValidateCreateChild(off_t* start, off_t* size,
|
||||||
status_t CreateChild(off_t start, off_t size, const char* type,
|
const char* type, BString* name,
|
||||||
const char* name, const char* parameters, BPartition** child = NULL);
|
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;
|
bool CanDeleteChild(int32 index) const;
|
||||||
status_t DeleteChild(int32 index);
|
status_t DeleteChild(int32 index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Delegate;
|
class Delegate;
|
||||||
|
|
||||||
BPartition();
|
BPartition();
|
||||||
BPartition(const BPartition &);
|
BPartition(const BPartition&);
|
||||||
virtual ~BPartition();
|
virtual ~BPartition();
|
||||||
BPartition & operator=(const BPartition &);
|
|
||||||
|
|
||||||
status_t _SetTo(BDiskDevice *device, BPartition *parent,
|
BPartition& operator=(const BPartition&);
|
||||||
user_partition_data *data);
|
|
||||||
void _Unset();
|
|
||||||
status_t _RemoveObsoleteDescendants(user_partition_data *data,
|
|
||||||
bool *updated);
|
|
||||||
status_t _Update(user_partition_data *data, bool *updated);
|
|
||||||
void _RemoveChild(int32 index);
|
|
||||||
|
|
||||||
bool _IsShadow() const;
|
status_t _SetTo(BDiskDevice* device, BPartition* parent,
|
||||||
partition_id _ShadowID() const;
|
user_partition_data* data);
|
||||||
disk_system_id _DiskSystem() const;
|
void _Unset();
|
||||||
int32 _ChangeCounter() const;
|
status_t _RemoveObsoleteDescendants(
|
||||||
|
user_partition_data* data, bool* updated);
|
||||||
|
status_t _Update(user_partition_data* data,
|
||||||
|
bool* updated);
|
||||||
|
void _RemoveChild(int32 index);
|
||||||
|
|
||||||
int32 _CountDescendants() const;
|
bool _IsShadow() const;
|
||||||
int32 _Level() const;
|
partition_id _ShadowID() const;
|
||||||
virtual bool _AcceptVisitor(BDiskDeviceVisitor *visitor, int32 level);
|
disk_system_id _DiskSystem() const;
|
||||||
BPartition *_VisitEachDescendant(BDiskDeviceVisitor *visitor,
|
int32 _ChangeCounter() const;
|
||||||
int32 level = -1);
|
|
||||||
|
|
||||||
const user_partition_data* _PartitionData() const;
|
int32 _CountDescendants() const;
|
||||||
|
int32 _Level() const;
|
||||||
|
virtual bool _AcceptVisitor(BDiskDeviceVisitor* visitor,
|
||||||
|
int32 level);
|
||||||
|
BPartition* _VisitEachDescendant(
|
||||||
|
BDiskDeviceVisitor* visitor,
|
||||||
|
int32 level = -1);
|
||||||
|
|
||||||
bool _HasContent() const;
|
const user_partition_data* _PartitionData() const;
|
||||||
bool _SupportsOperation(uint32 flag, uint32 whileMountedFlag,
|
|
||||||
bool* whileMounted) const;
|
|
||||||
bool _SupportsChildOperation(const BPartition* child, uint32 flag) const;
|
|
||||||
|
|
||||||
friend class BDiskDevice;
|
bool _HasContent() const;
|
||||||
friend class BDiskSystem;
|
bool _SupportsOperation(uint32 flag,
|
||||||
friend class BMutablePartition;
|
uint32 whileMountedFlag,
|
||||||
|
bool* whileMounted) const;
|
||||||
|
bool _SupportsChildOperation(const BPartition* child,
|
||||||
|
uint32 flag) const;
|
||||||
|
|
||||||
BDiskDevice* fDevice;
|
friend class BDiskDevice;
|
||||||
BPartition* fParent;
|
friend class BDiskSystem;
|
||||||
user_partition_data* fPartitionData;
|
friend class BMutablePartition;
|
||||||
Delegate* fDelegate;
|
|
||||||
|
BDiskDevice* fDevice;
|
||||||
|
BPartition* fParent;
|
||||||
|
user_partition_data* fPartitionData;
|
||||||
|
Delegate* fDelegate;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _PARTITION_H
|
#endif // _PARTITION_H
|
||||||
|
|||||||
@@ -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,9 +54,8 @@ 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) {
|
||||||
if (str2 == NULL)
|
if (str2 == NULL)
|
||||||
@@ -236,7 +232,7 @@ BPartition::Flags() const
|
|||||||
\return The name of the partition, or \c NULL, if the partitioning system
|
\return The name of the partition, or \c NULL, if the partitioning system
|
||||||
does not support names.
|
does not support names.
|
||||||
*/
|
*/
|
||||||
const char *
|
const char*
|
||||||
BPartition::Name() const
|
BPartition::Name() const
|
||||||
{
|
{
|
||||||
return _PartitionData()->name;
|
return _PartitionData()->name;
|
||||||
@@ -244,7 +240,7 @@ BPartition::Name() const
|
|||||||
|
|
||||||
|
|
||||||
// ContentName
|
// ContentName
|
||||||
const char *
|
const char*
|
||||||
BPartition::ContentName() const
|
BPartition::ContentName() const
|
||||||
{
|
{
|
||||||
return _PartitionData()->content_name;
|
return _PartitionData()->content_name;
|
||||||
@@ -255,7 +251,7 @@ BPartition::ContentName() const
|
|||||||
/*! \brief Returns a human readable string for the type of the partition.
|
/*! \brief Returns a human readable string for the type of the partition.
|
||||||
\return A human readable string for the type of the partition.
|
\return A human readable string for the type of the partition.
|
||||||
*/
|
*/
|
||||||
const char *
|
const char*
|
||||||
BPartition::Type() const
|
BPartition::Type() const
|
||||||
{
|
{
|
||||||
return _PartitionData()->type;
|
return _PartitionData()->type;
|
||||||
@@ -263,7 +259,7 @@ BPartition::Type() const
|
|||||||
|
|
||||||
|
|
||||||
// ContentType
|
// ContentType
|
||||||
const char *
|
const char*
|
||||||
BPartition::ContentType() const
|
BPartition::ContentType() const
|
||||||
{
|
{
|
||||||
return _PartitionData()->content_type;
|
return _PartitionData()->content_type;
|
||||||
@@ -305,7 +301,7 @@ BPartition::ContentParameters() const
|
|||||||
|
|
||||||
// GetDiskSystem
|
// GetDiskSystem
|
||||||
status_t
|
status_t
|
||||||
BPartition::GetDiskSystem(BDiskSystem *diskSystem) const
|
BPartition::GetDiskSystem(BDiskSystem* diskSystem) const
|
||||||
{
|
{
|
||||||
const user_partition_data* data = _PartitionData();
|
const user_partition_data* data = _PartitionData();
|
||||||
if (!data || !diskSystem)
|
if (!data || !diskSystem)
|
||||||
@@ -320,7 +316,7 @@ BPartition::GetDiskSystem(BDiskSystem *diskSystem) const
|
|||||||
|
|
||||||
// GetPath
|
// GetPath
|
||||||
status_t
|
status_t
|
||||||
BPartition::GetPath(BPath *path) const
|
BPartition::GetPath(BPath* path) const
|
||||||
{
|
{
|
||||||
// The path is constructed on the fly using our parent
|
// The path is constructed on the fly using our parent
|
||||||
if (path == NULL || Parent() == NULL || Index() < 0)
|
if (path == NULL || Parent() == NULL || Index() < 0)
|
||||||
@@ -335,7 +331,7 @@ BPartition::GetPath(BPath *path) const
|
|||||||
|
|
||||||
if (Parent()->IsDevice()) {
|
if (Parent()->IsDevice()) {
|
||||||
// Our parent is a device, so we replace `raw' by our index.
|
// Our parent is a device, so we replace `raw' by our index.
|
||||||
const char *leaf = path->Leaf();
|
const char* leaf = path->Leaf();
|
||||||
if (!leaf || strcmp(leaf, "raw") != B_OK)
|
if (!leaf || strcmp(leaf, "raw") != B_OK)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
@@ -364,7 +360,7 @@ BPartition::GetPath(BPath *path) const
|
|||||||
accordingly, another error code otherwise.
|
accordingly, another error code otherwise.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BPartition::GetVolume(BVolume *volume) const
|
BPartition::GetVolume(BVolume* volume) const
|
||||||
{
|
{
|
||||||
if (volume)
|
if (volume)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -387,7 +383,7 @@ BPartition::GetVolume(BVolume *volume) const
|
|||||||
\return \c B_OK, if everything went fine, another error code otherwise.
|
\return \c B_OK, if everything went fine, another error code otherwise.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BPartition::GetIcon(BBitmap *icon, icon_size which) const
|
BPartition::GetIcon(BBitmap* icon, icon_size which) const
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
status_t error = (icon ? B_OK : B_BAD_VALUE);
|
status_t error = (icon ? B_OK : B_BAD_VALUE);
|
||||||
@@ -400,7 +396,7 @@ BPartition::GetIcon(BBitmap *icon, icon_size which) const
|
|||||||
error = volume.GetIcon(icon, which);
|
error = volume.GetIcon(icon, which);
|
||||||
} else {
|
} else {
|
||||||
// not mounted: retrieve the icon ourselves
|
// not mounted: retrieve the icon ourselves
|
||||||
if (BDiskDevice *device = Device()) {
|
if (BDiskDevice* device = Device()) {
|
||||||
// get the icon
|
// get the icon
|
||||||
if (error == B_OK)
|
if (error == B_OK)
|
||||||
error = get_device_icon(device->Path(), icon, which);
|
error = get_device_icon(device->Path(), icon, which);
|
||||||
@@ -430,7 +426,7 @@ BPartition::GetIcon(BBitmap *icon, icon_size which) const
|
|||||||
\return \c B_OK, if everything went fine, an error code otherwise.
|
\return \c B_OK, if everything went fine, an error code otherwise.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BPartition::GetMountPoint(BPath *mountPoint) const
|
BPartition::GetMountPoint(BPath* mountPoint) const
|
||||||
{
|
{
|
||||||
if (!mountPoint || !ContainsFileSystem())
|
if (!mountPoint || !ContainsFileSystem())
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -447,7 +443,7 @@ BPartition::GetMountPoint(BPath *mountPoint) const
|
|||||||
|
|
||||||
// partition not mounted
|
// partition not mounted
|
||||||
// get the volume name
|
// get the volume name
|
||||||
const char *volumeName = ContentName();
|
const char* volumeName = ContentName();
|
||||||
if (!volumeName || strlen(volumeName) == 0)
|
if (!volumeName || strlen(volumeName) == 0)
|
||||||
volumeName = Name();
|
volumeName = Name();
|
||||||
if (!volumeName || strlen(volumeName) == 0)
|
if (!volumeName || strlen(volumeName) == 0)
|
||||||
@@ -498,8 +494,8 @@ BPartition::GetMountPoint(BPath *mountPoint) const
|
|||||||
\return \c B_OK, if everything went fine, another error code otherwise.
|
\return \c B_OK, if everything went fine, another error code otherwise.
|
||||||
*/
|
*/
|
||||||
dev_t
|
dev_t
|
||||||
BPartition::Mount(const char *mountPoint, uint32 mountFlags,
|
BPartition::Mount(const char* mountPoint, uint32 mountFlags,
|
||||||
const char *parameters)
|
const char* parameters)
|
||||||
{
|
{
|
||||||
if (IsMounted() || !ContainsFileSystem())
|
if (IsMounted() || !ContainsFileSystem())
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -582,7 +578,7 @@ BPartition::Unmount(uint32 unmountFlags)
|
|||||||
/*! \brief Returns the device this partition resides on.
|
/*! \brief Returns the device this partition resides on.
|
||||||
\return The device this partition resides on.
|
\return The device this partition resides on.
|
||||||
*/
|
*/
|
||||||
BDiskDevice *
|
BDiskDevice*
|
||||||
BPartition::Device() const
|
BPartition::Device() const
|
||||||
{
|
{
|
||||||
return fDevice;
|
return fDevice;
|
||||||
@@ -590,7 +586,7 @@ BPartition::Device() const
|
|||||||
|
|
||||||
|
|
||||||
// Parent
|
// Parent
|
||||||
BPartition *
|
BPartition*
|
||||||
BPartition::Parent() const
|
BPartition::Parent() const
|
||||||
{
|
{
|
||||||
return fParent;
|
return fParent;
|
||||||
@@ -598,7 +594,7 @@ BPartition::Parent() const
|
|||||||
|
|
||||||
|
|
||||||
// ChildAt
|
// ChildAt
|
||||||
BPartition *
|
BPartition*
|
||||||
BPartition::ChildAt(int32 index) const
|
BPartition::ChildAt(int32 index) const
|
||||||
{
|
{
|
||||||
if (fDelegate) {
|
if (fDelegate) {
|
||||||
@@ -624,7 +620,7 @@ BPartition::CountChildren() const
|
|||||||
|
|
||||||
|
|
||||||
// FindDescendant
|
// FindDescendant
|
||||||
BPartition *
|
BPartition*
|
||||||
BPartition::FindDescendant(partition_id id) const
|
BPartition::FindDescendant(partition_id id) const
|
||||||
{
|
{
|
||||||
IDFinderVisitor visitor(id);
|
IDFinderVisitor visitor(id);
|
||||||
@@ -634,7 +630,7 @@ BPartition::FindDescendant(partition_id id) const
|
|||||||
|
|
||||||
// GetPartitioningInfo
|
// GetPartitioningInfo
|
||||||
status_t
|
status_t
|
||||||
BPartition::GetPartitioningInfo(BPartitioningInfo *info) const
|
BPartition::GetPartitioningInfo(BPartitioningInfo* info) const
|
||||||
{
|
{
|
||||||
if (!fDelegate || !info)
|
if (!fDelegate || !info)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -644,12 +640,12 @@ BPartition::GetPartitioningInfo(BPartitioningInfo *info) const
|
|||||||
|
|
||||||
|
|
||||||
// VisitEachChild
|
// VisitEachChild
|
||||||
BPartition *
|
BPartition*
|
||||||
BPartition::VisitEachChild(BDiskDeviceVisitor *visitor)
|
BPartition::VisitEachChild(BDiskDeviceVisitor* visitor)
|
||||||
{
|
{
|
||||||
if (visitor) {
|
if (visitor) {
|
||||||
int32 level = _Level();
|
int32 level = _Level();
|
||||||
for (int32 i = 0; BPartition *child = ChildAt(i); i++) {
|
for (int32 i = 0; BPartition* child = ChildAt(i); i++) {
|
||||||
if (child->_AcceptVisitor(visitor, level))
|
if (child->_AcceptVisitor(visitor, level))
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
@@ -659,8 +655,8 @@ BPartition::VisitEachChild(BDiskDeviceVisitor *visitor)
|
|||||||
|
|
||||||
|
|
||||||
// VisitEachDescendant
|
// VisitEachDescendant
|
||||||
BPartition *
|
BPartition*
|
||||||
BPartition::VisitEachDescendant(BDiskDeviceVisitor *visitor)
|
BPartition::VisitEachDescendant(BDiskDeviceVisitor* visitor)
|
||||||
{
|
{
|
||||||
if (visitor)
|
if (visitor)
|
||||||
return _VisitEachDescendant(visitor);
|
return _VisitEachDescendant(visitor);
|
||||||
@@ -670,7 +666,7 @@ BPartition::VisitEachDescendant(BDiskDeviceVisitor *visitor)
|
|||||||
|
|
||||||
// CanDefragment
|
// CanDefragment
|
||||||
bool
|
bool
|
||||||
BPartition::CanDefragment(bool *whileMounted) const
|
BPartition::CanDefragment(bool* whileMounted) const
|
||||||
{
|
{
|
||||||
return _SupportsOperation(B_DISK_SYSTEM_SUPPORTS_DEFRAGMENTING,
|
return _SupportsOperation(B_DISK_SYSTEM_SUPPORTS_DEFRAGMENTING,
|
||||||
B_DISK_SYSTEM_SUPPORTS_DEFRAGMENTING_WHILE_MOUNTED, whileMounted);
|
B_DISK_SYSTEM_SUPPORTS_DEFRAGMENTING_WHILE_MOUNTED, whileMounted);
|
||||||
@@ -690,7 +686,7 @@ BPartition::Defragment() const
|
|||||||
|
|
||||||
// CanRepair
|
// CanRepair
|
||||||
bool
|
bool
|
||||||
BPartition::CanRepair(bool checkOnly, bool *whileMounted) const
|
BPartition::CanRepair(bool checkOnly, bool* whileMounted) const
|
||||||
{
|
{
|
||||||
uint32 flag;
|
uint32 flag;
|
||||||
uint32 whileMountedFlag;
|
uint32 whileMountedFlag;
|
||||||
@@ -719,7 +715,7 @@ BPartition::Repair(bool checkOnly) const
|
|||||||
|
|
||||||
// CanResize
|
// CanResize
|
||||||
bool
|
bool
|
||||||
BPartition::CanResize(bool *canResizeContents, bool *whileMounted) const
|
BPartition::CanResize(bool* canResizeContents, bool* whileMounted) const
|
||||||
{
|
{
|
||||||
BPartition* parent = Parent();
|
BPartition* parent = Parent();
|
||||||
if (!parent)
|
if (!parent)
|
||||||
@@ -740,7 +736,7 @@ BPartition::CanResize(bool *canResizeContents, bool *whileMounted) const
|
|||||||
|
|
||||||
// ValidateResize
|
// ValidateResize
|
||||||
status_t
|
status_t
|
||||||
BPartition::ValidateResize(off_t *size) const
|
BPartition::ValidateResize(off_t* size) const
|
||||||
{
|
{
|
||||||
BPartition* parent = Parent();
|
BPartition* parent = Parent();
|
||||||
if (!parent || !fDelegate)
|
if (!parent || !fDelegate)
|
||||||
@@ -809,8 +805,8 @@ BPartition::Resize(off_t size)
|
|||||||
|
|
||||||
// CanMove
|
// CanMove
|
||||||
bool
|
bool
|
||||||
BPartition::CanMove(BObjectList<BPartition> *unmovableDescendants,
|
BPartition::CanMove(BObjectList<BPartition>* unmovableDescendants,
|
||||||
BObjectList<BPartition> *movableOnlyIfUnmounted) const
|
BObjectList<BPartition>* movableOnlyIfUnmounted) const
|
||||||
{
|
{
|
||||||
BPartition* parent = Parent();
|
BPartition* parent = Parent();
|
||||||
if (!parent || !fDelegate)
|
if (!parent || !fDelegate)
|
||||||
@@ -823,7 +819,7 @@ BPartition::CanMove(BObjectList<BPartition> *unmovableDescendants,
|
|||||||
|
|
||||||
bool whileMounted;
|
bool whileMounted;
|
||||||
bool movable = _SupportsOperation(B_DISK_SYSTEM_SUPPORTS_MOVING,
|
bool movable = _SupportsOperation(B_DISK_SYSTEM_SUPPORTS_MOVING,
|
||||||
B_DISK_SYSTEM_SUPPORTS_MOVING_WHILE_MOUNTED, &whileMounted);
|
B_DISK_SYSTEM_SUPPORTS_MOVING_WHILE_MOUNTED, &whileMounted);
|
||||||
if (!movable)
|
if (!movable)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -842,7 +838,7 @@ BPartition::CanMove(BObjectList<BPartition> *unmovableDescendants,
|
|||||||
|
|
||||||
// ValidateMove
|
// ValidateMove
|
||||||
status_t
|
status_t
|
||||||
BPartition::ValidateMove(off_t *offset) const
|
BPartition::ValidateMove(off_t* offset) const
|
||||||
{
|
{
|
||||||
BPartition* parent = Parent();
|
BPartition* parent = Parent();
|
||||||
if (!parent || !fDelegate)
|
if (!parent || !fDelegate)
|
||||||
@@ -897,7 +893,7 @@ BPartition::CanSetName() const
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
return parent->_SupportsChildOperation(this,
|
return parent->_SupportsChildOperation(this,
|
||||||
B_DISK_SYSTEM_SUPPORTS_SETTING_NAME);
|
B_DISK_SYSTEM_SUPPORTS_SETTING_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -915,7 +911,7 @@ BPartition::ValidateSetName(BString* name) const
|
|||||||
|
|
||||||
// SetName
|
// SetName
|
||||||
status_t
|
status_t
|
||||||
BPartition::SetName(const char *name)
|
BPartition::SetName(const char* name)
|
||||||
{
|
{
|
||||||
BPartition* parent = Parent();
|
BPartition* parent = Parent();
|
||||||
if (!parent || !fDelegate)
|
if (!parent || !fDelegate)
|
||||||
@@ -927,7 +923,7 @@ BPartition::SetName(const char *name)
|
|||||||
|
|
||||||
// CanSetContentName
|
// CanSetContentName
|
||||||
bool
|
bool
|
||||||
BPartition::CanSetContentName(bool *whileMounted) const
|
BPartition::CanSetContentName(bool* whileMounted) const
|
||||||
{
|
{
|
||||||
return _SupportsOperation(B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_NAME,
|
return _SupportsOperation(B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_NAME,
|
||||||
B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_NAME_WHILE_MOUNTED,
|
B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_NAME_WHILE_MOUNTED,
|
||||||
@@ -948,7 +944,7 @@ BPartition::ValidateSetContentName(BString* name) const
|
|||||||
|
|
||||||
// SetContentName
|
// SetContentName
|
||||||
status_t
|
status_t
|
||||||
BPartition::SetContentName(const char *name)
|
BPartition::SetContentName(const char* name)
|
||||||
{
|
{
|
||||||
if (!fDelegate)
|
if (!fDelegate)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -966,13 +962,13 @@ BPartition::CanSetType() const
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
return parent->_SupportsChildOperation(this,
|
return parent->_SupportsChildOperation(this,
|
||||||
B_DISK_SYSTEM_SUPPORTS_SETTING_TYPE);
|
B_DISK_SYSTEM_SUPPORTS_SETTING_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ValidateSetType
|
// ValidateSetType
|
||||||
status_t
|
status_t
|
||||||
BPartition::ValidateSetType(const char *type) const
|
BPartition::ValidateSetType(const char* type) const
|
||||||
{
|
{
|
||||||
BPartition* parent = Parent();
|
BPartition* parent = Parent();
|
||||||
if (!parent || !fDelegate)
|
if (!parent || !fDelegate)
|
||||||
@@ -984,7 +980,7 @@ BPartition::ValidateSetType(const char *type) const
|
|||||||
|
|
||||||
// SetType
|
// SetType
|
||||||
status_t
|
status_t
|
||||||
BPartition::SetType(const char *type)
|
BPartition::SetType(const char* type)
|
||||||
{
|
{
|
||||||
BPartition* parent = Parent();
|
BPartition* parent = Parent();
|
||||||
if (!parent || !fDelegate)
|
if (!parent || !fDelegate)
|
||||||
@@ -1003,13 +999,13 @@ BPartition::CanEditParameters() const
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
return parent->_SupportsChildOperation(this,
|
return parent->_SupportsChildOperation(this,
|
||||||
B_DISK_SYSTEM_SUPPORTS_SETTING_PARAMETERS);
|
B_DISK_SYSTEM_SUPPORTS_SETTING_PARAMETERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// GetParameterEditor
|
// GetParameterEditor
|
||||||
status_t
|
status_t
|
||||||
BPartition::GetParameterEditor(BDiskDeviceParameterEditor **editor)
|
BPartition::GetParameterEditor(BDiskDeviceParameterEditor** editor)
|
||||||
{
|
{
|
||||||
BPartition* parent = Parent();
|
BPartition* parent = Parent();
|
||||||
if (!parent || !fDelegate)
|
if (!parent || !fDelegate)
|
||||||
@@ -1021,7 +1017,7 @@ BPartition::GetParameterEditor(BDiskDeviceParameterEditor **editor)
|
|||||||
|
|
||||||
// SetParameters
|
// SetParameters
|
||||||
status_t
|
status_t
|
||||||
BPartition::SetParameters(const char *parameters)
|
BPartition::SetParameters(const char* parameters)
|
||||||
{
|
{
|
||||||
BPartition* parent = Parent();
|
BPartition* parent = Parent();
|
||||||
if (!parent || !fDelegate)
|
if (!parent || !fDelegate)
|
||||||
@@ -1033,7 +1029,7 @@ BPartition::SetParameters(const char *parameters)
|
|||||||
|
|
||||||
// CanEditContentParameters
|
// CanEditContentParameters
|
||||||
bool
|
bool
|
||||||
BPartition::CanEditContentParameters(bool *whileMounted) const
|
BPartition::CanEditContentParameters(bool* whileMounted) const
|
||||||
{
|
{
|
||||||
return _SupportsOperation(B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_PARAMETERS,
|
return _SupportsOperation(B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_PARAMETERS,
|
||||||
B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_PARAMETERS_WHILE_MOUNTED,
|
B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_PARAMETERS_WHILE_MOUNTED,
|
||||||
@@ -1043,7 +1039,7 @@ BPartition::CanEditContentParameters(bool *whileMounted) const
|
|||||||
|
|
||||||
// GetContentParameterEditor
|
// GetContentParameterEditor
|
||||||
status_t
|
status_t
|
||||||
BPartition::GetContentParameterEditor(BDiskDeviceParameterEditor **editor)
|
BPartition::GetContentParameterEditor(BDiskDeviceParameterEditor** editor)
|
||||||
{
|
{
|
||||||
if (!fDelegate)
|
if (!fDelegate)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -1054,7 +1050,7 @@ BPartition::GetContentParameterEditor(BDiskDeviceParameterEditor **editor)
|
|||||||
|
|
||||||
// SetContentParameters
|
// SetContentParameters
|
||||||
status_t
|
status_t
|
||||||
BPartition::SetContentParameters(const char *parameters)
|
BPartition::SetContentParameters(const char* parameters)
|
||||||
{
|
{
|
||||||
if (!fDelegate)
|
if (!fDelegate)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -1065,7 +1061,7 @@ BPartition::SetContentParameters(const char *parameters)
|
|||||||
|
|
||||||
// CanInitialize
|
// CanInitialize
|
||||||
bool
|
bool
|
||||||
BPartition::CanInitialize(const char *diskSystem) const
|
BPartition::CanInitialize(const char* diskSystem) const
|
||||||
{
|
{
|
||||||
return fDelegate && fDelegate->CanInitialize(diskSystem);
|
return fDelegate && fDelegate->CanInitialize(diskSystem);
|
||||||
}
|
}
|
||||||
@@ -1086,7 +1082,7 @@ BPartition::GetInitializationParameterEditor(const char* diskSystem,
|
|||||||
// ValidateInitialize
|
// ValidateInitialize
|
||||||
status_t
|
status_t
|
||||||
BPartition::ValidateInitialize(const char* diskSystem, BString* name,
|
BPartition::ValidateInitialize(const char* diskSystem, BString* name,
|
||||||
const char* parameters)
|
const char* parameters)
|
||||||
{
|
{
|
||||||
if (!fDelegate)
|
if (!fDelegate)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -1097,8 +1093,8 @@ BPartition::ValidateInitialize(const char* diskSystem, BString* name,
|
|||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
status_t
|
status_t
|
||||||
BPartition::Initialize(const char *diskSystem, const char *name,
|
BPartition::Initialize(const char* diskSystem, const char* name,
|
||||||
const char *parameters)
|
const char* parameters)
|
||||||
{
|
{
|
||||||
if (!fDelegate)
|
if (!fDelegate)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -1150,8 +1146,8 @@ BPartition::ValidateCreateChild(off_t* offset, off_t* size, const char* type,
|
|||||||
|
|
||||||
// CreateChild
|
// CreateChild
|
||||||
status_t
|
status_t
|
||||||
BPartition::CreateChild(off_t offset, off_t size, const char *type,
|
BPartition::CreateChild(off_t offset, off_t size, const char* type,
|
||||||
const char* name, const char *parameters, BPartition **child)
|
const char* name, const char* parameters, BPartition** child)
|
||||||
{
|
{
|
||||||
if (!fDelegate)
|
if (!fDelegate)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -1205,8 +1201,8 @@ BPartition::operator=(const BPartition &)
|
|||||||
|
|
||||||
// _SetTo
|
// _SetTo
|
||||||
status_t
|
status_t
|
||||||
BPartition::_SetTo(BDiskDevice *device, BPartition *parent,
|
BPartition::_SetTo(BDiskDevice* device, BPartition* parent,
|
||||||
user_partition_data *data)
|
user_partition_data* data)
|
||||||
{
|
{
|
||||||
_Unset();
|
_Unset();
|
||||||
if (!device || !data)
|
if (!device || !data)
|
||||||
@@ -1215,10 +1211,11 @@ 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++) {
|
||||||
BPartition *child = new(nothrow) BPartition;
|
BPartition* child = new(nothrow) BPartition;
|
||||||
if (child) {
|
if (child) {
|
||||||
error = child->_SetTo(fDevice, this, fPartitionData->children[i]);
|
error = child->_SetTo(fDevice, this, fPartitionData->children[i]);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
@@ -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();
|
||||||
@@ -1240,11 +1238,12 @@ BPartition::_Unset()
|
|||||||
// delete children
|
// delete children
|
||||||
if (fPartitionData) {
|
if (fPartitionData) {
|
||||||
for (int32 i = 0; i < fPartitionData->child_count; i++) {
|
for (int32 i = 0; i < fPartitionData->child_count; i++) {
|
||||||
if (BPartition *child = ChildAt(i))
|
if (BPartition* child = ChildAt(i))
|
||||||
delete child;
|
delete child;
|
||||||
}
|
}
|
||||||
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()
|
||||||
@@ -1263,7 +1261,7 @@ BPartition::_RemoveObsoleteDescendants(user_partition_data *data,
|
|||||||
// BPartition to remove, which makes the list operation definitely O(n).
|
// BPartition to remove, which makes the list operation definitely O(n).
|
||||||
int32 count = CountChildren();
|
int32 count = CountChildren();
|
||||||
for (int32 i = count - 1; i >= 0; i--) {
|
for (int32 i = count - 1; i >= 0; i--) {
|
||||||
BPartition *child = ChildAt(i);
|
BPartition* child = ChildAt(i);
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (int32 k = data->child_count - 1; k >= 0; k--) {
|
for (int32 k = data->child_count - 1; k >= 0; k--) {
|
||||||
if (data->children[k]->id == child->ID()) {
|
if (data->children[k]->id == child->ID()) {
|
||||||
@@ -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;
|
||||||
@@ -1291,9 +1291,9 @@ BPartition::_RemoveObsoleteDescendants(user_partition_data *data,
|
|||||||
|
|
||||||
// _Update
|
// _Update
|
||||||
status_t
|
status_t
|
||||||
BPartition::_Update(user_partition_data *data, bool *updated)
|
BPartition::_Update(user_partition_data* data, bool* updated)
|
||||||
{
|
{
|
||||||
user_partition_data *oldData = fPartitionData;
|
user_partition_data* oldData = fPartitionData;
|
||||||
fPartitionData = data;
|
fPartitionData = data;
|
||||||
// check for changes
|
// check for changes
|
||||||
if (data->offset != oldData->offset
|
if (data->offset != oldData->offset
|
||||||
@@ -1312,11 +1312,12 @@ 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++) {
|
||||||
user_partition_data *childData = data->children[i];
|
user_partition_data* childData = data->children[i];
|
||||||
BPartition *child = (BPartition*)childData->user_data;
|
BPartition* child = (BPartition*)childData->user_data;
|
||||||
if (child) {
|
if (child) {
|
||||||
// old partition
|
// old partition
|
||||||
error = child->_Update(childData, updated);
|
error = child->_Update(childData, updated);
|
||||||
@@ -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];
|
||||||
@@ -1392,7 +1398,7 @@ int32
|
|||||||
BPartition::_CountDescendants() const
|
BPartition::_CountDescendants() const
|
||||||
{
|
{
|
||||||
int32 count = 1;
|
int32 count = 1;
|
||||||
for (int32 i = 0; BPartition *child = ChildAt(i); i++)
|
for (int32 i = 0; BPartition* child = ChildAt(i); i++)
|
||||||
count += child->_CountDescendants();
|
count += child->_CountDescendants();
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
@@ -1403,7 +1409,7 @@ int32
|
|||||||
BPartition::_Level() const
|
BPartition::_Level() const
|
||||||
{
|
{
|
||||||
int32 level = 0;
|
int32 level = 0;
|
||||||
const BPartition *ancestor = this;
|
const BPartition* ancestor = this;
|
||||||
while ((ancestor = ancestor->Parent()))
|
while ((ancestor = ancestor->Parent()))
|
||||||
level++;
|
level++;
|
||||||
return level;
|
return level;
|
||||||
@@ -1412,23 +1418,23 @@ BPartition::_Level() const
|
|||||||
|
|
||||||
// _AcceptVisitor
|
// _AcceptVisitor
|
||||||
bool
|
bool
|
||||||
BPartition::_AcceptVisitor(BDiskDeviceVisitor *visitor, int32 level)
|
BPartition::_AcceptVisitor(BDiskDeviceVisitor* visitor, int32 level)
|
||||||
{
|
{
|
||||||
return visitor->Visit(this, level);
|
return visitor->Visit(this, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// _VisitEachDescendant
|
// _VisitEachDescendant
|
||||||
BPartition *
|
BPartition*
|
||||||
BPartition::_VisitEachDescendant(BDiskDeviceVisitor *visitor, int32 level)
|
BPartition::_VisitEachDescendant(BDiskDeviceVisitor* visitor, int32 level)
|
||||||
{
|
{
|
||||||
if (level < 0)
|
if (level < 0)
|
||||||
level = _Level();
|
level = _Level();
|
||||||
if (_AcceptVisitor(visitor, level))
|
if (_AcceptVisitor(visitor, level))
|
||||||
return this;
|
return this;
|
||||||
for (int32 i = 0; BPartition *child = ChildAt(i); i++) {
|
for (int32 i = 0; BPartition* child = ChildAt(i); i++) {
|
||||||
if (BPartition *result = child->_VisitEachDescendant(visitor,
|
if (BPartition* result = child->_VisitEachDescendant(visitor,
|
||||||
level + 1)) {
|
level + 1)) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user