DiskDevice API v2.0

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3374 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Tyler Dauwalder
2003-05-28 21:43:58 +00:00
parent 800e59617f
commit 40f3824020
5 changed files with 125 additions and 143 deletions
+72 -64
View File
@@ -6,88 +6,96 @@
#ifndef _PARTITION_H
#define _PARTITION_H
#include <disk_scanner.h>
#include <Mime.h>
#include <ObjectList.h>
#include <Rect.h>
#include <String.h>
class BDiskDevice;
class BSession;
class BVolume;
class BPartition {
public:
~BPartition();
BSession *Session() const;
BDiskDevice *Device() const;
off_t Offset() const;
// General Info
off_t Offset() const; // 0 for devices
off_t Size() const;
int32 BlockSize() const;
int32 Index() const;
uint32 Flags() const;
bool IsHidden() const;
bool IsVirtual() const;
bool IsEmpty() const;
bool ContainsFileSystem() const;
const char *Name() const;
const char *Type() const;
const char *FileSystemShortName() const;
const char *FileSystemLongName() const;
const char *VolumeName() const;
uint32 FileSystemFlags() const;
bool IsMounted() const;
int32 Index() const; // 0 for devices
bool IsMountable();
bool IsPartitionable();
bool IsDevice();
bool IsReadOnly() const;
const char* Name() const;
const char* Type() const; // See DiskDeviceTypes.h
int32 UniqueID() const;
virtual char* Path() const; // Recursively obtained down to the parent device
uint32 Flags() const; // not sure if this is really necessary anymore
status_t GetVolume(BVolume *volume) const;
// Hierarchy Info
status_t GetIcon(BBitmap *icon, icon_size which) const;
status_t Mount(uint32 mountFlags = 0, const char *parameters = NULL);
status_t Unmount();
const BPartition* Parent();
BPartition* PartitionAt(int32 index) const;
BPartition* PartitionWithID(int32 id);
status_t GetInitializationParameters(const char *fileSystem,
BString *volumeName,
BString *parameters,
BRect dialogCenter = BRect(),
bool *cancelled = NULL);
status_t Initialize(const char *fileSystem, const char *volumeName,
const char *parameters);
status_t Initialize(const char *fileSystem = "bfs",
BRect dialogCenter = BRect(),
bool *cancelled = NULL);
int32 CountChildren() const; // Immediate descendents
int32 CountDescendents() const; // All descendents
BPartition* VisitEachChild(BDiskDeviceVisitor *visitor);
bool Traverse(BDiskDeviceVisitor *visitor);
private:
BPartition();
BPartition(const BPartition &);
BPartition &operator=(const BPartition &);
// Functions relevant to manipulating *this* partition
void _Unset();
status_t _Unarchive(BMessage *archive);
off_t MinimumSize();
off_t MaximumSize();
// Both based on information obtained from the system used for the
// partition and the partitioning system used for its parent
void _SetSession(BSession *session);
int32 MoveTo(off_t start, BMessenger progressMessenger);
int32 Resize(off_t size, BMessenger progressMessenger);
status_t GetParameterEditor(BDiskScannerParameterEditor **editor,
BDiskScannerParameterEditor **parentEditor);
// For changing parameters of the partition after it's been initialized,
// i.e. file system block size, volume name, etc. "editor" is an editor
// for the system with which this partition is initialized, "parentEditor"
// is an editor for any settings the parent partitioning system may
// allow to be edited ("*parentEditor" will be set to NULL if not
// applicable).
private:
friend class BDiskDeviceList;
friend class BSession;
status_t GetInitializationParameterEditor(const char *system,
BDiskScannerParameterEditor **editor);
int32 Initialize(const char *system,
const char *parameters,
BMessenger progressMessenger);
// Initialization is used to set up a partition with either
// an empty file system or an empty partitioning system
BSession *fSession;
// Functions relevant to manipluating *child* partitions
status_t GetPartitionCreationParameterEditor(BDiskScannerParameterEditor **editor);
int32 CreateChildPartition(off_t start,
off_t length,
const char *parameters,
BMessenger progressMessenger);
int32 DeleteChildPartition(int32 index,
BMessenger progressMessenger);
protected:
BObjectList<BPartition> fChildren;
int32 fUniqueID;
int32 fChangeCounter;
off_t fOffset;
off_t fSize;
int32 fBlockSize;
int32 fIndex;
// TODO: Also contains the device name, which we can get from Device() anyway.
// We could either remove it from extended_partition_info or list
// the individual fields here.
extended_partition_info fInfo;
dev_t fVolumeID;
};
bool fIsMountable;
bool fIsDevice;
bool fIsReadOnly;
char fName[B_FILE_NAME_LENGTH];
char fType[B_FILE_NAME_LENGTH];
}
#endif // _PARTITION_H