|
1 /* |
|
2 * Copyright (c) 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: See class definition below. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CTCMCEFILEHANDLER_H |
|
19 #define CTCMCEFILEHANDLER_H |
|
20 |
|
21 // INCLUDES |
|
22 |
|
23 #include <f32file.h> |
|
24 #include <bautils.h> |
|
25 #include <e32std.h> |
|
26 #include <e32base.h> |
|
27 |
|
28 // CLASS DECLARATION |
|
29 |
|
30 /** |
|
31 * CCTcMCEFileHandler |
|
32 * |
|
33 * Class for small file operations |
|
34 * |
|
35 */ |
|
36 class CTcMCEFileHandler : public CBase |
|
37 { |
|
38 public: |
|
39 // Constructors and destructor |
|
40 |
|
41 /** |
|
42 * Destructor. |
|
43 */ |
|
44 ~CTcMCEFileHandler(); |
|
45 |
|
46 /** |
|
47 * Two-phased constructor. |
|
48 */ |
|
49 static CTcMCEFileHandler* NewL(); |
|
50 |
|
51 /** |
|
52 * Two-phased constructor. |
|
53 */ |
|
54 static CTcMCEFileHandler* NewLC(); |
|
55 |
|
56 private: |
|
57 |
|
58 /** |
|
59 * Constructor for performing 1st stage construction |
|
60 */ |
|
61 CTcMCEFileHandler(); |
|
62 |
|
63 /** |
|
64 * EPOC default constructor for performing 2nd stage construction |
|
65 */ |
|
66 void ConstructL(); |
|
67 |
|
68 public: //user functions |
|
69 |
|
70 /** |
|
71 * Finds a files in the given path and file name or wildcard |
|
72 * Note that the trailing backslash is required to specify the directory |
|
73 * I.e. path x:\dir1\dir2\ |
|
74 * @param aPath The top level directory for the scan including the drive letter |
|
75 * @param aFileName name of the file or wildcard I.e. *.txt |
|
76 * @param aArray returned file list |
|
77 */ |
|
78 void FindFile(const TDesC& aPath, const TDesC& aFileName, CDesC8Array* aArray); |
|
79 |
|
80 /** |
|
81 * Function for reading all files from a specified folder. |
|
82 * @param aFolder |
|
83 * @param aArray returned file names. aArray must be initialized before function call |
|
84 * @return error code. KErrNone if no error |
|
85 */ |
|
86 TInt GetFilesFromFolderL(TDesC& aFolder,CDesC8Array* aArray); |
|
87 |
|
88 /** |
|
89 * Deletes the file from the file system |
|
90 * @param aName fullname of the (including the path) |
|
91 * @param aSwitch specify: zero for no recursion; CFileMan::ERecurse for recursion |
|
92 * @return ETrue if there was no errors |
|
93 */ |
|
94 TBool Delete(const TDesC& aName, TUint aSwitch=0); |
|
95 |
|
96 /** |
|
97 * Checks if file exists in the file system |
|
98 * @param aFileName fullname of the (including the path) |
|
99 * @return ETrue if file was found or EFalse otherwise |
|
100 */ |
|
101 TBool CheckFileExists(const TDesC& aFileName); |
|
102 |
|
103 /** |
|
104 * Gets the file information (size, date, attributes) |
|
105 * @param aFileName fullname of the (including the path) |
|
106 * @param aArray with file information returned by the pointer. |
|
107 * response structure: aArray[n]=attribute_name: aArray[n+1]=value |
|
108 */ |
|
109 void GetFileInfoL(const TDesC& aFileName, CDesC8Array* aArray); |
|
110 |
|
111 public: //internal |
|
112 |
|
113 void FormatEntry(TDes8& aBuffer, const TEntry& aEntry); |
|
114 |
|
115 void ScanDirectoryL( |
|
116 const TDesC& aDir, const TDesC& aWildCard, CDesC8Array* aArray); |
|
117 |
|
118 |
|
119 private: |
|
120 RFs iFsSession; |
|
121 TFileName iFileName; |
|
122 }; |
|
123 |
|
124 #endif // CTCMCEFILEHANDLER_H |