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:
parent
8954437d0a
commit
fc45522e03
@ -26,6 +26,7 @@ public:
|
||||
|
||||
off_t Offset() const; // 0 for devices
|
||||
off_t Size() const;
|
||||
off_t ContentSize() const; // 0 if uninitialized
|
||||
uint32 BlockSize() const;
|
||||
int32 Index() const; // 0 for devices
|
||||
uint32 Status() const;
|
||||
@ -76,12 +77,13 @@ public:
|
||||
bool CanRepair(bool checkOnly, bool *whileMounted = NULL) 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 Resize(off_t size, bool resizeContents = true);
|
||||
|
||||
bool CanMove(BObjectList<BPartition> *unmovableDescendants,
|
||||
BObjectList<BPartition> *movableOnlyIfUnmounted) const;
|
||||
bool CanMove(BObjectList<BPartition> *unmovableDescendants = NULL,
|
||||
BObjectList<BPartition> *movableOnlyIfUnmounted = NULL) const;
|
||||
status_t ValidateMove(off_t *newOffset, bool force = false) const;
|
||||
status_t Move(off_t newOffset, bool force = false);
|
||||
|
||||
|
@ -92,6 +92,13 @@ BPartition::Size() const
|
||||
return (fPartitionData ? fPartitionData->size : 0);
|
||||
}
|
||||
|
||||
// ContentSize
|
||||
off_t
|
||||
BPartition::ContentSize() const
|
||||
{
|
||||
return (fPartitionData ? fPartitionData->content_size : 0);
|
||||
}
|
||||
|
||||
// BlockSize
|
||||
/*! \brief Returns the block size of the device.
|
||||
\return The block size of the device in bytes.
|
||||
@ -513,10 +520,8 @@ BPartition::CanMove(BObjectList<BPartition> *unmovableDescendants,
|
||||
BObjectList<BPartition> *movableOnlyIfUnmounted) const
|
||||
{
|
||||
// check parameters
|
||||
if (!unmovableDescendants || !movableOnlyIfUnmounted || !fPartitionData
|
||||
|| IsDevice() || !Parent() || !_IsShadow()) {
|
||||
if (!fPartitionData || IsDevice() || !Parent() || !_IsShadow())
|
||||
return false;
|
||||
}
|
||||
// count descendants and allocate partition_id arrays large enough
|
||||
int32 descendantCount = _CountDescendants();
|
||||
partition_id *unmovableIDs = NULL;
|
||||
@ -542,20 +547,26 @@ BPartition::CanMove(BObjectList<BPartition> *unmovableDescendants,
|
||||
_ChangeCounter(), unmovableIDs, needUnmountingIDs,
|
||||
descendantCount);
|
||||
if (result) {
|
||||
// find unmovable BPartition objects for returned IDs
|
||||
for (int32 i = 0; i < descendantCount && unmovableIDs[i] != -1; i++) {
|
||||
// get unmovable BPartition objects for returned IDs
|
||||
if (unmovableDescendants) {
|
||||
for (int32 i = 0; i < descendantCount && unmovableIDs[i] != -1;
|
||||
i++) {
|
||||
BPartition *descendant = FindDescendant(unmovableIDs[i]);
|
||||
if (!descendant || !unmovableDescendants->AddItem(descendant))
|
||||
return false;
|
||||
}
|
||||
// find BPartition objects needing to be unmounted for returned IDs
|
||||
for (int32 i = 0; i < descendantCount && needUnmountingIDs[i] != -1;
|
||||
}
|
||||
// get BPartition objects needing to be unmounted for returned IDs
|
||||
if (movableOnlyIfUnmounted) {
|
||||
for (int32 i = 0;
|
||||
i < descendantCount && needUnmountingIDs[i] != -1;
|
||||
i++) {
|
||||
BPartition *descendant = FindDescendant(needUnmountingIDs[i]);
|
||||
if (!descendant || !movableOnlyIfUnmounted->AddItem(descendant))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user