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