* Got rid of SetContentType(). It is set automatically now, to the
PrettyName() of the responsible disk system. * Added change counter support and changes tracking. * Added UninitializeContents(). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4042 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -84,8 +84,8 @@ public:
|
||||
status_t SetType(const char *type);
|
||||
const char *Type() const;
|
||||
|
||||
status_t SetContentType(const char *type);
|
||||
const char *ContentType() const;
|
||||
// ContentType() == DiskSystem()->NamePretty()
|
||||
|
||||
// access to C style partition data
|
||||
partition_data *PartitionData();
|
||||
@@ -153,6 +153,9 @@ public:
|
||||
void SetContentCookie(void *cookie);
|
||||
void *ContentCookie() const;
|
||||
|
||||
void Changed(uint32 flags);
|
||||
void UninitializeContents(bool logChanges = true);
|
||||
|
||||
virtual void WriteUserData(UserDataWriter &writer,
|
||||
user_partition_data *data);
|
||||
|
||||
@@ -170,6 +173,8 @@ protected:
|
||||
KDiskDevice *fDevice;
|
||||
KPartition *fParent;
|
||||
KDiskSystem *fDiskSystem;
|
||||
uint32 fChangeFlags;
|
||||
int32 fChangeCounter;
|
||||
int32 fReferenceCount;
|
||||
bool fObsolete;
|
||||
static int32 fNextID;
|
||||
|
||||
@@ -32,6 +32,8 @@ KPartition::KPartition(partition_id id)
|
||||
fDevice(NULL),
|
||||
fParent(NULL),
|
||||
fDiskSystem(NULL),
|
||||
fChangeFlags(0),
|
||||
fChangeCounter(0),
|
||||
fReferenceCount(0),
|
||||
fObsolete(false)
|
||||
{
|
||||
@@ -61,7 +63,6 @@ KPartition::~KPartition()
|
||||
free(fPartitionData.name);
|
||||
free(fPartitionData.content_name);
|
||||
free(fPartitionData.type);
|
||||
free(fPartitionData.content_type);
|
||||
free(fPartitionData.parameters);
|
||||
free(fPartitionData.content_parameters);
|
||||
}
|
||||
@@ -386,13 +387,6 @@ KPartition::Type() const
|
||||
return fPartitionData.type;
|
||||
}
|
||||
|
||||
// SetContentType
|
||||
status_t
|
||||
KPartition::SetContentType(const char *type)
|
||||
{
|
||||
return set_string(fPartitionData.content_type, type);
|
||||
}
|
||||
|
||||
// ContentType
|
||||
const char *
|
||||
KPartition::ContentType() const
|
||||
@@ -432,8 +426,7 @@ KPartition::ID() const
|
||||
int32
|
||||
KPartition::ChangeCounter() const
|
||||
{
|
||||
// not implemented
|
||||
return 0;
|
||||
return fChangeCounter;
|
||||
}
|
||||
|
||||
// GetPath
|
||||
@@ -675,6 +668,7 @@ KPartition::SetDiskSystem(KDiskSystem *diskSystem)
|
||||
{
|
||||
// unload former disk system
|
||||
if (fDiskSystem) {
|
||||
fPartitionData.content_type = NULL;
|
||||
fDiskSystem->Unload();
|
||||
fDiskSystem = NULL;
|
||||
}
|
||||
@@ -684,6 +678,7 @@ KPartition::SetDiskSystem(KDiskSystem *diskSystem)
|
||||
fDiskSystem->Load(); // can't fail, since it's already loaded
|
||||
// update concerned partition flags
|
||||
if (fDiskSystem) {
|
||||
fPartitionData.content_type = fDiskSystem->PrettyName();
|
||||
if (fDiskSystem->IsFileSystem())
|
||||
SetFlags(Flags() | B_PARTITION_FILE_SYSTEM);
|
||||
else
|
||||
@@ -733,6 +728,43 @@ KPartition::ContentCookie() const
|
||||
return fPartitionData.content_cookie;
|
||||
}
|
||||
|
||||
// Changed
|
||||
void
|
||||
KPartition::Changed(uint32 flags)
|
||||
{
|
||||
fChangeFlags |= flags;
|
||||
fChangeCounter++;
|
||||
}
|
||||
|
||||
// UninitializeContents
|
||||
void
|
||||
KPartition::UninitializeContents(bool logChanges)
|
||||
{
|
||||
if (DiskSystem()) {
|
||||
uint32 flags = B_PARTITION_CHANGED_CONTENT_TYPE
|
||||
| B_PARTITION_CHANGED_STATUS
|
||||
| B_PARTITION_CHANGED_FLAGS;
|
||||
if (VolumeID() >= 0) {
|
||||
// TODO: More? Unmounting would be a bit drastical for changes
|
||||
// only on a shadow partition.
|
||||
SetVolumeID(-1);
|
||||
flags |= B_PARTITION_CHANGED_VOLUME;
|
||||
}
|
||||
if (ContentName()) {
|
||||
SetContentName(NULL);
|
||||
flags |= B_PARTITION_CHANGED_CONTENT_NAME;
|
||||
}
|
||||
if (ContentParameters()) {
|
||||
SetContentParameters(NULL);
|
||||
flags |= B_PARTITION_CHANGED_CONTENT_PARAMETERS;
|
||||
}
|
||||
DiskSystem()->FreeContentCookie(this);
|
||||
SetDiskSystem(NULL);
|
||||
if (logChanges)
|
||||
Changed(flags);
|
||||
}
|
||||
}
|
||||
|
||||
// WriteUserData
|
||||
void
|
||||
KPartition::WriteUserData(UserDataWriter &writer, user_partition_data *data)
|
||||
|
||||
Reference in New Issue
Block a user