1 pathinfo.h |
1 /* |
|
2 * Copyright (c) 2002-2007 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 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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Interface for quering system paths. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef PATH_INFO_H |
|
21 #define PATH_INFO_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32std.h> |
|
25 #include <badesca.h> |
|
26 |
|
27 // CLASS DECLARATION |
|
28 /** |
|
29 * Class holds information of system paths. Platform Environment API provides |
|
30 * interface for quering system paths. Methods provided by the API should be |
|
31 * used instead of hard coded path names. All paths have the trailing backslash |
|
32 * included. The API consist of the PathInfo class, DriveInfo class and system paths are defined |
|
33 * in PathConfiguration.hrh. The DriveInfo class is defined in DriveInfo.h. |
|
34 * |
|
35 * Usage: |
|
36 * |
|
37 * @code |
|
38 * #include <PathInfo.h> |
|
39 * |
|
40 * // Get the root path of Phone Memory. |
|
41 * TFileName path = PathInfo::PhoneMemoryRootPath(); |
|
42 * |
|
43 * // Get the games path and append the path to the root path of Phone Memory. |
|
44 * path.Append( PathInfo::GamesPath() ); |
|
45 * |
|
46 * // 'path' contains now the games path in Phone Memory. |
|
47 * @endcode |
|
48 * |
|
49 * Error handling: |
|
50 * |
|
51 * The panic mechanism is used to handle programming errors. |
|
52 * GetPath(TInt aPath) method will panic if invalid parameter is given as input. |
|
53 * The panic category is named PATHINFO and panic code is: |
|
54 * |
|
55 * - EInvalidParameter = 0 (Invalid parameter.) |
|
56 * |
|
57 * @lib PlatformEnv.dll |
|
58 * @since 2.0 |
|
59 */ |
|
60 |
|
61 class PathInfo |
|
62 { |
|
63 public: |
|
64 |
|
65 /** |
|
66 * Enumeration System Paths defines values to be used for the aPath parameter |
|
67 * in GetPath and GetFullPath methods. |
|
68 * @since 3.2 |
|
69 */ |
|
70 enum TSystemPaths |
|
71 { |
|
72 /** This value is used only as a return value of PathType() to indicate that |
|
73 * the path is not a system path. It is not a valid system path to be given |
|
74 * as a parameter for GetPath() or GetFullPath() |
|
75 */ |
|
76 ENotSystemPath = -1, |
|
77 /** To get the root path in ROM. |
|
78 */ |
|
79 ERomRootPath = 0, |
|
80 /** To get the root path in Phone Memory.. |
|
81 */ |
|
82 EPhoneMemoryRootPath, |
|
83 /** To get the root path in Memory Card. |
|
84 */ |
|
85 EMemoryCardRootPath, |
|
86 /** To get the games path to be appended to a root path. |
|
87 */ |
|
88 EGamesPath, |
|
89 /** To get the installs path to be appended to a root path. |
|
90 */ |
|
91 EInstallsPath, |
|
92 /** To get the others path to be appended to a root path. |
|
93 */ |
|
94 EOthersPath, |
|
95 /** To get the videos path to be appended to a root path. |
|
96 */ |
|
97 EVideosPath, |
|
98 /** To get the images path to be appended to a root path. |
|
99 */ |
|
100 EImagesPath, |
|
101 /** To get the GSM pictures path to be appended to a root path. |
|
102 */ |
|
103 EGsmPicturesPath, |
|
104 /** To get the MMS pictures path to be appended to a root path. |
|
105 */ |
|
106 EMmsBackgroundImagesPath, |
|
107 /** To get the presence logos path to be appended to a root path. |
|
108 */ |
|
109 EPresenceLogosPath, |
|
110 /** To get the sounds path to be appended to a root path. |
|
111 */ |
|
112 ESoundsPath, |
|
113 /** To get the digital sounds path to be appended to a root path. |
|
114 */ |
|
115 EDigitalSoundsPath, |
|
116 /** To get the simple sounds path to be appended to a root path. |
|
117 */ |
|
118 ESimpleSoundsPath, |
|
119 /** To get the images thumbnail path. |
|
120 * The thumbnail images directory exists under the same directory |
|
121 * where the corresponding image is. |
|
122 * Do not try to append this to a root directory. |
|
123 */ |
|
124 EImagesThumbnailPath, |
|
125 /** To get the full path of the contacts folder in the memory card. |
|
126 * The path also contains the drive letter. Do not try to append |
|
127 * this to any root directory. |
|
128 */ |
|
129 EMemoryCardContactsPath |
|
130 |
|
131 }; |
|
132 |
|
133 /** |
|
134 * This method returns the root path in ROM. |
|
135 * Corresponding TSystemPaths value of the returned path is ERomRootPath. |
|
136 * |
|
137 * @return The root path in ROM. |
|
138 * |
|
139 * @see TSystemPaths |
|
140 */ |
|
141 IMPORT_C static const TDesC& RomRootPath(); |
|
142 /** |
|
143 * This method returns the root path in Phone Memory. |
|
144 * Corresponding TSystemPaths value of the returned path is EPhoneMemoryRootPath. |
|
145 * |
|
146 * @return The root path in Phone Memory. |
|
147 * |
|
148 * @see TSystemPaths |
|
149 */ |
|
150 IMPORT_C static const TDesC& PhoneMemoryRootPath(); |
|
151 /** |
|
152 * This method returns the root path in Memory Card. |
|
153 * Corresponding TSystemPaths value of the returned path is EMemoryCardRootPath. |
|
154 * |
|
155 * @return The root path in Memory Card. |
|
156 * |
|
157 * @see TSystemPaths |
|
158 */ |
|
159 IMPORT_C static const TDesC& MemoryCardRootPath(); |
|
160 |
|
161 |
|
162 /** |
|
163 * This method returns the games path to be appended to a root path. |
|
164 * Corresponding TSystemPaths value of the returned path is EGamesPath. |
|
165 * |
|
166 * @return The games path. |
|
167 * |
|
168 * @see TSystemPaths |
|
169 */ |
|
170 IMPORT_C static const TDesC& GamesPath(); |
|
171 /** |
|
172 * This method returns the installs path to be appended to a root path. |
|
173 * Corresponding TSystemPaths value of the returned path is EInstallsPath. |
|
174 * |
|
175 * @return The installs path. |
|
176 * |
|
177 * @see TSystemPaths |
|
178 */ |
|
179 IMPORT_C static const TDesC& InstallsPath(); |
|
180 /** |
|
181 * This method returns the others path to be appended to a root path. |
|
182 * Corresponding TSystemPaths value of the returned path is EOthersPath. |
|
183 * |
|
184 * @return The installs path. |
|
185 * |
|
186 * @see TSystemPaths |
|
187 */ |
|
188 IMPORT_C static const TDesC& OthersPath(); |
|
189 /** |
|
190 * This method returns the videos path to be appended to a root path. |
|
191 * Corresponding TSystemPaths value of the returned path is EVideosPath. |
|
192 * |
|
193 * @return The videos path. |
|
194 * |
|
195 * @see TSystemPaths |
|
196 */ |
|
197 IMPORT_C static const TDesC& VideosPath(); |
|
198 /** |
|
199 * This method returns the images path to be appended to a root path. |
|
200 * Corresponding TSystemPaths value of the returned path is EImagesPath. |
|
201 * |
|
202 * @return The images path. |
|
203 * |
|
204 * @see TSystemPaths |
|
205 */ |
|
206 IMPORT_C static const TDesC& ImagesPath(); |
|
207 /** |
|
208 * This method returns the pictures path to be appended to a root path. |
|
209 * Corresponding TSystemPaths value of the returned path is EGsmPicturesPath. |
|
210 * |
|
211 * @return The pictures path. |
|
212 * |
|
213 * @deprecated Use GmsPicturesPath() instead. |
|
214 * |
|
215 * @see TSystemPaths |
|
216 */ |
|
217 IMPORT_C static const TDesC& PicturesPath(); |
|
218 /** |
|
219 * This method returns the GMS pictures path to be appended to |
|
220 * a root path. |
|
221 * Corresponding TSystemPaths value of the returned path is EGsmPicturesPath. |
|
222 * |
|
223 * @return The GSM pictures path. |
|
224 * |
|
225 * @see TSystemPaths |
|
226 */ |
|
227 IMPORT_C static const TDesC& GmsPicturesPath(); |
|
228 /** |
|
229 * This method returns the MMS background images path to be appended to |
|
230 * a root path. |
|
231 * Corresponding TSystemPaths value of the returned path is EMmsBackgroundImagesPath. |
|
232 * |
|
233 * @return The MMS background images path. |
|
234 * |
|
235 * @see TSystemPaths |
|
236 */ |
|
237 IMPORT_C static const TDesC& MmsBackgroundImagesPath(); |
|
238 /** |
|
239 * This method returns the presence logos path to be appended to |
|
240 * a root path. |
|
241 * Corresponding TSystemPaths value of the returned path is EPresenceLogosPath. |
|
242 * |
|
243 * @return The presence logos path. |
|
244 * |
|
245 * @see TSystemPaths |
|
246 */ |
|
247 IMPORT_C static const TDesC& PresenceLogosPath(); |
|
248 /** |
|
249 * This method returns the sounds path to be appended to a root path. |
|
250 * Corresponding TSystemPaths value of the returned path is ESoundsPath. |
|
251 * |
|
252 * @return The sounds path. |
|
253 * |
|
254 * @see TSystemPaths |
|
255 */ |
|
256 IMPORT_C static const TDesC& SoundsPath(); |
|
257 /** |
|
258 * This method returns the digital sounds path to be appended to |
|
259 * a root path. |
|
260 * Corresponding TSystemPaths value of the returned path is EDigitalSoundsPath. |
|
261 * |
|
262 * @return The digital sounds path. |
|
263 * |
|
264 * @see TSystemPaths |
|
265 */ |
|
266 IMPORT_C static const TDesC& DigitalSoundsPath(); |
|
267 /** |
|
268 * This method returns the simple sounds path to be appended to |
|
269 * a root path. |
|
270 * Corresponding TSystemPaths value of the returned path is ESimpleSoundsPath. |
|
271 * |
|
272 * @return The simple sound path. |
|
273 * |
|
274 * @see TSystemPaths |
|
275 */ |
|
276 IMPORT_C static const TDesC& SimpleSoundsPath(); |
|
277 |
|
278 // --------------------------------------------------------------------- |
|
279 // Paths that are not necessarily under root directories |
|
280 // --------------------------------------------------------------------- |
|
281 |
|
282 /** |
|
283 * This method returns a thumbnail images path. The thumbnail images |
|
284 * directory exists under the same directory where the corresponding |
|
285 * image is. Do not try to append this to a root directory. |
|
286 * Corresponding TSystemPaths value of the returned path is EImagesThumbnailPath. |
|
287 * |
|
288 * @return The thumbnail images path. |
|
289 * |
|
290 * @see TSystemPaths |
|
291 */ |
|
292 IMPORT_C static const TDesC& ImagesThumbnailPath(); |
|
293 |
|
294 /** |
|
295 * This method returns the full path of the contacts folder in |
|
296 * the memory card. The path also contains the drive letter. |
|
297 * Do not try to append this to any root directory. |
|
298 * Corresponding TSystemPaths value of the returned path is EMemoryCardContactsPath. |
|
299 * |
|
300 * @return The full path of the contacts folder in the memory card. |
|
301 * |
|
302 * @see TSystemPaths |
|
303 */ |
|
304 IMPORT_C static const TDesC& MemoryCardContactsPath(); |
|
305 |
|
306 /** |
|
307 * This method returns the requested system path. |
|
308 * |
|
309 * @since 3.2 |
|
310 * @param aPath Defines the requested system path. |
|
311 * @return The requested system path. |
|
312 * |
|
313 * @panic EInvalidParameter Parameter aPath is invalid. |
|
314 * |
|
315 * One small sample describing the usage of the method. |
|
316 * @code |
|
317 * #include <PathInfo.h> |
|
318 * |
|
319 * // Get the the full path of the contacts folder in the memory card. |
|
320 * TFileName path = PathInfo::GetPath( PathInfo::EMemoryCardContactsPath ); |
|
321 * |
|
322 * // 'path' contains now the full path of the contacts folder in the memory card.. |
|
323 * @endcode |
|
324 * |
|
325 * @see TSystemPaths |
|
326 */ |
|
327 IMPORT_C static const TDesC& GetPath( TInt aPath ); |
|
328 |
|
329 /** |
|
330 * This method gets the root path of the requested drive. |
|
331 * The root path is the path where the system paths are located. |
|
332 * |
|
333 * @since 3.2 |
|
334 * @param aRootPath Stores the path, the maximum path length is KMaxPath. |
|
335 * @param aDrive A drive identifier specified by TDriveNumber. |
|
336 * @return A system wide error code. |
|
337 * |
|
338 * One small sample describing the usage of the method. |
|
339 * @code |
|
340 * #include <PathInfo.h> |
|
341 * #include <DriveInfo.h> |
|
342 * |
|
343 * // Get the root path of the default phone memory. |
|
344 * TInt drive; |
|
345 * User::LeaveIfError( DriveInfo::GetDefaultDrive( |
|
346 * DriveInfo::EDefaultPhoneMemory, drive ) ); |
|
347 * TFileName path; |
|
348 * User::LeaveIfError( PathInfo::GetRootPath( path, drive ) ); |
|
349 * |
|
350 * // 'path' contains now the default folder root path of the default phone memory. |
|
351 * @endcode |
|
352 * |
|
353 * @see TDriveNumber |
|
354 * @see KMaxPath |
|
355 * @see DriveInfo |
|
356 */ |
|
357 IMPORT_C static TInt GetRootPath( TDes& aRootPath, TInt aDrive ); |
|
358 |
|
359 /** |
|
360 * This method gets the full path of the requested system path in the requested drive. |
|
361 * KErrNotFound is returned when the drive has no requested system path or |
|
362 * the requested path cannot be added to the root path. |
|
363 * |
|
364 * @since 3.2 |
|
365 * @param aFullPath Stores the requested path, the maximum path length is KMaxPath. |
|
366 * @param aDrive A drive identifier specified by TDriveNumber. |
|
367 * @param aPath Defines the requested system path. |
|
368 * @return A system wide error codes. |
|
369 * |
|
370 * One small sample describing the usage of the method. |
|
371 * @code |
|
372 * #include <PathInfo.h> |
|
373 * #include <DriveInfo.h> |
|
374 * |
|
375 * // Get the full path of the images folder in the default |
|
376 * // phone memory drive. |
|
377 * TFileName path; |
|
378 * TInt drive; |
|
379 * User::LeaveIfError( DriveInfo::GetDefaultDrive( |
|
380 * DriveInfo::EDefaultPhoneMemory, drive ) ); |
|
381 * User::LeaveIfError( PathInfo::GetFullPath( path, drive, PathInfo::EImages ) ); |
|
382 * |
|
383 * // 'path' contains now the full path of the images folder in the default |
|
384 * // phone memory drive. |
|
385 * @endcode |
|
386 * |
|
387 * @see TDriveNumber |
|
388 * @see KMaxPath |
|
389 * @see TSystemPaths |
|
390 * @see DriveInfo |
|
391 */ |
|
392 IMPORT_C static TInt GetFullPath( TDes& aFullPath, TInt aDrive, TInt aPath ); |
|
393 |
|
394 /** |
|
395 * This method returns the system path type of the given path. |
|
396 * Thumbnail system path can exist in any folder. |
|
397 * Other paths must be exact system paths, not subfolders of a system path |
|
398 * ENotSystemPath is returned, if the path is not a system path. |
|
399 * The given path must have backslash ending. |
|
400 * |
|
401 * @since 3.2 |
|
402 * @param aFullPath A path to be type checked |
|
403 * @return A value specified by TSystemPaths |
|
404 * |
|
405 * One small sample describing the usage of the method. |
|
406 * @code |
|
407 * #include <PathInfo.h> |
|
408 * |
|
409 * // Check the type of the system path. |
|
410 * _LIT( KImagesPath, "E:\\Images\\" ); |
|
411 * TInt type( PathInfo::PathType( KImagesPath ) ); |
|
412 * |
|
413 * // 'type' contains now the EImagesPath value. |
|
414 * @endcode |
|
415 * |
|
416 * @see TSystemPaths |
|
417 */ |
|
418 IMPORT_C static TInt PathType( const TDesC& aFullPath ); |
|
419 |
|
420 /** |
|
421 * This method gets the list of full system paths in the requested drive |
|
422 * and leaves the returned pointer in cleanup stack. |
|
423 * |
|
424 * @since 3.2 |
|
425 * @param aDrive A drive identifier specified by TDriveNumber. |
|
426 * @return A list of the system paths. Ownership is transferred. |
|
427 * |
|
428 * One small sample describing the usage of the method. |
|
429 * @code |
|
430 * #include <PathInfo.h> |
|
431 * #include <DriveInfo.h> |
|
432 * |
|
433 * // Create the default path structure for default mass storage drive |
|
434 * TInt drive; |
|
435 * User::LeaveIfError( DriveInfo::GetDefaultDrive( |
|
436 * DriveInfo::EDefaultMassStorage, drive ) ); |
|
437 * CDesCArray* paths = PathInfo::GetListOfPathsLC( drive ); |
|
438 * TInt count( paths->MdcaCount() ); |
|
439 * for ( TInt i( 0 ); i < count; ++i ) |
|
440 * { |
|
441 * User::LeaveIfError( iFs.MkDirAll( paths->MdcaPoint( i ) ); |
|
442 * } |
|
443 * CleanupStack::PopAndDestroy( paths ); |
|
444 * // The default mass storage drive contains now the default path structure |
|
445 * @endcode |
|
446 * |
|
447 * @see TDriveNumber |
|
448 * @see DriveInfo |
|
449 */ |
|
450 IMPORT_C static CDesCArray* GetListOfPathsLC( TInt aDrive ); |
|
451 |
|
452 /** |
|
453 * This method gets the list of full system paths in the requested drive. |
|
454 * |
|
455 * @since 3.2 |
|
456 * @param aDrive A drive identifier specified by TDriveNumber. |
|
457 * @return A list of the system paths. Ownership is transferred. |
|
458 * |
|
459 * @see TDriveNumber |
|
460 */ |
|
461 IMPORT_C static CDesCArray* GetListOfPathsL( TInt aDrive ); |
|
462 |
|
463 private: |
|
464 |
|
465 /** |
|
466 * C++ default constructor. |
|
467 */ |
|
468 PathInfo(); |
|
469 }; |
|
470 |
|
471 #endif // PATH_INFO_H |
|
472 |
|
473 // End of File |