37 _LIT(KPathDelimeter, "\\"); |
35 _LIT(KPathDelimeter, "\\"); |
38 |
36 |
39 |
37 |
40 // ================= LOCAL FUNCTIONS ======================= |
38 // ================= LOCAL FUNCTIONS ======================= |
41 |
39 |
42 // --------------------------------------------------------------------------- |
|
43 // ExcludeListNameL |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 static void FileWriteL(RPointerArray<HBufC> &files) |
|
47 { |
|
48 RFs fileSession; |
|
49 RFile file; |
|
50 User::LeaveIfError(fileSession.Connect()); |
|
51 TInt err = file.Open(fileSession,_L("c:\\private\\100059C9\\excludelistcache.txt"),EFileWrite|EFileStreamText); |
|
52 |
|
53 if ( err != KErrNone ) |
|
54 { |
|
55 RDebug::Print(_L("CFormatterRFSPlugin::ExcludeListNameL , FileWrite : Failed to open the file")); |
|
56 return; |
|
57 } |
|
58 |
|
59 TInt pos = 0; |
|
60 file.Seek(ESeekEnd,pos); |
|
61 TInt size = files.Count(); |
|
62 RBuf filenameBuf; |
|
63 |
|
64 for ( TInt i=0; i < size; i++) |
|
65 { |
|
66 HBufC8* fileName = HBufC8::NewLC(files[i]->Size()); |
|
67 TPtr8 fileNamePtr(fileName->Des()); |
|
68 fileNamePtr.Copy(*files[i]); |
|
69 |
|
70 filenameBuf.Create(fileNamePtr.Length()); |
|
71 filenameBuf.Copy(fileNamePtr); |
|
72 TFileText fileText ; |
|
73 fileText.Set(file) ; |
|
74 fileText.Seek(ESeekStart); |
|
75 fileText.Write(filenameBuf); |
|
76 CleanupStack::PopAndDestroy();//Filename |
|
77 file.Flush(); |
|
78 } |
|
79 |
|
80 file.Close(); |
|
81 fileSession.Close(); |
|
82 } |
|
83 |
|
84 static void MergeFilesL() |
|
85 { |
|
86 |
|
87 RFs fileSession; |
|
88 RFile excludeFileName; |
|
89 |
|
90 RFile fileName; |
|
91 TInt pos = 0; |
|
92 TInt size_of_script( 0 ); |
|
93 TInt buffer_size( sizeof(TText) ); |
|
94 TInt number_of_chars; |
|
95 |
|
96 User::LeaveIfError(fileSession.Connect()); |
|
97 TInt ret = excludeFileName.Open(fileSession,_L("c:\\private\\100059C9\\excludelist.txt"),EFileRead); |
|
98 |
|
99 if(ret != KErrNone) |
|
100 { |
|
101 RDebug::Print(_L("CFormatterRFSPlugin::ExcludeListNameL , MergeFiles : Failed to open the file")); |
|
102 return; |
|
103 } |
|
104 ret = fileName.Open(fileSession,_L("c:\\private\\100059C9\\excludelistcache.txt"),EFileWrite|EFileStreamText); |
|
105 if ( ret != KErrNone) |
|
106 { |
|
107 excludeFileName.Close(); |
|
108 RDebug::Print(_L("CFormatterRFSPlugin::ExcludeListNameL , MergeFiles : Failed to open the file")); |
|
109 return; |
|
110 } |
|
111 fileName.Seek(ESeekEnd,pos); |
|
112 |
|
113 HBufC* buffer = HBufC::NewMaxLC( buffer_size ); |
|
114 TPtr8 bufferPtr( (TUint8*)buffer->Ptr(), buffer_size); |
|
115 |
|
116 TInt err(0); |
|
117 err = excludeFileName.Size( size_of_script ); |
|
118 number_of_chars = size_of_script / sizeof(TText); |
|
119 |
|
120 TInt i(0); |
|
121 for (i = 0; i < number_of_chars; i++) |
|
122 { |
|
123 if ( err == KErrNone ) |
|
124 { |
|
125 err = excludeFileName.Read( bufferPtr); |
|
126 } |
|
127 fileName.Write(bufferPtr); |
|
128 } |
|
129 fileName.Flush(); |
|
130 fileName.Close(); |
|
131 |
|
132 excludeFileName.Close(); |
|
133 fileSession.Close(); |
|
134 CleanupStack::PopAndDestroy();//buffer |
|
135 |
|
136 } |
|
137 |
40 |
138 static HBufC* ExcludeListNameL( TChar aSystemDrive ) |
41 static HBufC* ExcludeListNameL( TChar aSystemDrive ) |
139 { |
42 { |
140 FUNC_LOG; |
43 FUNC_LOG; |
141 |
44 |
142 RDebug::Print(_L("CFormatterRFSPlugin::ExcludeListNameL")); |
45 HBufC* buf = HBufC::NewLC( KExcludeList().Length() + KExcludeListPathNameLenExt ); |
143 |
46 TPtr bufPtr = buf->Des(); |
144 RFs fileSession; |
47 bufPtr.Append( aSystemDrive ); |
145 RFile file; |
48 bufPtr.Append( KDriveDelimiter ); |
146 |
49 bufPtr.Append( KExcludeList ); |
147 _LIT8(KFileName, "c:\\private\\100059C9\\excludelistcache.txt\n"); |
50 CleanupStack::Pop( buf ); |
148 TBuf8 <50> fileName; |
|
149 fileName.Copy(KFileName); |
|
150 |
|
151 User::LeaveIfError(fileSession.Connect()); |
|
152 |
|
153 RDir dir; |
|
154 if(dir.Open(fileSession,_L("c:\\private\\100059C9\\"),KEntryAttNormal) != KErrNone) |
|
155 { |
|
156 User::LeaveIfError(fileSession.MkDir(_L("c:\\private\\100059C9\\"))); |
|
157 } |
|
158 |
|
159 TInt rev = file.Replace(fileSession,_L("c:\\private\\100059C9\\excludelistcache.txt"),EFileWrite|EFileStreamText); |
|
160 |
|
161 RDebug::Print(_L("CFormatterRFSPlugin::ExcludeListNameL, Replace returned %d"),rev); |
|
162 |
|
163 file.Flush(); |
|
164 file.Close(); |
|
165 dir.Close(); |
|
166 fileSession.Close(); |
|
167 |
|
168 Swi::RSisRegistrySession session; |
|
169 CleanupClosePushL(session); |
|
170 User::LeaveIfError(session.Connect()); |
|
171 |
|
172 // Get the installed application UIDs |
|
173 RArray<TUid> uids; |
|
174 CleanupClosePushL(uids); |
|
175 session.InstalledUidsL(uids); |
|
176 TInt uidcount = uids.Count(); |
|
177 |
|
178 Swi::RSisRegistryEntry entry; |
|
179 Swi::RSisRegistryEntry entry2; |
|
180 CleanupClosePushL(entry); |
|
181 CleanupClosePushL(entry2); |
|
182 |
|
183 RPointerArray<HBufC> registryFiles; |
|
184 RPointerArray<HBufC> augmentedRegistryFiles; |
|
185 RPointerArray<HBufC> nonRemovableFiles; |
|
186 RPointerArray<HBufC> nonRemovableAugmentedFiles; |
|
187 CleanupResetAndDestroyPushL(registryFiles); |
|
188 CleanupResetAndDestroyPushL(augmentedRegistryFiles); |
|
189 CleanupResetAndDestroyPushL(nonRemovableFiles); |
|
190 CleanupResetAndDestroyPushL(nonRemovableAugmentedFiles); |
|
191 |
|
192 TInt count; |
|
193 RPointerArray<Swi::CSisRegistryPackage> augmentationPackages; |
|
194 CleanupResetAndDestroyPushL(augmentationPackages); |
|
195 for ( TInt iter=0; iter<uidcount; iter++) |
|
196 { |
|
197 User::LeaveIfError(entry.Open(session,uids[iter])); |
|
198 if(EFalse == entry.RemovableL()) |
|
199 { |
|
200 entry.FilesL(nonRemovableFiles); |
|
201 entry.RegistryFilesL(registryFiles); |
|
202 TInt fileCount = nonRemovableFiles.Count(); |
|
203 for (TInt z=fileCount-1; z>=0;z--) |
|
204 { |
|
205 TPtr firstChar(nonRemovableFiles[z]->Des()); |
|
206 if(firstChar.Mid(0,1) == _L("z")) |
|
207 { |
|
208 delete nonRemovableFiles[z]; |
|
209 nonRemovableFiles.Remove(z); |
|
210 } |
|
211 } |
|
212 // Look for augmentations. |
|
213 if(entry.IsAugmentationL()) |
|
214 { |
|
215 entry.AugmentationsL(augmentationPackages); |
|
216 count = entry.AugmentationsNumberL(); |
|
217 for (TInt i=0; i < count; ++i) |
|
218 { |
|
219 User::LeaveIfError(entry2.OpenL(session,*augmentationPackages[i])); |
|
220 if(EFalse == entry2.RemovableL()) |
|
221 { |
|
222 entry2.FilesL(nonRemovableAugmentedFiles); |
|
223 entry2.RegistryFilesL(augmentedRegistryFiles); |
|
224 for (TInt c=0; c<nonRemovableAugmentedFiles.Count();c++) |
|
225 { |
|
226 TPtr firstChar(nonRemovableAugmentedFiles[c]->Des()); |
|
227 if(firstChar.Mid(0,1) == _L("z")) |
|
228 { |
|
229 delete nonRemovableAugmentedFiles[c]; |
|
230 nonRemovableAugmentedFiles.Remove(c); |
|
231 } |
|
232 } |
|
233 } |
|
234 entry2.Close(); |
|
235 } |
|
236 } |
|
237 } |
|
238 entry.Close(); |
|
239 } |
|
240 RDebug::Print(_L("CFormatterRFSPlugin::ExcludeListNameL Writing the file names to the excludelist.txt")); |
|
241 |
|
242 MergeFilesL(); |
|
243 FileWriteL(nonRemovableAugmentedFiles); |
|
244 FileWriteL(augmentedRegistryFiles); |
|
245 FileWriteL(nonRemovableFiles); |
|
246 FileWriteL(registryFiles); |
|
247 |
|
248 TInt pos = 0; |
|
249 User::LeaveIfError(fileSession.Connect()); |
|
250 User::LeaveIfError(file.Open(fileSession,_L("c:\\private\\100059C9\\excludelistcache.txt"),EFileWrite|EFileStreamText)); |
|
251 |
|
252 file.Seek(ESeekEnd,pos); |
|
253 |
|
254 TBuf<KMaxFileName> configurationLine ; |
|
255 TFileText fileText ; |
|
256 fileText.Set(file) ; |
|
257 fileText.Seek(ESeekStart); |
|
258 configurationLine.Format(_L("c:\\private\\100059C9\\excludelistcache.txt")) ; |
|
259 fileText.Write(configurationLine); |
|
260 |
|
261 file.Flush(); |
|
262 file.Close(); |
|
263 fileSession.Close(); |
|
264 |
|
265 |
|
266 CleanupStack::PopAndDestroy(9,&session); |
|
267 |
|
268 HBufC* buf = HBufC::NewLC( KExcludeListcache().Length() + KExcludeListPathNameLenExt ); |
|
269 TPtr bufPtr = buf->Des(); |
|
270 bufPtr.Append( aSystemDrive ); |
|
271 bufPtr.Append( KDriveDelimiter ); |
|
272 bufPtr.Append( KExcludeListcache ); |
|
273 CleanupStack::Pop( buf ); |
|
274 return buf; |
51 return buf; |
275 } |
52 } |
276 |
53 |
277 // --------------------------------------------------------------------------- |
54 // --------------------------------------------------------------------------- |
278 // CheckFileExist |
55 // CheckFileExist |