146b93b2cSIngo Weinhold/*
246b93b2cSIngo Weinhold * Copyright 2003-2007, Ingo Weinhold, ingo_weinhold@gmx.de.
346b93b2cSIngo Weinhold * Copyright 2003, Tyler Akidau, haiku@akidau.net.
446b93b2cSIngo Weinhold * Distributed under the terms of the MIT License.
546b93b2cSIngo Weinhold */
6d713d1d9SIngo Weinhold#ifndef _DISK_DEVICE_H
7d713d1d9SIngo Weinhold#define _DISK_DEVICE_H
8d713d1d9SIngo Weinhold
95c7270efSIngo Weinhold#include <Partition.h>
105c7270efSIngo Weinhold
1146b93b2cSIngo Weinhold
125c7270efSIngo Weinholdstruct user_disk_device_data;
135c7270efSIngo Weinhold
1440f38240STyler Dauwalderclass BDiskDevice : public BPartition {
15d713d1d9SIngo Weinholdpublic:
1646b93b2cSIngo Weinhold								BDiskDevice();
1746b93b2cSIngo Weinhold	virtual						~BDiskDevice();
185c7270efSIngo Weinhold
1946b93b2cSIngo Weinhold			bool				HasMedia() const;
2046b93b2cSIngo Weinhold			bool				IsRemovableMedia() const;
2146b93b2cSIngo Weinhold			bool				IsReadOnlyMedia() const;
2246b93b2cSIngo Weinhold			bool				IsWriteOnceMedia() const;
23d713d1d9SIngo Weinhold
2446b93b2cSIngo Weinhold			status_t			Eject(bool update = false);
25d713d1d9SIngo Weinhold
2646b93b2cSIngo Weinhold			status_t			SetTo(partition_id id);
2746b93b2cSIngo Weinhold			status_t			Update(bool* updated = NULL);
2846b93b2cSIngo Weinhold			void				Unset();
2946b93b2cSIngo Weinhold			status_t			InitCheck() const;
305c7270efSIngo Weinhold
3146b93b2cSIngo Weinhold	virtual	status_t			GetPath(BPath* path) const;
325c7270efSIngo Weinhold
3346b93b2cSIngo Weinhold			bool				IsModified() const;
3446b93b2cSIngo Weinhold			status_t			PrepareModifications();
3546b93b2cSIngo Weinhold			status_t			CommitModifications(bool synchronously = true,
3646b93b2cSIngo Weinhold									BMessenger progressMessenger = BMessenger(),
3746b93b2cSIngo Weinhold									bool receiveCompleteProgressUpdates = true);
3846b93b2cSIngo Weinhold			status_t			CancelModifications();
395c7270efSIngo Weinhold
4038bbc957SAxel Dörfler			bool				IsFile() const;
4138bbc957SAxel Dörfler			status_t			GetFilePath(BPath* path) const;
4238bbc957SAxel Dörfler
43d713d1d9SIngo Weinholdprivate:
4446b93b2cSIngo Weinhold			friend class BDiskDeviceList;
4546b93b2cSIngo Weinhold			friend class BDiskDeviceRoster;
46bdc2eaf5SIngo Weinhold
4746b93b2cSIngo Weinhold								BDiskDevice(const BDiskDevice&);
4846b93b2cSIngo Weinhold			BDiskDevice&		operator=(const BDiskDevice&);
49426b44c6SIngo Weinhold
5046b93b2cSIngo Weinhold	static	status_t			_GetData(partition_id id, bool deviceOnly,
511573b626SIngo Weinhold									size_t neededSize,
5246b93b2cSIngo Weinhold									user_disk_device_data** data);
53426b44c6SIngo Weinhold
5446b93b2cSIngo Weinhold			status_t			_SetTo(partition_id id, bool deviceOnly,
551573b626SIngo Weinhold									size_t neededSize);
5646b93b2cSIngo Weinhold			status_t			_SetTo(user_disk_device_data* data);
571573b626SIngo Weinhold			status_t			_Update(bool* updated);
5846b93b2cSIngo Weinhold			status_t			_Update(user_disk_device_data* data,
5946b93b2cSIngo Weinhold									bool* updated);
60671a7455SIngo Weinhold
6146b93b2cSIngo Weinhold	static	void				_ClearUserData(user_partition_data* data);
6204adb291SIngo Weinhold
6346b93b2cSIngo Weinhold	virtual	bool				_AcceptVisitor(BDiskDeviceVisitor* visitor,
6446b93b2cSIngo Weinhold									int32 level);
6540f38240STyler Dauwalder
6646b93b2cSIngo Weinhold			user_disk_device_data* fDeviceData;
675c7270efSIngo Weinhold};
68d713d1d9SIngo Weinhold
69d713d1d9SIngo Weinhold#endif	// _DISK_DEVICE_H
70