author | Simon Howkins <simonh@symbian.org> |
Tue, 16 Nov 2010 11:00:04 +0000 | |
branch | RCL_3 |
changeset 55 | 58ed58285a84 |
parent 52 | 40fb776cbfb3 |
permissions | -rw-r--r-- |
39 | 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 "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: Util methods for File Manager |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
// INCLUDE FILES |
|
21 |
#include <AknUtils.h> |
|
22 |
#include <StringLoader.h> |
|
23 |
#include <CDirectoryLocalizer.h> |
|
24 |
#include <CommonContentPolicy.h> |
|
25 |
#include <bautils.h> |
|
26 |
#include <caf/caf.h> |
|
27 |
#include <DcfCommon.h> |
|
28 |
#include <filemanagerengine.rsg> |
|
29 |
#ifdef RD_MULTIPLE_DRIVE |
|
30 |
#include <driveinfo.h> |
|
31 |
#endif // RD_MULTIPLE_DRIVE |
|
32 |
#if defined( __KEEP_DRM_CONTENT_ON_PHONE ) && defined ( FILE_MANAGER_USE_DISTRIBUTABLECHECKER ) |
|
33 |
#include <distributablechecker.h> |
|
34 |
#endif // __KEEP_DRM_CONTENT_ON_PHONE && FILE_MANAGER_USE_DISTRIBUTABLECHECKER |
|
35 |
#include "GflmUtils.h" |
|
36 |
#include <drmutility.h> |
|
37 |
#include "CFileManagerUtils.h" |
|
38 |
#include "CFilemanagerMimeIconArray.h" |
|
39 |
#include "Cfilemanagerfolderarray.h" |
|
40 |
#include "CGflmNavigatorModel.h" |
|
41 |
#include "CFileManagerItemProperties.h" |
|
42 |
#include "CFileManagerCommonDefinitions.h" |
|
43 |
#include "CGflmGroupItem.h" |
|
44 |
#include "CGflmFileSystemItem.h" |
|
45 |
#include "CGflmDriveItem.h" |
|
46 |
#include "CFileManagerFeatureManager.h" |
|
47 |
||
48 |
// CONSTANTS |
|
49 |
_LIT( KFlk, "flk:" ); |
|
50 |
_LIT( KLdf, "ldf:" ); |
|
51 |
||
52 |
#ifdef RD_MULTIPLE_DRIVE |
|
53 |
const TInt KDriveNameArrayLen = 2; |
|
54 |
const TInt KDriveLetterIndex = 0; |
|
55 |
const TInt KDriveNameIndex = 1; |
|
56 |
enum TFmgrDriveNameType |
|
57 |
{ |
|
58 |
EFmgrDeviceMemory = 0, |
|
59 |
EFmgrMassStorage, |
|
60 |
EFmgrNamedMemoryCard, |
|
61 |
EFmgrDefaultMemoryCard, |
|
62 |
EFmgrDefaultUsbMemory, |
|
63 |
EFmgrDriveNameTypeCount // Must be the last |
|
64 |
}; |
|
65 |
||
66 |
typedef TInt TFmgrDriveNameLayoutText[ EFmgrDriveNameTypeCount ]; |
|
67 |
const TFmgrDriveNameLayoutText KFmgrDriveNames[] = |
|
68 |
{ |
|
69 |
{ // CFileManagerUtils::EMainLayout |
|
70 |
R_QTN_FMGR_MAIN_DEVICE_MEMORY, // EFmgrDeviceMemory |
|
71 |
R_QTN_FMGR_MAIN_MASS_STORAGE, // EFmgrMassStorage |
|
72 |
R_QTN_FMGR_MAIN_NAMED_MEMORY_CARD, // EFmgrNamedMemoryCard |
|
73 |
R_QTN_FMGR_MAIN_MEMORY_CARD_DEFAULT, // EFmgrDefaultMemoryCard |
|
74 |
R_QTN_FMGR_MAIN_USB_DEFAULT // EFmgrDefaultUsbMemory |
|
75 |
}, |
|
76 |
{ // CFileManagerUtils::ETitleLayout |
|
77 |
R_QTN_FMGR_TITLE_DEVICE_MEMORY, // EFmgrDeviceMemory |
|
78 |
R_QTN_FMGR_TITLE_MASS_STORAGE, // EFmgrMassStorage |
|
79 |
R_QTN_FMGR_TITLE_NAMED_MEMORY_CARD, // EFmgrNamedMemoryCard |
|
80 |
R_QTN_FMGR_TITLE_MEMORY_CARD_DEFAULT, // EFmgrDefaultMemoryCard |
|
81 |
R_QTN_FMGR_TITLE_USB_DEFAULT, // EFmgrDefaultUsbMemory |
|
82 |
} |
|
83 |
}; |
|
84 |
#endif // RD_MULTIPLE_DRIVE |
|
85 |
||
86 |
||
87 |
// ============================ MEMBER FUNCTIONS =============================== |
|
88 |
||
89 |
// ----------------------------------------------------------------------------- |
|
90 |
// CFileManagerUtils::CFileManagerUtils |
|
91 |
// C++ default constructor can NOT contain any code, that |
|
92 |
// might leave. |
|
93 |
// ----------------------------------------------------------------------------- |
|
94 |
// |
|
95 |
CFileManagerUtils::CFileManagerUtils( |
|
96 |
RFs& aFs, |
|
97 |
CGflmNavigatorModel& aNavigator, |
|
98 |
CFileManagerFeatureManager& aFeatureManager ) : |
|
99 |
iFs( aFs ), |
|
100 |
iNavigator( aNavigator ), |
|
101 |
iFeatureManager( aFeatureManager ) |
|
102 |
{ |
|
103 |
} |
|
104 |
||
105 |
// ----------------------------------------------------------------------------- |
|
106 |
// CFileManagerUtils::ConstructL |
|
107 |
// Symbian 2nd phase constructor can leave. |
|
108 |
// ----------------------------------------------------------------------------- |
|
109 |
// |
|
110 |
void CFileManagerUtils::ConstructL() |
|
111 |
{ |
|
112 |
// Check and set value to indicate if the feature is supported |
|
113 |
iDrmFullSupported = iFeatureManager.IsDrmFullSupported(); |
|
114 |
||
115 |
iMimeIconMapper = CFileManagerMimeIconArray::NewL( |
|
116 |
R_FILEMANAGER_MIME_ICON_MAPPER, iNavigator ); |
|
117 |
||
118 |
#ifdef RD_MULTIPLE_DRIVE |
|
119 |
iDefaultFolders = CFileManagerFolderArray::NewL( *this ); |
|
120 |
#else // RD_MULTIPLE_DRIVE |
|
121 |
iDefaultFolders = CFileManagerFolderArray::NewL( |
|
122 |
R_FILEMANAGER_DEFAULT_FOLDERS, *this ); |
|
123 |
iDefaultFolders->CreateFolders(); |
|
124 |
#endif // RD_MULTIPLE_DRIVE |
|
125 |
||
126 |
} |
|
127 |
||
128 |
// ----------------------------------------------------------------------------- |
|
129 |
// CFileManagerUtils::NewL |
|
130 |
// Two-phased constructor. |
|
131 |
// ----------------------------------------------------------------------------- |
|
132 |
// |
|
133 |
CFileManagerUtils* CFileManagerUtils::NewL( |
|
134 |
RFs& aFs, |
|
135 |
CGflmNavigatorModel& aNavigator, |
|
136 |
CFileManagerFeatureManager& aFeatureManager ) |
|
137 |
{ |
|
138 |
CFileManagerUtils* self = |
|
139 |
new( ELeave ) CFileManagerUtils( aFs, aNavigator, aFeatureManager ); |
|
140 |
||
141 |
CleanupStack::PushL( self ); |
|
142 |
self->ConstructL(); |
|
143 |
CleanupStack::Pop( self ); |
|
144 |
||
145 |
return self; |
|
146 |
} |
|
147 |
||
148 |
// ----------------------------------------------------------------------------- |
|
149 |
// CFileManagerUtils::~CFileManagerUtils |
|
150 |
// |
|
151 |
// ----------------------------------------------------------------------------- |
|
152 |
// |
|
153 |
CFileManagerUtils::~CFileManagerUtils() |
|
154 |
{ |
|
155 |
#if defined( __KEEP_DRM_CONTENT_ON_PHONE ) && defined ( FILE_MANAGER_USE_DISTRIBUTABLECHECKER ) |
|
156 |
delete iDistributableChecker; |
|
157 |
#endif // __KEEP_DRM_CONTENT_ON_PHONE && FILE_MANAGER_USE_DISTRIBUTABLECHECKER |
|
158 |
delete iMimeIconMapper; |
|
159 |
delete iDefaultFolders; |
|
160 |
delete iCommonContentPolicy; |
|
161 |
} |
|
162 |
||
163 |
// ----------------------------------------------------------------------------- |
|
164 |
// CFileManagerUtils::Fs() const |
|
165 |
// |
|
166 |
// ----------------------------------------------------------------------------- |
|
167 |
// |
|
168 |
RFs& CFileManagerUtils::Fs() const |
|
169 |
{ |
|
170 |
return iFs; |
|
171 |
} |
|
172 |
||
173 |
// ----------------------------------------------------------------------------- |
|
174 |
// CFileManagerUtils::IsForwardLockedFile |
|
175 |
// ----------------------------------------------------------------------------- |
|
176 |
// |
|
177 |
TBool CFileManagerUtils::IsForwardLockedFile( const TDesC& aFullPath ) |
|
178 |
{ |
|
179 |
if ( iDrmFullSupported ) |
|
180 |
{ |
|
181 |
return EFalse; // Full DRM is used |
|
182 |
} |
|
183 |
TBool ret( EFalse ); |
|
184 |
||
185 |
if ( !iCommonContentPolicy ) |
|
186 |
{ |
|
187 |
TRAPD( err, iCommonContentPolicy = CCommonContentPolicy::NewL() ); |
|
188 |
if ( err != KErrNone ) |
|
189 |
{ |
|
190 |
_LIT( KReason, "No Common Content Policy" ); |
|
191 |
User::Panic( KReason, err ); |
|
192 |
} |
|
193 |
} |
|
194 |
||
195 |
if( iCommonContentPolicy ) |
|
196 |
{ |
|
197 |
TRAPD( err, ret = iCommonContentPolicy->IsClosedFileL( aFullPath ) ); |
|
198 |
if ( err != KErrNone ) |
|
199 |
{ |
|
200 |
ret = EFalse; |
|
201 |
} |
|
202 |
} |
|
203 |
||
204 |
return ret; |
|
205 |
} |
|
206 |
||
207 |
// ----------------------------------------------------------------------------- |
|
208 |
// CFileManagerUtils::IsDrmProtectedFile |
|
209 |
// ----------------------------------------------------------------------------- |
|
210 |
// |
|
211 |
TBool CFileManagerUtils::IsDrmProtectedFileL( const TDesC& aFullPath ) const |
|
212 |
{ |
|
213 |
if ( !iDrmFullSupported ) |
|
214 |
{ |
|
215 |
return EFalse; // Partial DRM is used |
|
216 |
} |
|
217 |
#if 0 |
|
218 |
// Check from file extension, this is the fastest possible check |
|
219 |
_LIT( KOdfExt, ".odf" ); |
|
220 |
_LIT( KDcfExt, ".dcf" ); |
|
221 |
TParsePtrC parse( aFullPath ); |
|
222 |
TPtrC ext( parse.Ext() ); |
|
223 |
return ( !ext.CompareF( KOdfExt ) || !ext.CompareF( KDcfExt ) ); |
|
224 |
#else |
|
225 |
// Do similar quick check than in old DRMCommon |
|
226 |
||
227 |
RFile64 drmFile; |
|
228 |
||
229 |
TInt err = drmFile.Open( |
|
230 |
iFs, aFullPath, EFileRead | EFileShareReadersOrWriters ); |
|
231 |
if( err != KErrNone ) |
|
232 |
{ |
|
233 |
// Just assume it is not protected when we fail to open it. |
|
234 |
drmFile.Close(); |
|
235 |
return EFalse; |
|
236 |
} |
|
237 |
CleanupClosePushL( drmFile ); |
|
238 |
DRM::CDrmUtility *drmCheck = DRM::CDrmUtility::NewLC(); |
|
239 |
||
240 |
TBool isProtected( EFalse ); |
|
241 |
TRAP_IGNORE( isProtected = drmCheck->IsProtectedL( drmFile ) ); |
|
242 |
||
243 |
CleanupStack::PopAndDestroy( drmCheck ); |
|
244 |
CleanupStack::PopAndDestroy( &drmFile ); |
|
245 |
||
246 |
return isProtected; |
|
247 |
#endif |
|
248 |
} |
|
249 |
||
250 |
// ----------------------------------------------------------------------------- |
|
251 |
// CFileManagerUtils::ResolveIconL |
|
252 |
// |
|
253 |
// ----------------------------------------------------------------------------- |
|
254 |
// |
|
255 |
TInt CFileManagerUtils::ResolveIconL( const TDesC& aFullPath ) const |
|
256 |
{ |
|
257 |
TInt iconId( EFileManagerOtherFileIcon ); |
|
258 |
if ( HasFinalBackslash( aFullPath ) ) |
|
259 |
{ |
|
260 |
// Do not check for subfolders for remote drives |
|
261 |
iconId = EFileManagerFolderIcon; |
|
262 |
if ( !IsRemoteDrive( aFullPath ) ) |
|
263 |
{ |
|
264 |
if ( HasSubFolders( aFullPath ) ) |
|
265 |
{ |
|
266 |
iconId = EFileManagerFolderSubIcon; |
|
267 |
} |
|
268 |
else if ( !HasFiles( aFullPath ) ) |
|
269 |
{ |
|
270 |
iconId = EFileManagerFolderEmptyIcon; |
|
271 |
} |
|
272 |
} |
|
273 |
} |
|
274 |
else |
|
275 |
{ |
|
276 |
iconId = iMimeIconMapper->ResolveIconL( aFullPath ); |
|
277 |
} |
|
278 |
return iconId; |
|
279 |
} |
|
280 |
||
281 |
// ----------------------------------------------------------------------------- |
|
282 |
// CFileManagerUtils::DefaultFolder |
|
283 |
// |
|
284 |
// ----------------------------------------------------------------------------- |
|
285 |
// |
|
286 |
TBool CFileManagerUtils::DefaultFolder( const TDesC& aFullPath ) const |
|
287 |
{ |
|
288 |
return iDefaultFolders->Contains( aFullPath ); |
|
289 |
} |
|
290 |
||
291 |
// ----------------------------------------------------------------------------- |
|
292 |
// CFileManagerUtils::IsDrmLocalDataFile |
|
293 |
// |
|
294 |
// ----------------------------------------------------------------------------- |
|
295 |
// |
|
296 |
TBool CFileManagerUtils::IsDrmLocalDataFile( const TDesC& aFullPath ) const |
|
297 |
{ |
|
298 |
if ( !iDrmFullSupported ) |
|
299 |
{ |
|
300 |
return EFalse; // Partial DRM is used |
|
301 |
} |
|
302 |
||
303 |
TBool isFlk( EFalse ); |
|
304 |
TBool isLdf( EFalse ); |
|
305 |
TRAP_IGNORE( IsFlkOrLdfFileL( aFullPath, isFlk, isLdf ) ); |
|
306 |
return isLdf; |
|
307 |
} |
|
308 |
||
309 |
// ----------------------------------------------------------------------------- |
|
310 |
// CFileManagerUtils::CanDelete |
|
311 |
// |
|
312 |
// ----------------------------------------------------------------------------- |
|
313 |
// |
|
314 |
TBool CFileManagerUtils::CanDelete( const TDesC& aFileName ) const |
|
315 |
{ |
|
316 |
TEntry entry; |
|
317 |
TBool ret( EFalse ); |
|
318 |
TBool fileOpen( EFalse ); |
|
319 |
if ( KErrNone == iFs.Entry( aFileName, entry ) && |
|
320 |
KErrNone == iFs.IsFileOpen( aFileName, fileOpen ) ) |
|
321 |
{ |
|
322 |
if ( !entry.IsReadOnly() && !entry.IsSystem() && !fileOpen ) |
|
323 |
{ |
|
324 |
ret = ETrue; |
|
325 |
} |
|
326 |
} |
|
327 |
return ret; |
|
328 |
} |
|
329 |
||
330 |
// ----------------------------------------------------------------------------- |
|
331 |
// CFileManagerUtils::FileTypeL |
|
332 |
// |
|
333 |
// ----------------------------------------------------------------------------- |
|
334 |
// |
|
335 |
TUint32 CFileManagerUtils::FileTypeL( const TDesC& aFullPath ) |
|
336 |
{ |
|
337 |
TUint32 fileType( CFileManagerItemProperties::ENotDefined ); |
|
338 |
||
339 |
_LIT( KRootFolder, "?:\\" ); |
|
340 |
if ( !aFullPath.MatchF( KRootFolder ) ) |
|
341 |
{ |
|
342 |
// RFs::Entry cannot be used for root folders |
|
343 |
fileType |= CFileManagerItemProperties::EFolder; |
|
344 |
} |
|
345 |
else if ( !IsRemoteDrive( aFullPath ) ) |
|
346 |
{ |
|
347 |
// Full check for local and removable drives |
|
348 |
TEntry entry; |
|
349 |
User::LeaveIfError( iFs.Entry( aFullPath, entry ) ); |
|
350 |
||
351 |
if ( HasFinalBackslash( aFullPath ) || entry.IsDir() ) |
|
352 |
{ |
|
353 |
fileType |= CFileManagerItemProperties::EFolder; |
|
354 |
||
355 |
if ( DefaultFolder( aFullPath ) ) |
|
356 |
{ |
|
357 |
fileType |= CFileManagerItemProperties::EDefault; |
|
358 |
} |
|
359 |
} |
|
360 |
else |
|
361 |
{ |
|
362 |
fileType |= CFileManagerItemProperties::EFile; |
|
363 |
||
364 |
if ( IsDrmProtectedFileL( aFullPath) ) |
|
365 |
{ |
|
366 |
fileType |= CFileManagerItemProperties::EDrmProtected; |
|
367 |
if ( IsDrmLocalDataFile( aFullPath ) ) |
|
368 |
{ |
|
369 |
fileType |= CFileManagerItemProperties::EDrmLocalDataFile; |
|
370 |
} |
|
371 |
} |
|
372 |
if ( IsForwardLockedFile( aFullPath ) ) |
|
373 |
{ |
|
374 |
fileType |= CFileManagerItemProperties::EForwardLocked; |
|
375 |
} |
|
376 |
// MimeIcon mapper knowledge is used to determine file type |
|
377 |
TInt id( iMimeIconMapper->ResolveIconL( aFullPath ) ); |
|
378 |
if ( id == EFileManagerLinkFileIcon ) |
|
379 |
{ |
|
380 |
fileType |= CFileManagerItemProperties::ELink; |
|
381 |
} |
|
382 |
if ( id == EFileManagerPlaylistFileIcon ) |
|
383 |
{ |
|
384 |
fileType |= CFileManagerItemProperties::EPlaylist; |
|
385 |
} |
|
386 |
||
387 |
TBool fileOpen( EFalse ); |
|
388 |
if ( iFs.IsFileOpen( aFullPath, fileOpen ) == KErrNone ) |
|
389 |
{ |
|
390 |
if ( fileOpen ) |
|
391 |
{ |
|
392 |
fileType |= CFileManagerItemProperties::EOpen; |
|
393 |
} |
|
394 |
} |
|
395 |
if ( fileOpen || entry.IsReadOnly() || entry.IsSystem() ) |
|
396 |
{ |
|
397 |
fileType |= CFileManagerItemProperties::EReadOnly; |
|
398 |
} |
|
399 |
} |
|
400 |
} |
|
401 |
else |
|
402 |
{ |
|
403 |
// Simple check for remote drives |
|
404 |
if ( HasFinalBackslash( aFullPath ) ) |
|
405 |
{ |
|
406 |
fileType |= CFileManagerItemProperties::EFolder; |
|
407 |
} |
|
408 |
else |
|
409 |
{ |
|
410 |
fileType |= CFileManagerItemProperties::EFile; |
|
411 |
} |
|
412 |
} |
|
413 |
||
414 |
return fileType; |
|
415 |
} |
|
416 |
||
417 |
// ----------------------------------------------------------------------------- |
|
418 |
// CFileManagerUtils::ResolveIconL |
|
419 |
// |
|
420 |
// ----------------------------------------------------------------------------- |
|
421 |
// |
|
422 |
TInt CFileManagerUtils::ResolveIconL( CGflmGroupItem& aItem ) const |
|
423 |
{ |
|
424 |
TInt iconId( EFileManagerOtherFileIcon ); |
|
425 |
if ( aItem.GetIconId( iconId ) == KErrNone ) |
|
426 |
{ |
|
427 |
// Use already mapped icon |
|
428 |
return iconId; |
|
429 |
} |
|
430 |
||
431 |
// Map icon |
|
432 |
switch ( aItem.Type() ) |
|
433 |
{ |
|
434 |
case CGflmGroupItem::EFile: |
|
435 |
{ |
|
436 |
CGflmFileSystemItem& fsItem = |
|
437 |
static_cast< CGflmFileSystemItem& >( aItem ); |
|
438 |
HBufC* fullPath = fsItem.FullPathLC(); |
|
439 |
iconId = iMimeIconMapper->ResolveIconL( *fullPath ); |
|
440 |
fsItem.SetIconId( iconId ); |
|
441 |
CleanupStack::PopAndDestroy( fullPath ); |
|
442 |
break; |
|
443 |
} |
|
444 |
case CGflmGroupItem::EDirectory: |
|
445 |
{ |
|
446 |
CGflmFileSystemItem& fsItem = |
|
447 |
static_cast< CGflmFileSystemItem& >( aItem ); |
|
448 |
HBufC* fullPath = fsItem.FullPathLC(); |
|
449 |
||
450 |
// Do not check for subfolders for remote drives |
|
451 |
iconId = EFileManagerFolderIcon; |
|
452 |
if ( !IsRemoteDrive( *fullPath ) ) |
|
453 |
{ |
|
454 |
if ( HasSubFolders( *fullPath ) ) |
|
455 |
{ |
|
456 |
iconId = EFileManagerFolderSubIcon; |
|
457 |
} |
|
458 |
else if ( !HasFiles( *fullPath ) ) |
|
459 |
{ |
|
460 |
iconId = EFileManagerFolderEmptyIcon; |
|
461 |
} |
|
462 |
} |
|
463 |
fsItem.SetIconId( iconId ); |
|
464 |
CleanupStack::PopAndDestroy( fullPath ); |
|
465 |
break; |
|
466 |
} |
|
467 |
case CGflmGroupItem::EDrive: // Fall through |
|
468 |
case CGflmGroupItem::EGlobalActionItem: |
|
469 |
{ |
|
470 |
break; |
|
471 |
} |
|
472 |
default: |
|
473 |
{ |
|
474 |
User::Leave( KErrNotFound ); |
|
475 |
break; |
|
476 |
} |
|
477 |
} |
|
478 |
||
479 |
return iconId; |
|
480 |
} |
|
481 |
||
482 |
// ----------------------------------------------------------------------------- |
|
483 |
// CFileManagerUtils::HasAny |
|
484 |
// |
|
485 |
// ----------------------------------------------------------------------------- |
|
486 |
// |
|
487 |
TBool CFileManagerUtils::HasAny( |
|
488 |
RFs& aFs, const TDesC& aFullPath, TUint aAttMask ) |
|
489 |
{ |
|
490 |
RDir dir; |
|
491 |
TBool ret( EFalse ); |
|
492 |
if ( dir.Open( aFs, aFullPath, aAttMask ) != KErrNone ) |
|
493 |
{ |
|
494 |
return EFalse; |
|
495 |
} |
|
496 |
TEntry entry; |
|
497 |
if ( dir.Read( entry ) == KErrNone ) |
|
498 |
{ |
|
499 |
ret = ETrue; |
|
500 |
} |
|
501 |
dir.Close(); |
|
502 |
return ret; |
|
503 |
} |
|
504 |
||
505 |
// ----------------------------------------------------------------------------- |
|
506 |
// CFileManagerUtils::HasSubFolders |
|
507 |
// |
|
508 |
// ----------------------------------------------------------------------------- |
|
509 |
// |
|
510 |
TBool CFileManagerUtils::HasSubFolders( const TDesC& aFullPath ) const |
|
511 |
{ |
|
512 |
return HasAny( iFs, aFullPath, KEntryAttDir | KEntryAttMatchExclusive ); |
|
513 |
} |
|
514 |
||
515 |
// ----------------------------------------------------------------------------- |
|
516 |
// CFileManagerUtils::HasFiles |
|
517 |
// |
|
518 |
// ----------------------------------------------------------------------------- |
|
519 |
// |
|
520 |
TBool CFileManagerUtils::HasFiles( const TDesC& aFullPath ) const |
|
521 |
{ |
|
522 |
return HasAny( iFs, aFullPath, KEntryAttNormal ); |
|
523 |
} |
|
524 |
||
525 |
// ----------------------------------------------------------------------------- |
|
526 |
// CFileManagerUtils::IsRemoteDrive |
|
527 |
// |
|
528 |
// ----------------------------------------------------------------------------- |
|
529 |
// |
|
530 |
TBool CFileManagerUtils::IsRemoteDrive( const TDesC& aPath ) const |
|
531 |
{ |
|
532 |
TBool ret( EFalse ); |
|
533 |
||
534 |
if ( aPath.Length() ) |
|
535 |
{ |
|
536 |
CGflmDriveItem* drvItem = iNavigator.DriveFromPath( aPath ); |
|
537 |
if ( drvItem ) |
|
538 |
{ |
|
539 |
const TVolumeInfo& vol( drvItem->VolumeInfo() ); |
|
540 |
if ( vol.iDrive.iDriveAtt & KDriveAttRemote ) |
|
541 |
{ |
|
542 |
ret = ETrue; |
|
543 |
} |
|
544 |
} |
|
545 |
} |
|
546 |
return ret; |
|
547 |
} |
|
548 |
||
549 |
// ----------------------------------------------------------------------------- |
|
550 |
// CFileManagerUtils::CreateDefaultFolders |
|
551 |
// |
|
552 |
// ----------------------------------------------------------------------------- |
|
553 |
// |
|
554 |
void CFileManagerUtils::CreateDefaultFolders( |
|
555 |
const TInt aDrive, const TBool aForced ) const |
|
556 |
{ |
|
557 |
iDefaultFolders->CreateFolders( aDrive, aForced ); |
|
558 |
} |
|
559 |
||
560 |
// ----------------------------------------------------------------------------- |
|
561 |
// CFileManagerUtils::IsDistributableFile |
|
562 |
// |
|
563 |
// ----------------------------------------------------------------------------- |
|
564 |
// |
|
565 |
TInt CFileManagerUtils::IsDistributableFile( |
|
566 |
const TDesC& aFullPath, TBool& aIsProtected ) |
|
567 |
{ |
|
568 |
#if defined( __KEEP_DRM_CONTENT_ON_PHONE ) && defined ( FILE_MANAGER_USE_DISTRIBUTABLECHECKER ) |
|
569 |
if ( !iDistributableChecker ) |
|
570 |
{ |
|
571 |
TRAPD( err, iDistributableChecker = CDistributableChecker::NewL() ); |
|
572 |
if ( err != KErrNone ) |
|
573 |
{ |
|
574 |
_LIT( KReason, "No Distributablechecker" ); |
|
575 |
User::Panic( KReason, err ); |
|
576 |
} |
|
577 |
} |
|
578 |
return iDistributableChecker->Check( aFullPath, aIsProtected ); |
|
579 |
#else // __KEEP_DRM_CONTENT_ON_PHONE && FILE_MANAGER_USE_DISTRIBUTABLECHECKER |
|
580 |
aIsProtected = EFalse; |
|
581 |
TBool isFlk( EFalse ); |
|
582 |
TBool isLdf( EFalse ); |
|
583 |
TRAPD( err, IsFlkOrLdfFileL( aFullPath, isFlk, isLdf ) ); |
|
584 |
// Do similar check than in old DRMCommon |
|
585 |
aIsProtected = ( isFlk || isLdf ); |
|
586 |
return err; |
|
587 |
#endif // __KEEP_DRM_CONTENT_ON_PHONE && FILE_MANAGER_USE_DISTRIBUTABLECHECKER |
|
588 |
} |
|
589 |
||
590 |
// ----------------------------------------------------------------------------- |
|
591 |
// CFileManagerUtils::MimeTypeL |
|
592 |
// |
|
593 |
// ----------------------------------------------------------------------------- |
|
594 |
// |
|
595 |
TPtrC CFileManagerUtils::MimeTypeL( const TDesC& aFullPath ) const |
|
596 |
{ |
|
597 |
return iNavigator.ResolveMimeTypeL( aFullPath ); |
|
598 |
} |
|
599 |
||
600 |
// ----------------------------------------------------------------------------- |
|
601 |
// CFileManagerUtils::DriveList |
|
602 |
// |
|
603 |
// ----------------------------------------------------------------------------- |
|
604 |
// |
|
605 |
void CFileManagerUtils::DriveList( |
|
606 |
RArray< TInt >& aDrives, const TInt aAttMask ) const |
|
607 |
{ |
|
608 |
aDrives.Reset(); |
|
609 |
TDriveList drivesList; |
|
610 |
if ( iFs.DriveList( drivesList ) != KErrNone ) |
|
611 |
{ |
|
612 |
return; |
|
613 |
} |
|
614 |
for ( TInt i( 0 ); i < KMaxDrives; i++ ) |
|
615 |
{ |
|
616 |
if ( drivesList[ i ] ) |
|
617 |
{ |
|
618 |
TBool append( EFalse ); |
|
619 |
TDriveInfo drvInfo; |
|
620 |
if ( iFs.Drive( drvInfo, i ) == KErrNone ) |
|
621 |
{ |
|
622 |
if ( drvInfo.iDriveAtt & aAttMask ) |
|
623 |
{ |
|
624 |
append = ETrue; |
|
625 |
} |
|
626 |
} |
|
627 |
if ( append ) |
|
628 |
{ |
|
629 |
aDrives.Append( i ); |
|
630 |
} |
|
631 |
} |
|
632 |
} |
|
633 |
} |
|
634 |
||
635 |
// ----------------------------------------------------------------------------- |
|
636 |
// CFileManagerUtils::IsRemovableDrive |
|
637 |
// |
|
638 |
// ----------------------------------------------------------------------------- |
|
639 |
// |
|
640 |
TBool CFileManagerUtils::IsRemovableDrive( const TDesC& aPath ) const |
|
641 |
{ |
|
642 |
return IsDrive( iFs, aPath, KDriveAttRemovable ); |
|
643 |
} |
|
644 |
||
645 |
// ----------------------------------------------------------------------------- |
|
646 |
// CFileManagerUtils::GetFullPath |
|
647 |
// ----------------------------------------------------------------------------- |
|
648 |
// |
|
649 |
void CFileManagerUtils::GetFullPath( |
|
650 |
const TDesC& aDir, const TEntry& aEntry, TDes& aFullPath ) |
|
651 |
{ |
|
652 |
GflmUtils::GetFullPath( aDir, aEntry, aFullPath ); |
|
653 |
} |
|
654 |
||
655 |
// ----------------------------------------------------------------------------- |
|
656 |
// CFileManagerUtils::StripFinalBackslash |
|
657 |
// ----------------------------------------------------------------------------- |
|
658 |
// |
|
659 |
EXPORT_C TPtrC CFileManagerUtils::StripFinalBackslash( const TDesC& aPath ) |
|
660 |
{ |
|
661 |
return GflmUtils::StripFinalBackslash( aPath ); |
|
662 |
} |
|
663 |
||
664 |
// ----------------------------------------------------------------------------- |
|
665 |
// CFileManagerUtils::EnsureFinalBackslash |
|
666 |
// ----------------------------------------------------------------------------- |
|
667 |
// |
|
668 |
EXPORT_C void CFileManagerUtils::EnsureFinalBackslash( TDes& aPath ) |
|
669 |
{ |
|
670 |
GflmUtils::EnsureFinalBackslash( aPath ); |
|
671 |
} |
|
672 |
||
673 |
// ----------------------------------------------------------------------------- |
|
674 |
// CFileManagerUtils::StripDirectionalCharsLC |
|
675 |
// ----------------------------------------------------------------------------- |
|
676 |
// |
|
677 |
HBufC* CFileManagerUtils::StripDirectionalCharsLC( const TDesC& aText ) |
|
678 |
{ |
|
679 |
HBufC* text = aText.AllocLC(); |
|
680 |
TPtr ptr( text->Des() ); |
|
681 |
AknTextUtils::StripCharacters( ptr, KFmgrDirectionalChars ); |
|
682 |
return text; |
|
683 |
} |
|
684 |
||
685 |
// ----------------------------------------------------------------------------- |
|
686 |
// CFileManagerUtils::IsFlkOrLdfFileL |
|
687 |
// ----------------------------------------------------------------------------- |
|
688 |
// |
|
689 |
void CFileManagerUtils::IsFlkOrLdfFileL( |
|
690 |
const TDesC& aFullPath, TBool& aIsFlk, TBool& aIsLdf ) |
|
691 |
{ |
|
692 |
aIsFlk = EFalse; |
|
693 |
aIsLdf = EFalse; |
|
694 |
ContentAccess::CContent* content = |
|
695 |
ContentAccess::CContent::CContent::NewLC( |
|
696 |
aFullPath, EContentShareReadOnly ); |
|
697 |
HBufC* contentId = HBufC::NewLC( KMaxFileName ); |
|
698 |
TPtr ptrContentId( contentId->Des() ); |
|
699 |
TInt err( content->GetStringAttribute( |
|
700 |
ContentAccess::EContentID, ptrContentId ) ); |
|
701 |
if ( err != KErrNone && err != KErrCANotSupported ) |
|
702 |
{ |
|
703 |
User::Leave( err ); |
|
704 |
} |
|
705 |
if ( !ptrContentId.Left( KFlk().Length() ).Compare( KFlk ) ) |
|
706 |
{ |
|
707 |
aIsFlk = ETrue; |
|
708 |
} |
|
709 |
else if ( !ptrContentId.Left( KLdf().Length() ).Compare( KLdf ) ) |
|
710 |
{ |
|
711 |
aIsLdf = ETrue; |
|
712 |
} |
|
713 |
CleanupStack::PopAndDestroy( contentId ); |
|
714 |
CleanupStack::PopAndDestroy( content ); |
|
715 |
} |
|
716 |
||
717 |
// ----------------------------------------------------------------------------- |
|
718 |
// CFileManagerUtils::HasFinalBackslash |
|
719 |
// ----------------------------------------------------------------------------- |
|
720 |
// |
|
721 |
EXPORT_C TBool CFileManagerUtils::HasFinalBackslash( const TDesC& aPath ) |
|
722 |
{ |
|
723 |
return GflmUtils::HasFinalBackslash( aPath ); |
|
724 |
} |
|
725 |
||
726 |
// ----------------------------------------------------------------------------- |
|
727 |
// CFileManagerUtils::IsInternalDrive |
|
728 |
// ----------------------------------------------------------------------------- |
|
729 |
// |
|
730 |
TBool CFileManagerUtils::IsInternalDrive( RFs& aFs, const TInt aDrive ) |
|
731 |
{ |
|
732 |
return IsDrive( aFs, aDrive, KDriveAttInternal ); |
|
733 |
} |
|
734 |
||
735 |
// ----------------------------------------------------------------------------- |
|
736 |
// CFileManagerUtils::IsFromInternalToRemovableDrive |
|
737 |
// ----------------------------------------------------------------------------- |
|
738 |
// |
|
739 |
EXPORT_C TBool CFileManagerUtils::IsFromInternalToRemovableDrive( |
|
740 |
RFs& aFs, const TDesC& aSrcPath, const TDesC& aDstPath ) |
|
741 |
{ |
|
742 |
TInt srcDrv = TDriveUnit( aSrcPath ); |
|
743 |
TInt dstDrv = TDriveUnit( aDstPath ); |
|
744 |
if ( srcDrv == dstDrv ) |
|
745 |
{ |
|
746 |
return EFalse; |
|
747 |
} |
|
748 |
return ( IsInternalDrive( aFs, srcDrv ) && |
|
749 |
!IsInternalDrive( aFs, dstDrv ) ); |
|
750 |
} |
|
751 |
||
752 |
// ----------------------------------------------------------------------------- |
|
753 |
// CFileManagerUtils::RemoveReadOnlyAttribute |
|
754 |
// ----------------------------------------------------------------------------- |
|
755 |
// |
|
756 |
TInt CFileManagerUtils::RemoveReadOnlyAttribute( |
|
757 |
RFs& aFs, const TDesC& aFullPath, const TEntry& aEntry ) |
|
758 |
{ |
|
759 |
TInt ret( KErrNone ); |
|
760 |
if( aEntry.IsReadOnly() ) |
|
761 |
{ |
|
762 |
ret = aFs.SetEntry( |
|
763 |
aFullPath, aEntry.iModified, 0, KEntryAttReadOnly ); |
|
764 |
} |
|
765 |
return ret; |
|
766 |
} |
|
767 |
||
768 |
// ----------------------------------------------------------------------------- |
|
769 |
// CFileManagerUtils::RemoveReadOnlyAttribute |
|
770 |
// ----------------------------------------------------------------------------- |
|
771 |
// |
|
772 |
TInt CFileManagerUtils::RemoveReadOnlyAttribute( |
|
773 |
RFs& aFs, const TDesC& aFullPath ) |
|
774 |
{ |
|
775 |
TEntry entry; |
|
776 |
TInt ret( aFs.Entry( aFullPath, entry ) ); |
|
777 |
if ( ret == KErrNone ) |
|
778 |
{ |
|
779 |
ret = RemoveReadOnlyAttribute( aFs, aFullPath, entry ); |
|
780 |
} |
|
781 |
return ret; |
|
782 |
} |
|
783 |
||
784 |
#ifdef RD_MULTIPLE_DRIVE |
|
785 |
// ----------------------------------------------------------------------------- |
|
786 |
// CFileManagerUtils::GetDriveNameArrayLC |
|
787 |
// ----------------------------------------------------------------------------- |
|
788 |
// |
|
789 |
CDesCArray* CFileManagerUtils::GetDriveNameArrayLC( |
|
790 |
const TInt aDrive, TUint& aDriveStatus ) const |
|
791 |
{ |
|
792 |
CGflmDriveItem* drvItem = iNavigator.DriveFromId( aDrive ); |
|
793 |
if ( !drvItem ) |
|
794 |
{ |
|
795 |
User::Leave( KErrNotFound ); |
|
796 |
} |
|
797 |
aDriveStatus = drvItem->DriveStatus(); |
|
798 |
CDesCArray* ret = new( ELeave ) CDesCArrayFlat( KDriveNameArrayLen ); |
|
799 |
CleanupStack::PushL( ret ); |
|
800 |
ret->AppendL( TDriveUnit( aDrive ).Name() ); |
|
801 |
||
802 |
if ( aDriveStatus & DriveInfo::EDriveInternal ) |
|
803 |
{ |
|
804 |
// Device memory and mass storage drives |
|
805 |
return ret; |
|
806 |
} |
|
807 |
// Other drives |
|
808 |
TPtrC drvName( drvItem->Name() ); |
|
809 |
if ( drvName.Length() ) |
|
810 |
{ |
|
811 |
ret->AppendL( drvName ); |
|
812 |
} |
|
813 |
return ret; |
|
814 |
} |
|
815 |
||
816 |
// ----------------------------------------------------------------------------- |
|
817 |
// CFileManagerUtils::GetDriveNameL |
|
818 |
// ----------------------------------------------------------------------------- |
|
819 |
// |
|
820 |
HBufC* CFileManagerUtils::GetDriveNameL( |
|
821 |
const TInt aDrive, const TDriveNameLayout aLayout ) const |
|
822 |
{ |
|
823 |
if ( aLayout < 0 || aLayout >= ELayoutCount ) |
|
824 |
{ |
|
825 |
User::Leave( KErrArgument ); |
|
826 |
} |
|
827 |
TUint driveStatus( 0 ); |
|
828 |
CDesCArray* array = GetDriveNameArrayLC( aDrive, driveStatus ); |
|
829 |
HBufC* ret = NULL; |
|
830 |
if ( driveStatus & DriveInfo::EDriveInternal ) |
|
831 |
{ |
|
832 |
// Device memory and mass storage drives |
|
833 |
if ( driveStatus & DriveInfo::EDriveExternallyMountable ) |
|
834 |
{ |
|
835 |
ret = StringLoader::LoadL( |
|
836 |
KFmgrDriveNames[ aLayout ][ EFmgrMassStorage ], |
|
837 |
array->MdcaPoint( KDriveLetterIndex ) ); |
|
838 |
} |
|
839 |
else |
|
840 |
{ |
|
841 |
ret = StringLoader::LoadL( |
|
842 |
KFmgrDriveNames[ aLayout ][ EFmgrDeviceMemory ], |
|
843 |
array->MdcaPoint( KDriveLetterIndex ) ); |
|
844 |
} |
|
845 |
} |
|
846 |
else if ( driveStatus & DriveInfo::EDriveRemovable ) |
|
847 |
{ |
|
848 |
// Physically removable drives |
|
849 |
if ( array->MdcaCount() > 1 ) |
|
850 |
{ |
|
851 |
ret = StringLoader::LoadL( |
|
852 |
KFmgrDriveNames[ aLayout ][ EFmgrNamedMemoryCard ], |
|
853 |
*array ); |
|
854 |
} |
|
855 |
else |
|
856 |
{ |
|
857 |
TInt driveType( EFmgrDefaultMemoryCard ); |
|
858 |
if ( driveStatus & DriveInfo::EDriveUsbMemory ) |
|
859 |
{ |
|
860 |
driveType = EFmgrDefaultUsbMemory; |
|
861 |
} |
|
862 |
ret = StringLoader::LoadL( |
|
863 |
KFmgrDriveNames[ aLayout ][ driveType ], |
|
864 |
array->MdcaPoint( KDriveLetterIndex ) ); |
|
865 |
} |
|
866 |
} |
|
867 |
else if ( array->MdcaCount() > 1 ) |
|
868 |
{ |
|
869 |
// Other drives |
|
870 |
ret = array->MdcaPoint( KDriveNameIndex ).AllocL(); |
|
871 |
} |
|
872 |
else |
|
873 |
{ |
|
874 |
User::Leave( KErrNotFound ); |
|
875 |
} |
|
876 |
CleanupStack::PopAndDestroy( array ); |
|
877 |
return ret; |
|
878 |
} |
|
879 |
||
880 |
// ----------------------------------------------------------------------------- |
|
881 |
// CFileManagerUtils::GetFormattedDriveNameLC |
|
882 |
// ----------------------------------------------------------------------------- |
|
883 |
// |
|
884 |
HBufC* CFileManagerUtils::GetFormattedDriveNameLC( |
|
885 |
const TInt aDrive, |
|
886 |
const TInt aTextIdForDefaultName, |
|
887 |
const TInt aTextIdForName ) const |
|
52
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
888 |
{ |
39 | 889 |
TUint driveStatus( 0 ); |
52
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
890 |
HBufC* ret = NULL; |
39 | 891 |
CDesCArray* array = GetDriveNameArrayLC( aDrive, driveStatus ); |
892 |
if ( aTextIdForName && array->MdcaCount() > 1 ) |
|
893 |
{ |
|
52
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
894 |
ret = StringLoader::LoadL( |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
895 |
aTextIdForName, |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
896 |
*array ); |
39 | 897 |
} |
898 |
else if ( aTextIdForDefaultName ) |
|
899 |
{ |
|
52
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
900 |
if( driveStatus & DriveInfo::EDriveUsbMemory ) |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
901 |
{ |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
902 |
CDesCArray* usbLetterName = new ( ELeave ) CDesCArrayFlat( KDriveNameArrayLen ); |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
903 |
CleanupStack::PushL( usbLetterName ); |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
904 |
|
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
905 |
TPtrC16 driveletter=array->MdcaPoint( KDriveLetterIndex ); |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
906 |
usbLetterName->AppendL( driveletter ); |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
907 |
HBufC* usbDriveDefaultName = NULL; |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
908 |
if(array->MdcaCount() > 1 ) |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
909 |
{ |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
910 |
TPtrC16 drivename=array->MdcaPoint( KDriveNameIndex ); |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
911 |
usbLetterName->AppendL( drivename ); |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
912 |
} |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
913 |
else |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
914 |
{ |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
915 |
usbDriveDefaultName = StringLoader::LoadLC( R_QTN_FMGR_USB_MEMORY_DEFAULT_NAME ); |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
916 |
TPtrC16 drivename = usbDriveDefaultName->Des(); |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
917 |
usbLetterName->AppendL( drivename ); |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
918 |
} |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
919 |
|
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
920 |
|
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
921 |
ret = StringLoader::LoadL( |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
922 |
aTextIdForDefaultName,*usbLetterName ); |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
923 |
|
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
924 |
CleanupStack::PopAndDestroy( usbLetterName ); |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
925 |
if ( usbDriveDefaultName ) |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
926 |
{ |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
927 |
CleanupStack::PopAndDestroy( usbDriveDefaultName ); |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
928 |
} |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
929 |
} |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
930 |
else |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
931 |
{ |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
932 |
ret = StringLoader::LoadL(aTextIdForDefaultName, array->MdcaPoint( |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
933 |
KDriveLetterIndex)); |
40fb776cbfb3
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
42
diff
changeset
|
934 |
} |
39 | 935 |
} |
936 |
else if ( array->MdcaCount() > 1 ) |
|
937 |
{ |
|
938 |
ret = array->MdcaPoint( KDriveNameIndex ).AllocL(); |
|
939 |
} |
|
940 |
else |
|
941 |
{ |
|
942 |
User::Leave( KErrNotFound ); |
|
943 |
} |
|
944 |
CleanupStack::PopAndDestroy( array ); |
|
945 |
CleanupStack::PushL( ret ); |
|
946 |
return ret; |
|
947 |
} |
|
948 |
||
949 |
#endif // RD_MULTIPLE_DRIVE |
|
950 |
||
951 |
// ----------------------------------------------------------------------------- |
|
952 |
// CFileManagerUtils::IsRemoteDrive |
|
953 |
// ----------------------------------------------------------------------------- |
|
954 |
EXPORT_C TBool CFileManagerUtils::IsRemoteDrive( |
|
955 |
RFs& aFs, const TDesC& aPath ) |
|
956 |
{ |
|
957 |
return IsDrive( aFs, aPath, KDriveAttRemote ); |
|
958 |
} |
|
959 |
||
960 |
// ----------------------------------------------------------------------------- |
|
961 |
// CFileManagerUtils::IsDrive |
|
962 |
// ----------------------------------------------------------------------------- |
|
963 |
TBool CFileManagerUtils::IsDrive( |
|
964 |
RFs& aFs, const TDesC& aPath, const TUint aAttMask ) |
|
965 |
{ |
|
966 |
TInt drv( 0 ); |
|
967 |
if ( aPath.Length() && |
|
968 |
RFs::CharToDrive( aPath[ 0 ], drv ) == KErrNone ) |
|
969 |
{ |
|
970 |
return IsDrive( aFs, drv, aAttMask ); |
|
971 |
} |
|
972 |
return EFalse; |
|
973 |
} |
|
974 |
||
975 |
// ----------------------------------------------------------------------------- |
|
976 |
// CFileManagerUtils::IsDrive |
|
977 |
// ----------------------------------------------------------------------------- |
|
978 |
TBool CFileManagerUtils::IsDrive( |
|
979 |
RFs& aFs, const TInt aDrive, const TUint aAttMask ) |
|
980 |
{ |
|
981 |
TDriveInfo drvInfo; |
|
982 |
if ( aFs.Drive( drvInfo, aDrive ) == KErrNone ) |
|
983 |
{ |
|
984 |
if ( drvInfo.iDriveAtt & aAttMask ) |
|
985 |
{ |
|
986 |
return ETrue; |
|
987 |
} |
|
988 |
} |
|
989 |
return EFalse; |
|
990 |
} |
|
991 |
||
992 |
// ------------------------------------------------------------------------------ |
|
993 |
// CFileManagerUtils::LocalizedName |
|
994 |
// |
|
995 |
// ------------------------------------------------------------------------------ |
|
996 |
// |
|
997 |
TPtrC CFileManagerUtils::LocalizedName( const TDesC& aFullPath ) const |
|
998 |
{ |
|
999 |
return iNavigator.LocalizedName( aFullPath ); |
|
1000 |
} |
|
1001 |
||
1002 |
// ----------------------------------------------------------------------------- |
|
1003 |
// CFileManagerUtils::IsNameFoundL |
|
1004 |
// ----------------------------------------------------------------------------- |
|
1005 |
// |
|
1006 |
TBool CFileManagerUtils::IsNameFoundL( const TDesC& aFullPath ) const |
|
1007 |
{ |
|
1008 |
TParsePtrC parse( CFileManagerUtils::StripFinalBackslash( aFullPath ) ); |
|
1009 |
TPtrC baseDir( parse.DriveAndPath() ); |
|
1010 |
TPtrC currentDir( iNavigator.CurrentDirectory() ); |
|
1011 |
TBool ret( EFalse ); |
|
1012 |
HBufC* name1 = CFileManagerUtils::StripDirectionalCharsLC( parse.NameAndExt() ); |
|
1013 |
// Remove white spaces from end, file server also ignores those |
|
1014 |
name1->Des().TrimRight(); |
|
1015 |
if ( !parse.PathPresent() || |
|
1016 |
( currentDir.Length() && !currentDir.CompareF( baseDir ) ) ) |
|
1017 |
{ |
|
1018 |
TBool searchmode = iNavigator.SearchMode(); |
|
1019 |
iNavigator.EnableSearchMode( EFalse ); |
|
1020 |
// Do check from current directory, all items are cached |
|
1021 |
TInt count( iNavigator.MdcaCount() ); |
|
1022 |
for( TInt i( 0 ); i < count; ++i ) |
|
1023 |
{ |
|
1024 |
CGflmGroupItem* item = iNavigator.Item( i ); |
|
1025 |
TInt itemType( item->Type() ); |
|
1026 |
switch (itemType ) |
|
1027 |
{ |
|
1028 |
case CGflmGroupItem::EFile: // FALLTHROUGH |
|
1029 |
case CGflmGroupItem::EDirectory: |
|
1030 |
{ |
|
1031 |
// Compare with file system name |
|
1032 |
CGflmFileSystemItem* fsItem = |
|
1033 |
static_cast< CGflmFileSystemItem* >( item ); |
|
1034 |
HBufC* name2 = CFileManagerUtils::StripDirectionalCharsLC( |
|
1035 |
fsItem->Entry().iName ); |
|
1036 |
ret = !( name1->CompareF( *name2 ) ); |
|
1037 |
CleanupStack::PopAndDestroy( name2 ); |
|
1038 |
if ( !ret && itemType == CGflmGroupItem::EDirectory ) |
|
1039 |
{ |
|
1040 |
// Compare with localized name |
|
1041 |
name2 = CFileManagerUtils::StripDirectionalCharsLC( |
|
1042 |
fsItem->Name() ); |
|
1043 |
if ( name2->Length() ) |
|
1044 |
{ |
|
1045 |
ret = !( name1->CompareF( *name2 ) ); |
|
1046 |
} |
|
1047 |
CleanupStack::PopAndDestroy( name2 ); |
|
1048 |
} |
|
1049 |
break; |
|
1050 |
} |
|
1051 |
default: |
|
1052 |
{ |
|
1053 |
break; |
|
1054 |
} |
|
1055 |
} |
|
1056 |
if ( ret ) |
|
1057 |
{ |
|
1058 |
break; |
|
1059 |
} |
|
1060 |
} |
|
1061 |
iNavigator.EnableSearchMode( searchmode ); |
|
1062 |
} |
|
1063 |
else |
|
1064 |
{ |
|
1065 |
// Do check from any directory |
|
1066 |
HBufC* buffer = HBufC::NewLC( |
|
1067 |
Max( KMaxFileName, aFullPath.Length() + KFmgrBackslashSpace ) ); |
|
1068 |
TPtr ptr( buffer->Des() ); |
|
1069 |
ptr.Copy( aFullPath ); |
|
1070 |
CFileManagerUtils::EnsureFinalBackslash( ptr ); |
|
1071 |
ret = ( BaflUtils::FolderExists( iFs, ptr ) || |
|
1072 |
BaflUtils::FileExists( iFs, |
|
1073 |
CFileManagerUtils::StripFinalBackslash( aFullPath ) ) ); |
|
1074 |
if ( !ret && |
|
1075 |
!IsRemoteDrive( aFullPath ) && |
|
1076 |
BaflUtils::PathExists( iFs, baseDir ) ) |
|
1077 |
{ |
|
1078 |
// Check directory for localized items on local drives |
|
1079 |
CDir* dir = NULL; |
|
1080 |
User::LeaveIfError( iFs.GetDir( |
|
1081 |
baseDir, KEntryAttMatchMask | KEntryAttNormal, ESortNone, dir ) ); |
|
1082 |
CleanupStack::PushL( dir ); |
|
1083 |
ptr.Zero(); |
|
1084 |
TInt count( dir->Count() ); |
|
1085 |
for ( TInt i ( 0 ); i < count; ++i ) |
|
1086 |
{ |
|
1087 |
HBufC* name2 = NULL; |
|
1088 |
const TEntry& entry( ( *dir )[ i ] ); |
|
1089 |
if( entry.IsDir() ) |
|
1090 |
{ |
|
1091 |
// Compare with localized name |
|
1092 |
CFileManagerUtils::GetFullPath( baseDir, entry, ptr ); |
|
1093 |
TPtrC ptr2( iNavigator.LocalizedName( ptr ) ); |
|
1094 |
if ( ptr2.Length() ) |
|
1095 |
{ |
|
1096 |
name2 = CFileManagerUtils::StripDirectionalCharsLC( ptr2 ); |
|
1097 |
} |
|
1098 |
} |
|
1099 |
if ( !name2 ) |
|
1100 |
{ |
|
1101 |
// Compare with file system name |
|
1102 |
name2 = CFileManagerUtils::StripDirectionalCharsLC( entry.iName ); |
|
1103 |
} |
|
1104 |
ret = !( name1->CompareF( *name2 ) ); |
|
1105 |
CleanupStack::PopAndDestroy( name2 ); |
|
1106 |
if ( ret ) |
|
1107 |
{ |
|
1108 |
break; |
|
1109 |
} |
|
1110 |
} |
|
1111 |
CleanupStack::PopAndDestroy( dir ); |
|
1112 |
} |
|
1113 |
CleanupStack::PopAndDestroy( buffer ); |
|
1114 |
} |
|
1115 |
CleanupStack::PopAndDestroy( name1 ); |
|
1116 |
return ret; |
|
1117 |
} |
|
1118 |
// ----------------------------------------------------------------------------- |
|
1119 |
// CFileManagerUtils::FlushCache |
|
1120 |
// ----------------------------------------------------------------------------- |
|
1121 |
// |
|
1122 |
void CFileManagerUtils::FlushCache() const |
|
1123 |
{ |
|
1124 |
iNavigator.FlushCache(); |
|
1125 |
} |
|
1126 |
||
1127 |
// End of File |