epoc32/include/driveinfo.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     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".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:  Interface for quering the drive information of the system.
    15 *
    16 */
    17 
    18 
    19 
    20 #ifndef DRIVE_INFO_H
    21 #define DRIVE_INFO_H
    22 
    23 //  INCLUDES
    24 #include <e32std.h>
    25 #include <f32file.h>
    26 
    27 // CLASS DECLARATION
    28 /**
    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.
    34 *
    35 * Usage:
    36 *
    37 * @code
    38 *  #include <DriveInfo.h>
    39 *
    40 *  // Get the drive identifier of the default removable mass storage.
    41 *  TInt drive;
    42 *  User::LeaveIfError( DriveInfo::GetDefaultDrive(
    43 *      DriveInfo::EDefaultRemovableMassStorage, drive ) );
    44 *
    45 *  // 'drive' contains now the drive identifier of the default removable mass storage.
    46 *
    47 *  // Get the drive status of the default removable mass storage.
    48 *  TUint status;
    49 *  User::LeaveIfError( DriveInfo::GetDriveStatus( fs, drive, status ) );
    50 *
    51 *  // 'status' contains now the drive status of the default removable mass storage.
    52 *
    53 *  // Get all drives that are visible to the user in TDriveList.
    54 *  TDriveList driveList;
    55 *  TInt driveCount;
    56 *  User::LeaveIfError( DriveInfo::GetUserVisibleDrives( fs, driveList, driveCount ) );
    57 *
    58 *  // 'driveList' contains now the user visible drives.
    59 *  // 'driveCount'contains now the drive count i.e. number of non zero items in driveList.
    60 *
    61 *  // Access the drives stored in 'driveList'
    62 *  TInt driveListLen( driveList.Length() ); // The length of 'driveList'
    63 *  for( TInt i( 0 ); i < driveListLen; ++i )
    64 *      {
    65 *      if ( driveList[ i ] ) // Non zero items are valid drives
    66 *          {
    67 *          // 'i' contains drive identifier specified by TDriveNumber
    68 *          // ...
    69 *          }
    70 *      }
    71 *
    72 *  // Get all drives that are visible to the user in DriveInfo::TDriveArray.
    73 *  DriveInfo::TDriveArray driveArray;
    74 *  User::LeaveIfError( DriveInfo::GetUserVisibleDrives( fs, driveArray ) );
    75 *
    76 *  // 'driveArray' contains now the user visible drives.
    77 *
    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 )
    81 *      {
    82 *      TDriveNumber drive( driveArray[ i ] ); // The drive identifier at position 'i'
    83 *      TChar driveLetter( driveArray.LetterAt( i ) ); // The drive letter at position 'i'
    84 *      // ...
    85 *      }
    86 *
    87 * @endcode
    88 *
    89 * Error handling:
    90 *
    91 * System wide error codes are returned to indicate errors in methods that can fail.
    92 *
    93 *  @lib PlatformEnv.dll
    94 *  @since 3.2
    95 */
    96 
    97 NONSHARABLE_CLASS(DriveInfo)
    98     {
    99     public:
   100         /**
   101          * Enumeration Default Drives to be used with GetDefaultDrive() method.
   102          * @since 3.2
   103          */
   104         enum TDefaultDrives
   105             {
   106             /** To get the default ROM drive.
   107             */
   108             EDefaultRom = 0,
   109 
   110             /** To get the default RAM drive.
   111             */
   112             EDefaultRam,
   113 
   114             /** To get the default system drive.
   115             * The default system drive is the preferred drive for system specific functionalities.
   116             */
   117             EDefaultSystem,
   118 
   119             /** To get the default phone memory like FLASH memory, internal memory card, hard drive etc.
   120             */
   121             EDefaultPhoneMemory,
   122 
   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.
   126             */
   127             EDefaultMassStorage,
   128 
   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.
   131             */
   132             EDefaultRemovableMassStorage
   133             };
   134 
   135        /**
   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.
   140         *
   141         * @since 3.2
   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.
   145         *
   146         * @see TDefaultDrives
   147         * @see TDriveNumber
   148         */
   149         IMPORT_C static TInt GetDefaultDrive( TInt aDefaultDrive, TInt& aDrive );
   150 
   151        /**
   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.
   156         *
   157         * @since 3.2
   158         * @param aDefaultDrive A default drive identifier specified by TDefaultDrives
   159         * @param aDriveLetter Stores a drive letter
   160         * @return A system wide error code.
   161         *
   162         * @see TDefaultDrives
   163         */
   164         IMPORT_C static TInt GetDefaultDrive( TInt aDefaultDrive, TChar& aDriveLetter );
   165 
   166         /**
   167          * Enumeration bit mask Status used by GetDriveStatus() method.
   168          * @since 3.2
   169          */
   170         enum TStatus
   171             {
   172             /** To indicate that the drive is internal and 
   173             * cannot be physically removed.
   174             */
   175             EDriveInternal = 0x1,
   176 
   177             /** To indicate that the drive is physically removable.
   178             */
   179             EDriveRemovable = 0x2,
   180 
   181             /** To indicate that the drive is remote.
   182             */
   183             EDriveRemote = 0x4,
   184 
   185             /** To indicate that the drive is present.
   186             */
   187             EDrivePresent = 0x8,
   188 
   189             /** To indicate that the drive is locked.
   190             */
   191             EDriveLocked = 0x10,
   192 
   193             /** To indicate that the drive is corrupt.
   194             */
   195             EDriveCorrupt = 0x20,
   196 
   197             /** To indicate that the drive is in use i.e.
   198             * reserved for some exclusive usage.
   199             */
   200             EDriveInUse = 0x40,
   201 
   202             /** To indicate that the drive is readonly.
   203             */
   204             EDriveReadOnly = 0x80,
   205 
   206             /** To indicate that the drive is substed.
   207             */
   208             EDriveSubsted = 0x100,
   209 
   210             /** To indicate that the drive is user visible.
   211             * The UI is allowed to show the drive to the user.
   212             */
   213             EDriveUserVisible = 0x200,
   214 
   215             /** To indicate that the drive is externally mountable i.e.
   216             * can be mounted from PC or from other devices.
   217             */
   218             EDriveExternallyMountable = 0x400,
   219 
   220             /** To indicate that the drive is software ejectable.
   221             * The user can select software based eject from the UI for this drive.
   222             */
   223             EDriveSwEjectable = 0x800,
   224 
   225             /** To indicate that the drive is ROM drive.
   226             */
   227             EDriveRom = 0x1000,
   228 
   229             /** To indicate that the drive is RAM drive.
   230             */
   231             EDriveRam = 0x2000,
   232 
   233             /** To indicate that the drive has been formatted.
   234             */
   235             EDriveFormatted = 0x4000,
   236 
   237             /** To indicate that the drive is formattable.
   238             */
   239             EDriveFormattable = 0x8000,
   240 
   241             /** To indicate that the drive is lockable i.e. password can be set.
   242             */
   243             EDriveLockable = 0x10000,
   244 
   245             /** To indicate that the drive is password protected.
   246             */
   247             EDriveHasPassword = 0x20000,
   248 
   249             /** To indicate that the drive is USB memory.
   250             */
   251             EDriveUsbMemory = 0x40000
   252 
   253             };
   254 
   255        /**
   256         * This method gets the drive status, a bit mask specified by TStatus.
   257         *
   258         * @since 3.2
   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.
   263         *
   264         * @see RFs
   265         * @see TDriveNumber
   266         * @see TStatus
   267         */
   268         IMPORT_C static TInt GetDriveStatus( RFs& aFs, TInt aDrive, TUint& aStatus );
   269 
   270        /**
   271         * This method gets all the drives that are visible to the user.
   272         *
   273         * @since 3.2
   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.
   278         *
   279         * @see RFs
   280         * @see TDriveList
   281         */
   282         IMPORT_C static TInt GetUserVisibleDrives(
   283             RFs& aFs, TDriveList& aDriveList, TInt& aDriveCount );
   284 
   285        /**
   286         * This method gets the user visible drives with specified file server drive 
   287         * attributes.
   288         *
   289         * Note that file server drive attributes are not equal with TStatus definitions.
   290         *
   291         * @since 3.2
   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.
   297         *
   298         * @see RFs
   299         * @see TDriveList
   300         */
   301         IMPORT_C static TInt GetUserVisibleDrives(
   302             RFs& aFs, TDriveList& aDriveList, TInt& aDriveCount, TUint aFlags );
   303 
   304        /**
   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.
   308         *
   309         * @since 3.2
   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.
   312         *
   313         * @see TDriveList
   314         */
   315         IMPORT_C static TInt StripUserHiddenDrives( TDriveList& aDriveList );
   316 
   317        /**
   318         * This method returns the number of drives in the given drive list.
   319         *
   320         * @since 3.2
   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.
   323         *
   324         * @see TDriveList
   325         */
   326         IMPORT_C static TInt DriveCount( const TDriveList& aDriveList );
   327 
   328         /**
   329          * Class TDriveArray provides easy-to-use access to drive identifiers.
   330          * @since S60 5.0
   331          */
   332         class TDriveArray
   333             {
   334             public: // Constructors
   335                 inline TDriveArray();
   336                 inline TDriveArray( const TDriveList& aDriveList );
   337 
   338             public:
   339                 /**
   340                  * This method sets the drive array data from given drive list.
   341                  *
   342                  * @since 3.2
   343                  * @param aDriveList A drive list where to set the data from.
   344                  *
   345                  * @see TDriveList
   346                  */
   347                 IMPORT_C void Set( const TDriveList& aDriveList );
   348 
   349                 /**
   350                  * This method resets the array.
   351                  *
   352                  * @since 3.2
   353                  */
   354                 inline void Reset();
   355 
   356                 /**
   357                  * This method gets the number of drives in the array.
   358                  *
   359                  * @since 3.2
   360                  * @return A number of drives in the array.
   361                  */
   362                 inline TInt Count() const;
   363 
   364                 /**
   365                  * This method gets the drive identifier at given index within the array.
   366                  *
   367                  * @since 3.2
   368                  * @param aIndex The position of drive within the array.
   369                  * @return A drive identifier specified by TDriveNumber.
   370                  *
   371                  * @panic USER 21 if aIndex is negative or is greater than 
   372                  * the number of drives in the array
   373                  *
   374                  * @see TDriveNumber
   375                  */
   376                 inline TDriveNumber operator[]( TInt aIndex ) const;
   377 
   378                 /**
   379                  * This method gets the drive letter at given index within the array.
   380                  *
   381                  * @since 3.2
   382                  * @param aIndex The position of drive within the array.
   383                  * @return A drive letter.
   384                  *
   385                  * @panic USER 21 if aIndex is negative or is greater than 
   386                  * the number of drives in the array
   387                  */
   388                 IMPORT_C TChar LetterAt( TInt aIndex ) const;
   389 
   390             private:
   391                 TBuf8< KMaxDrives > iArray;
   392             };
   393 
   394        /**
   395         * This method gets all the drives that are visible to the user.
   396         *
   397         * @since 3.2
   398         * @param aFs An opened file server session
   399         * @param aDriveArray Stores the user visible drives
   400         * @return A system wide error code.
   401         *
   402         * @see RFs
   403         * @see TDriveArray
   404         */
   405         IMPORT_C static TInt GetUserVisibleDrives( RFs& aFs, TDriveArray& aDriveArray );
   406 
   407        /**
   408         * This method gets the user visible drives with specified file server drive 
   409         * attributes.
   410         *
   411         * Note that file server drive attributes are not equal with TStatus definitions.
   412         *
   413         * @since 3.2
   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.
   418         *
   419         * @see RFs
   420         * @see TDriveArray
   421         */
   422         IMPORT_C static TInt GetUserVisibleDrives(
   423             RFs& aFs, TDriveArray& aDriveArray, TUint aFlags );
   424 
   425     private:
   426 
   427         /**
   428         * C++ default constructor.
   429         */
   430         DriveInfo();
   431     };
   432 
   433 #include "driveinfo.inl"
   434 
   435 #endif      // DRIVE_INFO_H   
   436 
   437 // End of File