299
|
1 |
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// f32test\testfsys\t_tfsys.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include "t_tfsys_notify.h"
|
|
19 |
|
|
20 |
|
|
21 |
const TInt KMajorVersionNumber=1;
|
|
22 |
const TInt KMinorVersionNumber=0;
|
|
23 |
|
|
24 |
void CTestNotificationMountCB::FileOpenL(const TDesC& aName,TUint /*aMode*/,TFileOpen /*anOpen*/,CFileCB* /*aFile*/)
|
|
25 |
{
|
|
26 |
RDebug::Print(_L("CTestMountCB::FileOpenL - aName = %S"),&aName);
|
|
27 |
|
|
28 |
if(aName.Match(_L("\\Wellformed_functionReplace.txt"))!= KErrNotFound) //PhantomFile_functionWrite.txt
|
|
29 |
{
|
|
30 |
CFsNotificationInfo* notificationInfo = CFsNotificationInfo::Allocate(*this,EFsFileReplace);
|
|
31 |
TBuf<KMaxFileName> phantomName;
|
|
32 |
phantomName.Append(_L("\\"));
|
|
33 |
phantomName.Append(_L("PhantomFile_functionReplace.txt"));
|
|
34 |
TInt r = notificationInfo->SetSourceName(phantomName);
|
|
35 |
User::LeaveIfError(r);
|
|
36 |
r = notificationInfo->SetUid(TUid::Uid(KErrUnknown));
|
|
37 |
User::LeaveIfError(r);
|
|
38 |
r = IssueNotification(notificationInfo);
|
|
39 |
User::LeaveIfError(r);
|
|
40 |
CFsNotificationInfo::Free(notificationInfo);
|
|
41 |
return;
|
|
42 |
}
|
|
43 |
else if(aName.Match(_L("\\Extended_Replaced.txt"))!= KErrNotFound) //\\Extended_Replaced.txt
|
|
44 |
{
|
|
45 |
CFsNotificationInfo* notificationInfo = CFsNotificationInfo::Allocate(*this,EFsFileReplace);
|
|
46 |
TBuf<KMaxFileName> phantomName;
|
|
47 |
phantomName.Append(_L("\\"));
|
|
48 |
phantomName.Append(_L("PhantomExtended_Replaced.txt"));
|
|
49 |
TInt r = notificationInfo->SetSourceName(phantomName);
|
|
50 |
User::LeaveIfError(r);
|
|
51 |
r = notificationInfo->SetUid(TUid::Uid(KErrUnknown));
|
|
52 |
User::LeaveIfError(r);
|
|
53 |
r = IssueNotification(notificationInfo);
|
|
54 |
User::LeaveIfError(r);
|
|
55 |
CFsNotificationInfo::Free(notificationInfo);
|
|
56 |
return;
|
|
57 |
}
|
|
58 |
else if(aName.Match(_L("\\Extended_RenameMe.txt"))!= KErrNotFound) //\\PhantomExtended_Renamed.txt
|
|
59 |
{
|
|
60 |
CFsNotificationInfo* notificationInfo = CFsNotificationInfo::Allocate(*this,EFsRename);
|
|
61 |
TBuf<KMaxFileName> phantomName;
|
|
62 |
phantomName.Append(_L("\\"));
|
|
63 |
phantomName.Append(_L("PhantomExtended_RenameMe.txt"));
|
|
64 |
TInt r = notificationInfo->SetSourceName(phantomName);
|
|
65 |
User::LeaveIfError(r);
|
|
66 |
TBuf<KMaxFileName> phantomRename;
|
|
67 |
phantomRename.Append(_L("\\"));
|
|
68 |
phantomRename.Append(_L("PhantomExtended_Renamed.txt"));
|
|
69 |
r = notificationInfo->SetNewName(phantomRename);
|
|
70 |
User::LeaveIfError(r);
|
|
71 |
r = notificationInfo->SetUid(TUid::Uid(KErrUnknown));
|
|
72 |
User::LeaveIfError(r);
|
|
73 |
r = IssueNotification(notificationInfo);
|
|
74 |
User::LeaveIfError(r);
|
|
75 |
CFsNotificationInfo::Free(notificationInfo);
|
|
76 |
return;
|
|
77 |
}
|
|
78 |
|
|
79 |
|
|
80 |
}
|
|
81 |
|
|
82 |
void CTestNotificationFileCB::RenameL(const TDesC& /*aNewName*/)
|
|
83 |
{
|
|
84 |
RDebug::Print(_L("CTestNotificationFileCB::RenameL - aName = %S"),iFileName);
|
|
85 |
|
|
86 |
if(iFileName->Match(_L("\\Wellformed_functionReplace.txt"))!= KErrNotFound) //PhantomFile_functionWrite.txt
|
|
87 |
{
|
|
88 |
CFsNotificationInfo* notificationInfo = CFsNotificationInfo::Allocate(Mount(),EFsFileRename);
|
|
89 |
TBuf<KMaxFileName> phantomName;
|
|
90 |
phantomName.Append(_L("\\"));
|
|
91 |
phantomName.Append(_L("PhantomFile_functionReplace.txt"));
|
|
92 |
TInt r = notificationInfo->SetSourceName(phantomName);
|
|
93 |
User::LeaveIfError(r);
|
|
94 |
TBuf<KMaxFileName> phantomNewName;
|
|
95 |
phantomNewName.Append(_L("\\"));
|
|
96 |
phantomNewName.Append(_L("PhantomFile_functionRename.txt"));
|
|
97 |
r = notificationInfo->SetNewName(phantomNewName);
|
|
98 |
User::LeaveIfError(r);
|
|
99 |
r = notificationInfo->SetUid(TUid::Uid(KErrUnknown));
|
|
100 |
User::LeaveIfError(r);
|
|
101 |
r = Mount().IssueNotification(notificationInfo);
|
|
102 |
User::LeaveIfError(r);
|
|
103 |
CFsNotificationInfo::Free(notificationInfo);
|
|
104 |
return;
|
|
105 |
}
|
|
106 |
|
|
107 |
//MALFORMED
|
|
108 |
if(iFileName->Match(_L("\\Malformed_functionWrite.txt"))!=KErrNotFound)
|
|
109 |
{
|
|
110 |
CFsNotificationInfo* notificationInfo = CFsNotificationInfo::Allocate(Mount(),EFsFileRename);
|
|
111 |
TBuf<KMaxFileName> phantomName;
|
|
112 |
phantomName.Append(_L("\\"));
|
|
113 |
phantomName.Append(_L("Malformed_functionWrite.txt"));
|
|
114 |
TInt r = notificationInfo->SetSourceName(phantomName);
|
|
115 |
User::LeaveIfError(r);
|
|
116 |
// Don't set NewName - Should cause error.
|
|
117 |
// SetNewName(phantomNewName);
|
|
118 |
r = notificationInfo->SetUid(TUid::Uid(KErrUnknown));
|
|
119 |
User::LeaveIfError(r);
|
|
120 |
r = Mount().IssueNotification(notificationInfo);
|
|
121 |
User::LeaveIfError(r);
|
|
122 |
CFsNotificationInfo::Free(notificationInfo);
|
|
123 |
return;
|
|
124 |
}
|
|
125 |
}
|
|
126 |
|
|
127 |
void CTestNotificationFileCB::WriteL(TInt /*aPos*/,TInt& /*aLength*/,const TAny* /*aDes*/,const RMessagePtr2& /*aMessage*/)
|
|
128 |
{
|
|
129 |
if(iFileName->Match(_L("\\Wellformed_functionWrite.txt"))!= KErrNotFound) //PhantomFile_functionWrite.txt
|
|
130 |
{
|
|
131 |
RDebug::Printf("CTestNotificationFileCB::WriteL - wellformed_functionWrite.txt");
|
|
132 |
CFsNotificationInfo* notificationInfo = CFsNotificationInfo::Allocate(Mount(),EFsFileWrite);
|
|
133 |
TBuf<KMaxFileName> phantomName;
|
|
134 |
phantomName.Append(_L("\\"));
|
|
135 |
phantomName.Append(_L("PhantomFile_functionWrite.txt"));
|
|
136 |
TInt r = notificationInfo->SetSourceName(phantomName);
|
|
137 |
User::LeaveIfError(r);
|
|
138 |
r = notificationInfo->SetFilesize((TInt64)4);
|
|
139 |
User::LeaveIfError(r);
|
|
140 |
r = notificationInfo->SetUid(TUid::Uid(KErrUnknown));
|
|
141 |
User::LeaveIfError(r);
|
|
142 |
r = Mount().IssueNotification(notificationInfo);
|
|
143 |
User::LeaveIfError(r);
|
|
144 |
CFsNotificationInfo::Free(notificationInfo);
|
|
145 |
return;
|
|
146 |
}
|
|
147 |
|
|
148 |
//MALFORMED
|
|
149 |
if(iFileName->Match(_L("\\Malformed_functionWrite.txt"))!=KErrNotFound)
|
|
150 |
{
|
|
151 |
RDebug::Printf("CTestNotificationFileCB::WriteL - malformed_functionWrite.txt");
|
|
152 |
CFsNotificationInfo* notificationInfo = CFsNotificationInfo::Allocate(Mount(),EFsFileWrite);
|
|
153 |
TBuf<KMaxFileName> phantomName;
|
|
154 |
phantomName.Append(_L("\\"));
|
|
155 |
phantomName.Append(_L("PhantomFileMalformed_functionWrite.txt"));
|
|
156 |
TInt r = notificationInfo->SetSourceName(phantomName);
|
|
157 |
User::LeaveIfError(r);
|
|
158 |
//We won't set filesize - which should result in an error.
|
|
159 |
// SetFilesize((TInt64)4);
|
|
160 |
//
|
|
161 |
r = notificationInfo->SetUid(TUid::Uid(KErrUnknown));
|
|
162 |
User::LeaveIfError(r);
|
|
163 |
r = Mount().IssueNotification(notificationInfo);
|
|
164 |
User::LeaveIfError(r);
|
|
165 |
CFsNotificationInfo::Free(notificationInfo);
|
|
166 |
return;
|
|
167 |
}
|
|
168 |
|
|
169 |
}
|
|
170 |
|
|
171 |
void CTestNotificationFileCB::SetEntryL(const TTime& /*aTime*/,TUint /*aSetAttMask*/,TUint /*aClearAttMask*/)
|
|
172 |
{
|
|
173 |
if(iFileName->Match(_L("\\Wellformed_functionAttributes.txt"))!= KErrNotFound) //PhantomFile_functionWrite.txt
|
|
174 |
{
|
|
175 |
CFsNotificationInfo* notificationInfo = CFsNotificationInfo::Allocate(Mount(),EFsFileSetAtt);
|
|
176 |
TBuf<KMaxFileName> phantomName;
|
|
177 |
phantomName.Append(_L("\\"));
|
|
178 |
phantomName.Append(_L("PhantomFile_functionAttributes.txt"));
|
|
179 |
TInt r = notificationInfo->SetSourceName(phantomName);
|
|
180 |
User::LeaveIfError(r);
|
|
181 |
r = notificationInfo->SetAttributes(KEntryAttSystem,KEntryAttHidden);
|
|
182 |
User::LeaveIfError(r);
|
|
183 |
r = notificationInfo->SetUid(TUid::Uid(KErrUnknown));
|
|
184 |
User::LeaveIfError(r);
|
|
185 |
r = Mount().IssueNotification(notificationInfo);
|
|
186 |
User::LeaveIfError(r);
|
|
187 |
CFsNotificationInfo::Free(notificationInfo);
|
|
188 |
return;
|
|
189 |
}
|
|
190 |
}
|
|
191 |
|
|
192 |
CTestFileSystem::CTestFileSystem()
|
|
193 |
//
|
|
194 |
// Constructor
|
|
195 |
//
|
|
196 |
{
|
|
197 |
__DECLARE_NAME(_S("CNotifyTestFileSystem"));
|
|
198 |
}
|
|
199 |
|
|
200 |
CTestFileSystem::~CTestFileSystem()
|
|
201 |
//
|
|
202 |
// Destructor
|
|
203 |
//
|
|
204 |
{}
|
|
205 |
|
|
206 |
TInt CTestFileSystem::Install()
|
|
207 |
//
|
|
208 |
// Install the file system
|
|
209 |
//
|
|
210 |
{
|
|
211 |
iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KF32BuildVersionNumber);
|
|
212 |
TPtrC name=_L("CNotifyTestFileSystem");
|
|
213 |
return(SetName(&name));
|
|
214 |
}
|
|
215 |
|
|
216 |
CMountCB* CTestFileSystem::NewMountL() const
|
|
217 |
//
|
|
218 |
// Create a new mount control block
|
|
219 |
//
|
|
220 |
{
|
|
221 |
return (new(ELeave) CTestNotificationMountCB);
|
|
222 |
}
|
|
223 |
|
|
224 |
CFileCB* CTestFileSystem::NewFileL() const
|
|
225 |
//
|
|
226 |
// Create a new file
|
|
227 |
//
|
|
228 |
{
|
|
229 |
return (new(ELeave) CTestNotificationFileCB);
|
|
230 |
}
|
|
231 |
|
|
232 |
CDirCB* CTestFileSystem::NewDirL() const
|
|
233 |
//
|
|
234 |
// create a new directory lister
|
|
235 |
//
|
|
236 |
{
|
|
237 |
return (new(ELeave) CTestDirCB);
|
|
238 |
}
|
|
239 |
|
|
240 |
CFormatCB* CTestFileSystem::NewFormatL() const
|
|
241 |
//
|
|
242 |
// Create a new media formatter
|
|
243 |
//
|
|
244 |
{
|
|
245 |
return (new(ELeave) CTestFormatCB);
|
|
246 |
}
|
|
247 |
|
|
248 |
TInt CTestFileSystem::DefaultPath(TDes& aPath) const
|
|
249 |
//
|
|
250 |
// Return the intial default path
|
|
251 |
//
|
|
252 |
{
|
|
253 |
aPath=_L("C:\\");
|
|
254 |
return (KErrNone);
|
|
255 |
}
|
|
256 |
|
|
257 |
|
|
258 |
/**
|
|
259 |
Reports whether the specified interface is supported - if it is,
|
|
260 |
the supplied interface object is modified to it
|
|
261 |
|
|
262 |
@param aInterfaceId The interface of interest
|
|
263 |
@param aInterface The interface object
|
|
264 |
@return KErrNone if the interface is supported, otherwise KErrNotFound
|
|
265 |
|
|
266 |
@see CFileSystem::GetInterface()
|
|
267 |
*/
|
|
268 |
TInt CTestFileSystem::GetInterface(TInt aInterfaceId, TAny*& aInterface,TAny* aInput)
|
|
269 |
{
|
|
270 |
switch(aInterfaceId)
|
|
271 |
{
|
|
272 |
case CFileSystem::EProxyDriveSupport: // The FAT Filesystem supports proxy drives
|
|
273 |
return KErrNone;
|
|
274 |
|
|
275 |
default:
|
|
276 |
return(CFileSystem::GetInterface(aInterfaceId, aInterface, aInput));
|
|
277 |
}
|
|
278 |
}
|
|
279 |
|
|
280 |
CFileSystem* CTestFileSystem::NewL()
|
|
281 |
//
|
|
282 |
//
|
|
283 |
//
|
|
284 |
{
|
|
285 |
CFileSystem* testFSys = new(ELeave) CTestFileSystem;
|
|
286 |
return testFSys;
|
|
287 |
}
|
|
288 |
|
|
289 |
|
|
290 |
CTestNotificationMountCB::CTestNotificationMountCB(){};
|
|
291 |
CTestNotificationMountCB::~CTestNotificationMountCB(){};
|
|
292 |
CTestDirCB::CTestDirCB(){};
|
|
293 |
CTestDirCB::~CTestDirCB(){};
|
|
294 |
CTestNotificationFileCB::CTestNotificationFileCB(){};
|
|
295 |
CTestNotificationFileCB::~CTestNotificationFileCB(){};
|
|
296 |
CTestFormatCB::CTestFormatCB(){};
|
|
297 |
CTestFormatCB::~CTestFormatCB(){};
|
|
298 |
|
|
299 |
|
|
300 |
extern "C" {
|
|
301 |
|
|
302 |
EXPORT_C CFileSystem* CreateFileSystem()
|
|
303 |
//
|
|
304 |
// Create a new file system
|
|
305 |
//
|
|
306 |
{
|
|
307 |
return(CTestFileSystem::NewL());
|
|
308 |
}
|
|
309 |
}
|
|
310 |
|