epoc32/include/pathinfo.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
     1.1 --- a/epoc32/include/pathinfo.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/pathinfo.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,473 @@
     1.4 -pathinfo.h
     1.5 +/*
     1.6 +* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). 
     1.7 +* All rights reserved.
     1.8 +* This component and the accompanying materials are made available
     1.9 +* 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
    1.10 +* which accompanies this distribution, and is available
    1.11 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.12 +*
    1.13 +* Initial Contributors:
    1.14 +* Nokia Corporation - initial contribution.
    1.15 +*
    1.16 +* Contributors:
    1.17 +*
    1.18 +* Description:  Interface for quering system paths.
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +
    1.24 +#ifndef PATH_INFO_H
    1.25 +#define PATH_INFO_H
    1.26 +
    1.27 +//  INCLUDES
    1.28 +#include <e32std.h>
    1.29 +#include <badesca.h>
    1.30 +
    1.31 +// CLASS DECLARATION
    1.32 +/**
    1.33 +* Class holds information of system paths. Platform Environment API provides
    1.34 +* interface for quering system paths. Methods provided by the API should be
    1.35 +* used instead of hard coded path names. All paths have the trailing backslash
    1.36 +* included. The API consist of the PathInfo class, DriveInfo class and system paths are defined
    1.37 +* in PathConfiguration.hrh. The DriveInfo class is defined in DriveInfo.h.
    1.38 +*
    1.39 +* Usage:
    1.40 +*
    1.41 +* @code
    1.42 +*  #include <PathInfo.h>
    1.43 +*
    1.44 +*  // Get the root path of Phone Memory.
    1.45 +*  TFileName path = PathInfo::PhoneMemoryRootPath();
    1.46 +*
    1.47 +*  // Get the games path and append the path to the root path of Phone Memory.
    1.48 +*  path.Append( PathInfo::GamesPath() );
    1.49 +*
    1.50 +*  // 'path' contains now the games path in Phone Memory.
    1.51 +* @endcode
    1.52 +*
    1.53 +* Error handling:
    1.54 +*
    1.55 +* The panic mechanism is used to handle programming errors. 
    1.56 +* GetPath(TInt aPath) method will panic if invalid parameter is given as input. 
    1.57 +* The panic category is named PATHINFO and panic code is:
    1.58 +*
    1.59 +* - EInvalidParameter = 0 (Invalid parameter.)
    1.60 +*
    1.61 +*  @lib PlatformEnv.dll
    1.62 +*  @since 2.0
    1.63 +*/
    1.64 +
    1.65 +class PathInfo
    1.66 +    {
    1.67 +    public:
    1.68 +
    1.69 +        /**
    1.70 +		* Enumeration System Paths defines values to be used for the aPath parameter
    1.71 +		* in GetPath and GetFullPath methods.
    1.72 +        * @since 3.2
    1.73 +		*/
    1.74 +		enum TSystemPaths
    1.75 +			{
    1.76 +            /** This value is used only as a return value of PathType() to indicate that
    1.77 +            * the path is not a system path. It is not a valid system path to be given
    1.78 +            * as a parameter for GetPath() or GetFullPath()
    1.79 +            */
    1.80 +			ENotSystemPath = -1,
    1.81 +            /** To get the root path in ROM.
    1.82 +            */
    1.83 +			ERomRootPath = 0,
    1.84 +			/** To get the root path in Phone Memory..
    1.85 +            */
    1.86 +            EPhoneMemoryRootPath,
    1.87 +            /** To get the root path in Memory Card.
    1.88 +            */
    1.89 +			EMemoryCardRootPath, 
    1.90 +			/** To get the games path to be appended to a root path.
    1.91 +            */
    1.92 +            EGamesPath,
    1.93 +            /** To get the installs path to be appended to a root path.
    1.94 +            */
    1.95 +            EInstallsPath,
    1.96 +            /** To get the others path to be appended to a root path.
    1.97 +            */
    1.98 +            EOthersPath,
    1.99 +            /** To get the videos path to be appended to a root path.
   1.100 +            */
   1.101 +            EVideosPath,
   1.102 +            /** To get the images path to be appended to a root path.
   1.103 +            */
   1.104 +            EImagesPath,
   1.105 +            /**  To get the GSM pictures path to be appended to a root path.
   1.106 +            */
   1.107 +            EGsmPicturesPath,
   1.108 +            /** To get the MMS pictures path to be appended to a root path.
   1.109 +            */
   1.110 +            EMmsBackgroundImagesPath,
   1.111 +            /** To get the presence logos path to be appended to a root path.
   1.112 +            */
   1.113 +            EPresenceLogosPath,
   1.114 +            /** To get the sounds path to be appended to a root path.
   1.115 +            */
   1.116 +            ESoundsPath,            
   1.117 +            /** To get the digital sounds path to be appended to a root path.
   1.118 +            */  
   1.119 +            EDigitalSoundsPath,
   1.120 +            /** To get the simple sounds path to be appended to a root path.
   1.121 +            */
   1.122 +            ESimpleSoundsPath,
   1.123 +            /** To get the images thumbnail path.
   1.124 +            * The thumbnail images directory exists under the same directory
   1.125 +            * where the corresponding image is. 
   1.126 +            * Do not try to append this to a root directory.
   1.127 +            */
   1.128 +            EImagesThumbnailPath,
   1.129 +            /** To get the full path of the contacts folder in the memory card.
   1.130 +            * The path also contains the drive letter. Do not try to append 
   1.131 +            * this to any root directory.
   1.132 +            */ 
   1.133 +            EMemoryCardContactsPath
   1.134 +
   1.135 +			};
   1.136 +
   1.137 +        /**
   1.138 +        * This method returns the root path in ROM.
   1.139 +        * Corresponding TSystemPaths value of the returned path is ERomRootPath.
   1.140 +        *
   1.141 +        * @return The root path in ROM.
   1.142 +        *
   1.143 +        * @see TSystemPaths
   1.144 +        */
   1.145 +        IMPORT_C static const TDesC& RomRootPath();
   1.146 +        /**
   1.147 +        * This method returns the root path in Phone Memory.
   1.148 +        * Corresponding TSystemPaths value of the returned path is EPhoneMemoryRootPath.
   1.149 +        *
   1.150 +        * @return The root path in Phone Memory.
   1.151 +        *
   1.152 +        * @see TSystemPaths
   1.153 +        */
   1.154 +        IMPORT_C static const TDesC& PhoneMemoryRootPath();
   1.155 +        /**
   1.156 +        * This method returns the root path in Memory Card.
   1.157 +        * Corresponding TSystemPaths value of the returned path is EMemoryCardRootPath.
   1.158 +        *
   1.159 +        * @return The root path in Memory Card.
   1.160 +        *
   1.161 +        * @see TSystemPaths
   1.162 +        */
   1.163 +        IMPORT_C static const TDesC& MemoryCardRootPath();
   1.164 +
   1.165 +
   1.166 +        /**
   1.167 +        * This method returns the games path to be appended to a root path.
   1.168 +        * Corresponding TSystemPaths value of the returned path is EGamesPath.
   1.169 +        *
   1.170 +        * @return The games path.
   1.171 +        *
   1.172 +        * @see TSystemPaths
   1.173 +        */
   1.174 +        IMPORT_C static const TDesC& GamesPath();
   1.175 +        /**
   1.176 +        * This method returns the installs path to be appended to a root path.
   1.177 +        * Corresponding TSystemPaths value of the returned path is EInstallsPath.
   1.178 +        *
   1.179 +        * @return The installs path.
   1.180 +        *
   1.181 +        * @see TSystemPaths
   1.182 +        */
   1.183 +        IMPORT_C static const TDesC& InstallsPath();
   1.184 +        /**
   1.185 +        * This method returns the others path to be appended to a root path.
   1.186 +        * Corresponding TSystemPaths value of the returned path is EOthersPath.
   1.187 +        *
   1.188 +        * @return The installs path.
   1.189 +        *
   1.190 +        * @see TSystemPaths
   1.191 +        */
   1.192 +        IMPORT_C static const TDesC& OthersPath();
   1.193 +        /**
   1.194 +        * This method returns the videos path to be appended to a root path.
   1.195 +        * Corresponding TSystemPaths value of the returned path is EVideosPath.
   1.196 +        *
   1.197 +        * @return The videos path.
   1.198 +        *
   1.199 +        * @see TSystemPaths
   1.200 +        */
   1.201 +        IMPORT_C static const TDesC& VideosPath();
   1.202 +        /**
   1.203 +        * This method returns the images path to be appended to a root path.
   1.204 +        * Corresponding TSystemPaths value of the returned path is EImagesPath.
   1.205 +        *
   1.206 +        * @return The images path.
   1.207 +        *
   1.208 +        * @see TSystemPaths
   1.209 +        */
   1.210 +        IMPORT_C static const TDesC& ImagesPath();  
   1.211 +        /**
   1.212 +        * This method returns the pictures path to be appended to a root path.
   1.213 +        * Corresponding TSystemPaths value of the returned path is EGsmPicturesPath.
   1.214 +        *
   1.215 +        * @return The pictures path.
   1.216 +        *
   1.217 +        * @deprecated Use GmsPicturesPath() instead.
   1.218 +        *
   1.219 +        * @see TSystemPaths
   1.220 +        */
   1.221 +        IMPORT_C static const TDesC& PicturesPath();       
   1.222 +        /**
   1.223 +        * This method returns the GMS pictures path to be appended to 
   1.224 +        * a root path.
   1.225 +        * Corresponding TSystemPaths value of the returned path is EGsmPicturesPath.
   1.226 +        *
   1.227 +        * @return The GSM pictures path.
   1.228 +        *
   1.229 +        * @see TSystemPaths
   1.230 +        */
   1.231 +        IMPORT_C static const TDesC& GmsPicturesPath();
   1.232 +        /**
   1.233 +        * This method returns the MMS background images path to be appended to
   1.234 +        * a root path.
   1.235 +        * Corresponding TSystemPaths value of the returned path is EMmsBackgroundImagesPath.
   1.236 +        *
   1.237 +        * @return The MMS background images path.
   1.238 +        *
   1.239 +        * @see TSystemPaths
   1.240 +        */
   1.241 +        IMPORT_C static const TDesC& MmsBackgroundImagesPath();
   1.242 +        /**
   1.243 +        * This method returns the presence logos path to be appended to 
   1.244 +        * a root path.
   1.245 +        * Corresponding TSystemPaths value of the returned path is EPresenceLogosPath.
   1.246 +        *
   1.247 +        * @return The presence logos path.
   1.248 +        *
   1.249 +        * @see TSystemPaths
   1.250 +        */
   1.251 +        IMPORT_C static const TDesC& PresenceLogosPath();
   1.252 +        /**
   1.253 +        * This method returns the sounds path to be appended to a root path.
   1.254 +        * Corresponding TSystemPaths value of the returned path is ESoundsPath.
   1.255 +        *
   1.256 +        * @return The sounds path.
   1.257 +        *
   1.258 +        * @see TSystemPaths
   1.259 +        */
   1.260 +        IMPORT_C static const TDesC& SoundsPath();
   1.261 +        /**
   1.262 +        * This method returns the digital sounds path to be appended to 
   1.263 +        * a root path.
   1.264 +        * Corresponding TSystemPaths value of the returned path is EDigitalSoundsPath.
   1.265 +        *
   1.266 +        * @return The digital sounds path.
   1.267 +        *
   1.268 +        * @see TSystemPaths
   1.269 +        */
   1.270 +        IMPORT_C static const TDesC& DigitalSoundsPath();
   1.271 +        /**
   1.272 +        * This method returns the simple sounds path to be appended to 
   1.273 +        * a root path.
   1.274 +        * Corresponding TSystemPaths value of the returned path is ESimpleSoundsPath.
   1.275 +        *
   1.276 +        * @return The simple sound path.
   1.277 +        *
   1.278 +        * @see TSystemPaths
   1.279 +        */
   1.280 +        IMPORT_C static const TDesC& SimpleSoundsPath();
   1.281 +
   1.282 +        // ---------------------------------------------------------------------
   1.283 +        // Paths that are not necessarily under root directories
   1.284 +        // ---------------------------------------------------------------------
   1.285 +
   1.286 +        /**
   1.287 +        * This method returns a thumbnail images path. The thumbnail images 
   1.288 +        * directory exists under the same directory where the corresponding 
   1.289 +        * image is. Do not try to append this to a root directory.
   1.290 +        * Corresponding TSystemPaths value of the returned path is EImagesThumbnailPath.
   1.291 +        *
   1.292 +        * @return The thumbnail images path.
   1.293 +        *
   1.294 +        * @see TSystemPaths
   1.295 +        */
   1.296 +        IMPORT_C static const TDesC& ImagesThumbnailPath();
   1.297 +
   1.298 +        /**
   1.299 +        * This method returns the full path of the contacts folder in 
   1.300 +        * the memory card. The path also contains the drive letter. 
   1.301 +        * Do not try to append this to any root directory.
   1.302 +        * Corresponding TSystemPaths value of the returned path is EMemoryCardContactsPath.
   1.303 +        *
   1.304 +        * @return The full path of the contacts folder in the memory card.
   1.305 +        *
   1.306 +        * @see TSystemPaths
   1.307 +        */
   1.308 +        IMPORT_C static const TDesC& MemoryCardContactsPath();
   1.309 +
   1.310 +        /**
   1.311 +        * This method returns the requested system path.
   1.312 +        *
   1.313 +        * @since 3.2
   1.314 +        * @param aPath Defines the requested system path.
   1.315 +        * @return The requested system path.
   1.316 +        *
   1.317 +        * @panic EInvalidParameter Parameter aPath is invalid.
   1.318 +        *
   1.319 +        * One small sample describing the usage of the method.
   1.320 +        * @code
   1.321 +        *  #include <PathInfo.h>
   1.322 +        *
   1.323 +        *  // Get the the full path of the contacts folder in the memory card.
   1.324 +        *  TFileName path = PathInfo::GetPath( PathInfo::EMemoryCardContactsPath );
   1.325 +        *
   1.326 +        *  // 'path' contains now the full path of the contacts folder in the memory card..
   1.327 +        * @endcode
   1.328 +        *
   1.329 +        * @see TSystemPaths
   1.330 +        */
   1.331 +        IMPORT_C static const TDesC& GetPath( TInt aPath );
   1.332 +
   1.333 +        /**
   1.334 +        * This method gets the root path of the requested drive.
   1.335 +        * The root path is the path where the system paths are located.
   1.336 +        *
   1.337 +        * @since 3.2
   1.338 +        * @param aRootPath Stores the path, the maximum path length is KMaxPath.
   1.339 +        * @param aDrive A drive identifier specified by TDriveNumber.
   1.340 +        * @return A system wide error code.
   1.341 +        * 
   1.342 +        * One small sample describing the usage of the method.
   1.343 +        * @code
   1.344 +        *  #include <PathInfo.h>
   1.345 +        *  #include <DriveInfo.h>
   1.346 +        *
   1.347 +        *  // Get the root path of the default phone memory.
   1.348 +        *  TInt drive;
   1.349 +        *  User::LeaveIfError( DriveInfo::GetDefaultDrive(
   1.350 +        *      DriveInfo::EDefaultPhoneMemory, drive ) );
   1.351 +        *  TFileName path;
   1.352 +        *  User::LeaveIfError( PathInfo::GetRootPath( path, drive ) );
   1.353 +        *
   1.354 +        *  // 'path' contains now the default folder root path of the default phone memory.
   1.355 +        * @endcode
   1.356 +        *
   1.357 +        * @see TDriveNumber
   1.358 +        * @see KMaxPath
   1.359 +        * @see DriveInfo
   1.360 +        */
   1.361 +        IMPORT_C static TInt GetRootPath( TDes& aRootPath, TInt aDrive );
   1.362 +
   1.363 +        /**
   1.364 +        * This method gets the full path of the requested system path in the requested drive.
   1.365 +        * KErrNotFound is returned when the drive has no requested system path or 
   1.366 +        * the requested path cannot be added to the root path.
   1.367 +        *
   1.368 +        * @since 3.2
   1.369 +        * @param aFullPath Stores the requested path, the maximum path length is KMaxPath.
   1.370 +        * @param aDrive A drive identifier specified by TDriveNumber.
   1.371 +        * @param aPath Defines the requested system path.
   1.372 +        * @return A system wide error codes.
   1.373 +        *
   1.374 +        * One small sample describing the usage of the method.
   1.375 +        * @code
   1.376 +        *  #include <PathInfo.h>
   1.377 +        *  #include <DriveInfo.h>
   1.378 +        *
   1.379 +        *  // Get the full path of the images folder in the default
   1.380 +        *  // phone memory drive.
   1.381 +        *  TFileName path;
   1.382 +        *  TInt drive;
   1.383 +        *  User::LeaveIfError( DriveInfo::GetDefaultDrive(
   1.384 +        *      DriveInfo::EDefaultPhoneMemory, drive ) );
   1.385 +        *  User::LeaveIfError( PathInfo::GetFullPath( path, drive, PathInfo::EImages ) );
   1.386 +        *
   1.387 +        *  // 'path' contains now the full path of the images folder in the default
   1.388 +        *  // phone memory drive.
   1.389 +        * @endcode
   1.390 +        *
   1.391 +        * @see TDriveNumber
   1.392 +        * @see KMaxPath
   1.393 +        * @see TSystemPaths
   1.394 +        * @see DriveInfo
   1.395 +        */
   1.396 +        IMPORT_C static TInt GetFullPath( TDes& aFullPath, TInt aDrive, TInt aPath );
   1.397 +
   1.398 +        /**
   1.399 +        * This method returns the system path type of the given path.
   1.400 +        * Thumbnail system path can exist in any folder.
   1.401 +        * Other paths must be exact system paths, not subfolders of a system path
   1.402 +        * ENotSystemPath is returned, if the path is not a system path.
   1.403 +        * The given path must have backslash ending.
   1.404 +        *
   1.405 +        * @since 3.2
   1.406 +        * @param aFullPath A path to be type checked
   1.407 +        * @return A value specified by TSystemPaths
   1.408 +        * 
   1.409 +        * One small sample describing the usage of the method.
   1.410 +        * @code
   1.411 +        *  #include <PathInfo.h>
   1.412 +        *
   1.413 +        *  // Check the type of the system path.
   1.414 +        * _LIT( KImagesPath, "E:\\Images\\" );
   1.415 +        *  TInt type( PathInfo::PathType( KImagesPath ) );
   1.416 +        *
   1.417 +        *  // 'type' contains now the EImagesPath value.
   1.418 +        * @endcode
   1.419 +        *
   1.420 +        * @see TSystemPaths
   1.421 +        */
   1.422 +        IMPORT_C static TInt PathType( const TDesC& aFullPath );
   1.423 +
   1.424 +        /**
   1.425 +        * This method gets the list of full system paths in the requested drive 
   1.426 +        * and leaves the returned pointer in cleanup stack.
   1.427 +        *
   1.428 +        * @since 3.2
   1.429 +        * @param aDrive A drive identifier specified by TDriveNumber.
   1.430 +        * @return A list of the system paths. Ownership is transferred.
   1.431 +        *
   1.432 +        * One small sample describing the usage of the method.
   1.433 +        * @code
   1.434 +        *  #include <PathInfo.h>
   1.435 +        *  #include <DriveInfo.h>
   1.436 +        *
   1.437 +        *  // Create the default path structure for default mass storage drive
   1.438 +        *  TInt drive;
   1.439 +        *  User::LeaveIfError( DriveInfo::GetDefaultDrive(
   1.440 +        *      DriveInfo::EDefaultMassStorage, drive ) );
   1.441 +        *  CDesCArray* paths = PathInfo::GetListOfPathsLC( drive );
   1.442 +        *  TInt count( paths->MdcaCount() );
   1.443 +        *  for ( TInt i( 0 ); i < count; ++i )
   1.444 +        *      {
   1.445 +        *      User::LeaveIfError( iFs.MkDirAll( paths->MdcaPoint( i ) );
   1.446 +        *      }
   1.447 +        * CleanupStack::PopAndDestroy( paths );
   1.448 +        * // The default mass storage drive contains now the default path structure
   1.449 +        * @endcode
   1.450 +        *
   1.451 +        * @see TDriveNumber
   1.452 +        * @see DriveInfo
   1.453 +        */
   1.454 +        IMPORT_C static CDesCArray* GetListOfPathsLC( TInt aDrive );
   1.455 +
   1.456 +        /**
   1.457 +        * This method gets the list of full system paths in the requested drive.
   1.458 +        *
   1.459 +        * @since 3.2
   1.460 +        * @param aDrive A drive identifier specified by TDriveNumber.
   1.461 +        * @return A list of the system paths. Ownership is transferred.
   1.462 +        *
   1.463 +        * @see TDriveNumber
   1.464 +        */
   1.465 +        IMPORT_C static CDesCArray* GetListOfPathsL( TInt aDrive );
   1.466 +
   1.467 +    private:
   1.468 +
   1.469 +        /**
   1.470 +        * C++ default constructor.
   1.471 +        */
   1.472 +        PathInfo();
   1.473 +    };
   1.474 +
   1.475 +#endif      // PATH_INFO_H   
   1.476 +            
   1.477 +// End of File