2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.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,
249 /** To indicate that the drive is USB memory.
251 EDriveUsbMemory = 0x40000
256 * This method gets the drive status, a bit mask specified by TStatus.
259 * @param aFs An opened file server session
260 * @param aDrive A drive identifier specified by TDriveNumber
261 * @param aStatus Stores the drive status bit mask specified by TStatus
262 * @return A system wide error code.
268 IMPORT_C static TInt GetDriveStatus( RFs& aFs, TInt aDrive, TUint& aStatus );
271 * This method gets all the drives that are visible to the user.
274 * @param aFs An opened file server session
275 * @param aDriveList Stores the user visible drives in the same format than RFs::DriveList() method.
276 * @param aDriveCount Stores the drive count i.e. number of non zero items in aDriveList.
277 * @return A system wide error code.
282 IMPORT_C static TInt GetUserVisibleDrives(
283 RFs& aFs, TDriveList& aDriveList, TInt& aDriveCount );
286 * This method gets the user visible drives with specified file server drive
289 * Note that file server drive attributes are not equal with TStatus definitions.
292 * @param aFs An opened file server session
293 * @param aDriveList Stores the user visible drives in the same format than RFs::DriveList() method.
294 * @param aDriveCount Stores the drive count i.e. number of non zero items in aDriveList.
295 * @param aFlags The mask flags specified for RFs::DriveList() method.
296 * @return A system wide error code.
301 IMPORT_C static TInt GetUserVisibleDrives(
302 RFs& aFs, TDriveList& aDriveList, TInt& aDriveCount, TUint aFlags );
305 * This method methods checks the given drive list and removes the drives hidden from the user.
306 * It is intended to be used with the drive lists that are not read by using GetUserVisibleDrives() method
307 * e.g. the drive list has been got as a parameter elsewhere.
310 * @param aDriveList A drive list where to remove the drives hidden from the user.
311 * @return A drive count i.e. number of non zero items in the given drive list after removal.
315 IMPORT_C static TInt StripUserHiddenDrives( TDriveList& aDriveList );
318 * This method returns the number of drives in the given drive list.
321 * @param aDriveList A drive list where to count the number of drives.
322 * @return A drive count i.e. number of non zero items in the given drive list.
326 IMPORT_C static TInt DriveCount( const TDriveList& aDriveList );
329 * Class TDriveArray provides easy-to-use access to drive identifiers.
334 public: // Constructors
335 inline TDriveArray();
336 inline TDriveArray( const TDriveList& aDriveList );
340 * This method sets the drive array data from given drive list.
343 * @param aDriveList A drive list where to set the data from.
347 IMPORT_C void Set( const TDriveList& aDriveList );
350 * This method resets the array.
357 * This method gets the number of drives in the array.
360 * @return A number of drives in the array.
362 inline TInt Count() const;
365 * This method gets the drive identifier at given index within the array.
368 * @param aIndex The position of drive within the array.
369 * @return A drive identifier specified by TDriveNumber.
371 * @panic USER 21 if aIndex is negative or is greater than
372 * the number of drives in the array
376 inline TDriveNumber operator[]( TInt aIndex ) const;
379 * This method gets the drive letter at given index within the array.
382 * @param aIndex The position of drive within the array.
383 * @return A drive letter.
385 * @panic USER 21 if aIndex is negative or is greater than
386 * the number of drives in the array
388 IMPORT_C TChar LetterAt( TInt aIndex ) const;
391 TBuf8< KMaxDrives > iArray;
395 * This method gets all the drives that are visible to the user.
398 * @param aFs An opened file server session
399 * @param aDriveArray Stores the user visible drives
400 * @return A system wide error code.
405 IMPORT_C static TInt GetUserVisibleDrives( RFs& aFs, TDriveArray& aDriveArray );
408 * This method gets the user visible drives with specified file server drive
411 * Note that file server drive attributes are not equal with TStatus definitions.
414 * @param aFs An opened file server session
415 * @param aDriveArray Stores the user visible drives
416 * @param aFlags The mask flags specified for RFs::DriveList() method.
417 * @return A system wide error code.
422 IMPORT_C static TInt GetUserVisibleDrives(
423 RFs& aFs, TDriveArray& aDriveArray, TUint aFlags );
428 * C++ default constructor.
433 #include "driveinfo.inl"
435 #endif // DRIVE_INFO_H