Added ContentSize(). Added default parameters for CanMove() and CanResize().
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4134 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -26,6 +26,7 @@ public:
|
|||||||
|
|
||||||
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
|
||||||
uint32 BlockSize() const;
|
uint32 BlockSize() const;
|
||||||
int32 Index() const; // 0 for devices
|
int32 Index() const; // 0 for devices
|
||||||
uint32 Status() const;
|
uint32 Status() const;
|
||||||
@@ -76,12 +77,13 @@ public:
|
|||||||
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, bool *whileMounted = NULL) const;
|
bool CanResize(bool *canResizeContents = NULL,
|
||||||
|
bool *whileMounted = NULL) const;
|
||||||
status_t ValidateResize(off_t *size, bool resizeContents = true) const;
|
status_t ValidateResize(off_t *size, bool resizeContents = true) const;
|
||||||
status_t Resize(off_t size, bool resizeContents = true);
|
status_t Resize(off_t size, bool resizeContents = true);
|
||||||
|
|
||||||
bool CanMove(BObjectList<BPartition> *unmovableDescendants,
|
bool CanMove(BObjectList<BPartition> *unmovableDescendants = NULL,
|
||||||
BObjectList<BPartition> *movableOnlyIfUnmounted) const;
|
BObjectList<BPartition> *movableOnlyIfUnmounted = NULL) const;
|
||||||
status_t ValidateMove(off_t *newOffset, bool force = false) const;
|
status_t ValidateMove(off_t *newOffset, bool force = false) const;
|
||||||
status_t Move(off_t newOffset, bool force = false);
|
status_t Move(off_t newOffset, bool force = false);
|
||||||
|
|
||||||
|
|||||||
@@ -92,6 +92,13 @@ BPartition::Size() const
|
|||||||
return (fPartitionData ? fPartitionData->size : 0);
|
return (fPartitionData ? fPartitionData->size : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ContentSize
|
||||||
|
off_t
|
||||||
|
BPartition::ContentSize() const
|
||||||
|
{
|
||||||
|
return (fPartitionData ? fPartitionData->content_size : 0);
|
||||||
|
}
|
||||||
|
|
||||||
// BlockSize
|
// BlockSize
|
||||||
/*! \brief Returns the block size of the device.
|
/*! \brief Returns the block size of the device.
|
||||||
\return The block size of the device in bytes.
|
\return The block size of the device in bytes.
|
||||||
@@ -513,10 +520,8 @@ BPartition::CanMove(BObjectList<BPartition> *unmovableDescendants,
|
|||||||
BObjectList<BPartition> *movableOnlyIfUnmounted) const
|
BObjectList<BPartition> *movableOnlyIfUnmounted) const
|
||||||
{
|
{
|
||||||
// check parameters
|
// check parameters
|
||||||
if (!unmovableDescendants || !movableOnlyIfUnmounted || !fPartitionData
|
if (!fPartitionData || IsDevice() || !Parent() || !_IsShadow())
|
||||||
|| IsDevice() || !Parent() || !_IsShadow()) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
// count descendants and allocate partition_id arrays large enough
|
// count descendants and allocate partition_id arrays large enough
|
||||||
int32 descendantCount = _CountDescendants();
|
int32 descendantCount = _CountDescendants();
|
||||||
partition_id *unmovableIDs = NULL;
|
partition_id *unmovableIDs = NULL;
|
||||||
@@ -542,18 +547,24 @@ BPartition::CanMove(BObjectList<BPartition> *unmovableDescendants,
|
|||||||
_ChangeCounter(), unmovableIDs, needUnmountingIDs,
|
_ChangeCounter(), unmovableIDs, needUnmountingIDs,
|
||||||
descendantCount);
|
descendantCount);
|
||||||
if (result) {
|
if (result) {
|
||||||
// find unmovable BPartition objects for returned IDs
|
// get unmovable BPartition objects for returned IDs
|
||||||
for (int32 i = 0; i < descendantCount && unmovableIDs[i] != -1; i++) {
|
if (unmovableDescendants) {
|
||||||
BPartition *descendant = FindDescendant(unmovableIDs[i]);
|
for (int32 i = 0; i < descendantCount && unmovableIDs[i] != -1;
|
||||||
if (!descendant || !unmovableDescendants->AddItem(descendant))
|
i++) {
|
||||||
return false;
|
BPartition *descendant = FindDescendant(unmovableIDs[i]);
|
||||||
|
if (!descendant || !unmovableDescendants->AddItem(descendant))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// find BPartition objects needing to be unmounted for returned IDs
|
// get BPartition objects needing to be unmounted for returned IDs
|
||||||
for (int32 i = 0; i < descendantCount && needUnmountingIDs[i] != -1;
|
if (movableOnlyIfUnmounted) {
|
||||||
i++) {
|
for (int32 i = 0;
|
||||||
BPartition *descendant = FindDescendant(needUnmountingIDs[i]);
|
i < descendantCount && needUnmountingIDs[i] != -1;
|
||||||
if (!descendant || !movableOnlyIfUnmounted->AddItem(descendant))
|
i++) {
|
||||||
return false;
|
BPartition *descendant = FindDescendant(needUnmountingIDs[i]);
|
||||||
|
if (!descendant || !movableOnlyIfUnmounted->AddItem(descendant))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user