1 /* |
|
2 * Copyright (c) 2004-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: Contains the RsUtils class definitions. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <bautils.h> |
|
20 |
|
21 #include "rsutils.h" |
|
22 |
|
23 // CONSTANTS |
|
24 namespace |
|
25 { |
|
26 _LIT( KBackslash, "\\" ); |
|
27 _LIT( KMatchPattern, "*" ); |
|
28 } |
|
29 |
|
30 |
|
31 TBool RsUtils::FileExists(const TDesC& aFileName, RFs& aFs) |
|
32 { |
|
33 return ( BaflUtils::FileExists( aFs, aFileName ) ); |
|
34 } |
|
35 |
|
36 TBool RsUtils::PathExists(const TDesC& aFilePath, RFs& aFs) |
|
37 { |
|
38 if( aFilePath.Right( 1 ) == KBackslash ) |
|
39 { |
|
40 return ( BaflUtils::PathExists( aFs, aFilePath ) ); |
|
41 } |
|
42 else |
|
43 { |
|
44 TFileName filePath = aFilePath; |
|
45 filePath.Append( KBackslash ); |
|
46 return ( BaflUtils::PathExists( aFs, filePath ) ); |
|
47 } |
|
48 } |
|
49 |
|
50 TInt RsUtils::DriveFreeSpace( TChar aDrive, RFs& aFs, TUint32& aSpace ) |
|
51 { |
|
52 TInt mmcDriveNum; |
|
53 TInt err = aFs.CharToDrive( aDrive, mmcDriveNum ); |
|
54 if( !err ) |
|
55 { |
|
56 TVolumeInfo volInfo; |
|
57 err = aFs.Volume( volInfo, mmcDriveNum ); |
|
58 aSpace = volInfo.iFree; |
|
59 } |
|
60 return err; |
|
61 } |
|
62 |
|
63 |
|
64 TInt RsUtils::CumulativeFileSize( const TDesC& aFileName, RFs& aFs, TInt& aCumulativeSize ) |
|
65 { |
|
66 TEntry fileEntry; |
|
67 TInt err = aFs.Entry( aFileName, fileEntry ); |
|
68 if( !err ) |
|
69 { |
|
70 aCumulativeSize += fileEntry.iSize; |
|
71 } |
|
72 return err; |
|
73 } |
|
74 |
|
75 TBool RsUtils::FileInDir( const TDesC& aFileName, const TDesC& aDirName ) |
|
76 { |
|
77 TFileName dir = aDirName; |
|
78 if( dir.Right( 1 ) != KBackslash ) |
|
79 { |
|
80 dir.Append( KBackslash ); |
|
81 } |
|
82 dir.Append( KMatchPattern ); |
|
83 TBool ret = ( aFileName.Match( dir ) == KErrNotFound ) ? EFalse : ETrue; |
|
84 return ret; |
|
85 } |
|
86 |
|
87 TBool RsUtils::FileOnDrive( TChar aDrive, const TDesC& aFileName ) |
|
88 { |
|
89 TParsePtrC parse( aFileName ); |
|
90 TBool res = ( parse.Drive().LocateF( aDrive ) == KErrNotFound ) ? EFalse : ETrue; |
|
91 return res; |
|
92 } |
|
93 |
|
94 // End of File |
|