2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Interface for quering the drive information of the system.
29 * Class holds the drive information of the system. Platform Environment API provides
30 * interface for quering the drive information of the system. Methods provided by the API should be
31 * used instead of the hard coded drive identifiers.
32 * The API consist of the DriveInfo class, PathInfo class and system paths are defined
33 * in PathConfiguration.hrh. The PathInfo class is defined in PathInfo.h.
38 * #include <DriveInfo.h>
40 * // Get the drive identifier of the default removable mass storage.
42 * User::LeaveIfError( DriveInfo::GetDefaultDrive(
43 * DriveInfo::EDefaultRemovableMassStorage, drive ) );
45 * // 'drive' contains now the drive identifier of the default removable mass storage.
47 * // Get the drive status of the default removable mass storage.
49 * User::LeaveIfError( DriveInfo::GetDriveStatus( fs, drive, status ) );
51 * // 'status' contains now the drive status of the default removable mass storage.
53 * // Get all drives that are visible to the user in TDriveList.
54 * TDriveList driveList;
56 * User::LeaveIfError( DriveInfo::GetUserVisibleDrives( fs, driveList, driveCount ) );
58 * // 'driveList' contains now the user visible drives.
59 * // 'driveCount'contains now the drive count i.e. number of non zero items in driveList.
61 * // Access the drives stored in 'driveList'
62 * TInt driveListLen( driveList.Length() ); // The length of 'driveList'
63 * for( TInt i( 0 ); i < driveListLen; ++i )
65 * if ( driveList[ i ] ) // Non zero items are valid drives
67 * // 'i' contains drive identifier specified by TDriveNumber
72 * // Get all drives that are visible to the user in DriveInfo::TDriveArray.
73 * DriveInfo::TDriveArray driveArray;
74 * User::LeaveIfError( DriveInfo::GetUserVisibleDrives( fs, driveArray ) );
76 * // 'driveArray' contains now the user visible drives.
78 * // Access the drives stored in 'driveArray'
79 * driveCount = driveArray.Count() ); // The number of drives stored in 'driveArray'
80 * for( TInt i( 0 ); i < driveCount; ++i )
82 * TDriveNumber drive( driveArray[ i ] ); // The drive identifier at position 'i'
83 * TChar driveLetter( driveArray.LetterAt( i ) ); // The drive letter at position 'i'
91 * System wide error codes are returned to indicate errors in methods that can fail.
93 * @lib PlatformEnv.dll
97 NONSHARABLE_CLASS(DriveInfo)
101 * Enumeration Default Drives to be used with GetDefaultDrive() method.
106 /** To get the default ROM drive.
110 /** To get the default RAM drive.
114 /** To get the default system drive.
115 * The default system drive is the preferred drive for system specific functionalities.
119 /** To get the default phone memory like FLASH memory, internal memory card, hard drive etc.
123 /** To get the default mass storage like any kind of memory card, hard drive, USB stick etc.
124 * This definition should be always used, unless a removable mass storage is explicitly required.
125 * The default mass storage is the preferred drive for a large amount of user files.
129 /** To get the default removable mass storage like memory card, USB stick etc.
130 * This definition should be used only when explicitly removable mass storage is required.
132 EDefaultRemovableMassStorage
136 * This method gets the default drive of requested type.
137 * If the device does not have the requested default drive, then KErrNotSupported is returned.
138 * This happens for example if device supports only internal drives and
139 * EDefaultRemovableMassStorage is requested.
142 * @param aDefaultDrive A default drive identifier specified by TDefaultDrives
143 * @param aDrive Stores a drive identifier specified by TDriveNumber
144 * @return A system wide error code.
146 * @see TDefaultDrives
149 IMPORT_C static TInt GetDefaultDrive( TInt aDefaultDrive, TInt& aDrive );
152 * This method gets the default drive of requested type.
153 * If the device does not have the requested default drive, then KErrNotSupported is returned.
154 * This happens for example if device supports only internal drives and
155 * EDefaultRemovableMassStorage is requested.
158 * @param aDefaultDrive A default drive identifier specified by TDefaultDrives
159 * @param aDriveLetter Stores a drive letter
160 * @return A system wide error code.
162 * @see TDefaultDrives
164 IMPORT_C static TInt GetDefaultDrive( TInt aDefaultDrive, TChar& aDriveLetter );
167 * Enumeration bit mask Status used by GetDriveStatus() method.
172 /** To indicate that the drive is internal and
173 * cannot be physically removed.
175 EDriveInternal = 0x1,
177 /** To indicate that the drive is physically removable.
179 EDriveRemovable = 0x2,
181 /** To indicate that the drive is remote.
185 /** To indicate that the drive is present.
189 /** To indicate that the drive is locked.
193 /** To indicate that the drive is corrupt.
195 EDriveCorrupt = 0x20,
197 /** To indicate that the drive is in use i.e.
198 * reserved for some exclusive usage.
202 /** To indicate that the drive is readonly.
204 EDriveReadOnly = 0x80,
206 /** To indicate that the drive is substed.
208 EDriveSubsted = 0x100,
210 /** To indicate that the drive is user visible.
211 * The UI is allowed to show the drive to the user.
213 EDriveUserVisible = 0x200,
215 /** To indicate that the drive is externally mountable i.e.
216 * can be mounted from PC or from other devices.
218 EDriveExternallyMountable = 0x400,
220 /** To indicate that the drive is software ejectable.
221 * The user can select software based eject from the UI for this drive.
223 EDriveSwEjectable = 0x800,
225 /** To indicate that the drive is ROM drive.
229 /** To indicate that the drive is RAM drive.
233 /** To indicate that the drive has been formatted.
235 EDriveFormatted = 0x4000,
237 /** To indicate that the drive is formattable.
239 EDriveFormattable = 0x8000,
241 /** To indicate that the drive is lockable i.e. password can be set.
243 EDriveLockable = 0x10000,
245 /** To indicate that the drive is password protected.
247 EDriveHasPassword = 0x20000
252 * This method gets the drive status, a bit mask specified by TStatus.
255 * @param aFs An opened file server session
256 * @param aDrive A drive identifier specified by TDriveNumber
257 * @param aStatus Stores the drive status bit mask specified by TStatus
258 * @return A system wide error code.
264 IMPORT_C static TInt GetDriveStatus( RFs& aFs, TInt aDrive, TUint& aStatus );
267 * This method gets all the drives that are visible to the user.
270 * @param aFs An opened file server session
271 * @param aDriveList Stores the user visible drives in the same format than RFs::DriveList() method.
272 * @param aDriveCount Stores the drive count i.e. number of non zero items in aDriveList.
273 * @return A system wide error code.
278 IMPORT_C static TInt GetUserVisibleDrives(
279 RFs& aFs, TDriveList& aDriveList, TInt& aDriveCount );
282 * This method gets the user visible drives with specified file server drive
285 * Note that file server drive attributes are not equal with TStatus definitions.
288 * @param aFs An opened file server session
289 * @param aDriveList Stores the user visible drives in the same format than RFs::DriveList() method.
290 * @param aDriveCount Stores the drive count i.e. number of non zero items in aDriveList.
291 * @param aFlags The mask flags specified for RFs::DriveList() method.
292 * @return A system wide error code.
297 IMPORT_C static TInt GetUserVisibleDrives(
298 RFs& aFs, TDriveList& aDriveList, TInt& aDriveCount, TUint aFlags );
301 * This method methods checks the given drive list and removes the drives hidden from the user.
302 * It is intended to be used with the drive lists that are not read by using GetUserVisibleDrives() method
303 * e.g. the drive list has been got as a parameter elsewhere.
306 * @param aDriveList A drive list where to remove the drives hidden from the user.
307 * @return A drive count i.e. number of non zero items in the given drive list after removal.
311 IMPORT_C static TInt StripUserHiddenDrives( TDriveList& aDriveList );
314 * This method returns the number of drives in the given drive list.
317 * @param aDriveList A drive list where to count the number of drives.
318 * @return A drive count i.e. number of non zero items in the given drive list.
322 IMPORT_C static TInt DriveCount( const TDriveList& aDriveList );
325 * Class TDriveArray provides easy-to-use access to drive identifiers.
330 public: // Constructors
331 inline TDriveArray();
332 inline TDriveArray( const TDriveList& aDriveList );
336 * This method sets the drive array data from given drive list.
339 * @param aDriveList A drive list where to set the data from.
343 IMPORT_C void Set( const TDriveList& aDriveList );
346 * This method resets the array.
353 * This method gets the number of drives in the array.
356 * @return A number of drives in the array.
358 inline TInt Count() const;
361 * This method gets the drive identifier at given index within the array.
364 * @param aIndex The position of drive within the array.
365 * @return A drive identifier specified by TDriveNumber.
367 * @panic USER 21 if aIndex is negative or is greater than
368 * the number of drives in the array
372 inline TDriveNumber operator[]( TInt aIndex ) const;
375 * This method gets the drive letter at given index within the array.
378 * @param aIndex The position of drive within the array.
379 * @return A drive letter.
381 * @panic USER 21 if aIndex is negative or is greater than
382 * the number of drives in the array
384 IMPORT_C TChar LetterAt( TInt aIndex ) const;
387 TBuf8< KMaxDrives > iArray;
391 * This method gets all the drives that are visible to the user.
394 * @param aFs An opened file server session
395 * @param aDriveArray Stores the user visible drives
396 * @return A system wide error code.
401 IMPORT_C static TInt GetUserVisibleDrives( RFs& aFs, TDriveArray& aDriveArray );
404 * This method gets the user visible drives with specified file server drive
407 * Note that file server drive attributes are not equal with TStatus definitions.
410 * @param aFs An opened file server session
411 * @param aDriveArray Stores the user visible drives
412 * @param aFlags The mask flags specified for RFs::DriveList() method.
413 * @return A system wide error code.
418 IMPORT_C static TInt GetUserVisibleDrives(
419 RFs& aFs, TDriveArray& aDriveArray, TUint aFlags );
424 * C++ default constructor.
429 #include "driveinfo.inl"
431 #endif // DRIVE_INFO_H