xref: /haiku/headers/private/storage/DiskDevice.h (revision 02354704729d38c3b078c696adc1bbbd33cbcf72)
1 /*
2  * Copyright 2003-2007, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Copyright 2003, Tyler Akidau, haiku@akidau.net.
4  * Distributed under the terms of the MIT License.
5  */
6 #ifndef _DISK_DEVICE_H
7 #define _DISK_DEVICE_H
8 
9 #include <Partition.h>
10 
11 
12 struct user_disk_device_data;
13 
14 class BDiskDevice : public BPartition {
15 public:
16 								BDiskDevice();
17 	virtual						~BDiskDevice();
18 
19 			bool				HasMedia() const;
20 			bool				IsRemovableMedia() const;
21 			bool				IsReadOnlyMedia() const;
22 			bool				IsWriteOnceMedia() const;
23 
24 			status_t			Eject(bool update = false);
25 
26 			status_t			SetTo(partition_id id);
27 			status_t			Update(bool* updated = NULL);
28 			void				Unset();
29 			status_t			InitCheck() const;
30 
31 	virtual	status_t			GetPath(BPath* path) const;
32 
33 			bool				IsModified() const;
34 			status_t			PrepareModifications();
35 			status_t			CommitModifications(bool synchronously = true,
36 									BMessenger progressMessenger = BMessenger(),
37 									bool receiveCompleteProgressUpdates = true);
38 			status_t			CancelModifications();
39 
40 			bool				IsFile() const;
41 			status_t			GetFilePath(BPath* path) const;
42 
43 private:
44 			friend class BDiskDeviceList;
45 			friend class BDiskDeviceRoster;
46 
47 								BDiskDevice(const BDiskDevice&);
48 			BDiskDevice&		operator=(const BDiskDevice&);
49 
50 	static	status_t			_GetData(partition_id id, bool deviceOnly,
51 									size_t neededSize,
52 									user_disk_device_data** data);
53 
54 			status_t			_SetTo(partition_id id, bool deviceOnly,
55 									size_t neededSize);
56 			status_t			_SetTo(user_disk_device_data* data);
57 			status_t			_Update(bool* updated);
58 			status_t			_Update(user_disk_device_data* data,
59 									bool* updated);
60 
61 	static	void				_ClearUserData(user_partition_data* data);
62 
63 	virtual	bool				_AcceptVisitor(BDiskDeviceVisitor* visitor,
64 									int32 level);
65 
66 			user_disk_device_data* fDeviceData;
67 };
68 
69 #endif	// _DISK_DEVICE_H
70