|
1 // Copyright (c) 2006-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_tfsys2.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include "t_tfsys2.h" |
|
19 |
|
20 |
|
21 const TInt KMajorVersionNumber=1; |
|
22 const TInt KMinorVersionNumber=0; |
|
23 |
|
24 //TInt gMountAttempts = 0; |
|
25 |
|
26 CTestFileSystem::CTestFileSystem() |
|
27 // |
|
28 // Constructor |
|
29 // |
|
30 { |
|
31 __DECLARE_NAME(_S("CTestFileSystem2")); |
|
32 } |
|
33 |
|
34 CTestFileSystem::~CTestFileSystem() |
|
35 // |
|
36 // Destructor |
|
37 // |
|
38 {} |
|
39 |
|
40 TInt CTestFileSystem::Install() |
|
41 // |
|
42 // Install the file system |
|
43 // |
|
44 { |
|
45 iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KF32BuildVersionNumber); |
|
46 TPtrC name=_L("Test2"); |
|
47 return(SetName(&name)); |
|
48 } |
|
49 |
|
50 CMountCB* CTestFileSystem::NewMountL() const |
|
51 // |
|
52 // Create a new mount control block |
|
53 // |
|
54 { |
|
55 CTestMountCB* mount = new(ELeave) CTestMountCB; |
|
56 mount->SetFsy(this); |
|
57 return mount; |
|
58 } |
|
59 |
|
60 CFileCB* CTestFileSystem::NewFileL() const |
|
61 // |
|
62 // Create a new file |
|
63 // |
|
64 { |
|
65 return (new(ELeave) CTestFileCB); |
|
66 } |
|
67 |
|
68 CDirCB* CTestFileSystem::NewDirL() const |
|
69 // |
|
70 // create a new directory lister |
|
71 // |
|
72 { |
|
73 return (new(ELeave) CTestDirCB); |
|
74 } |
|
75 |
|
76 CFormatCB* CTestFileSystem::NewFormatL() const |
|
77 // |
|
78 // Create a new media formatter |
|
79 // |
|
80 { |
|
81 return (new(ELeave) CTestFormatCB); |
|
82 } |
|
83 |
|
84 TInt CTestFileSystem::DefaultPath(TDes& aPath) const |
|
85 // |
|
86 // Return the intial default path |
|
87 // |
|
88 { |
|
89 aPath=_L("C:\\"); |
|
90 return (KErrNone); |
|
91 } |
|
92 |
|
93 void CTestFileSystem::DriveInfo(TDriveInfo& anInfo,TInt aDriveNumber) const |
|
94 // |
|
95 // Return drive info - iDriveAtt and iBatteryState are already set |
|
96 // |
|
97 { |
|
98 if(!IsValidLocalDriveMapping(aDriveNumber)) |
|
99 return; |
|
100 |
|
101 TLocalDriveCapsV2Buf localDriveCaps; |
|
102 |
|
103 // is the drive local? |
|
104 if (!IsProxyDrive(aDriveNumber)) |
|
105 { |
|
106 // if not valid local drive, use default values in localDriveCaps |
|
107 // if valid local drive and not locked, use TBusLocalDrive::Caps() values |
|
108 // if valid drive and locked, hard-code attributes |
|
109 (void)GetLocalDrive(aDriveNumber).Caps(localDriveCaps); |
|
110 } |
|
111 else // this need to be made a bit nicer |
|
112 { |
|
113 CExtProxyDrive* pD = GetProxyDrive(aDriveNumber); |
|
114 if(pD) |
|
115 { |
|
116 (void)pD->Caps(localDriveCaps); |
|
117 } |
|
118 } |
|
119 |
|
120 anInfo.iMediaAtt=localDriveCaps().iMediaAtt; |
|
121 anInfo.iType=localDriveCaps().iType; |
|
122 anInfo.iDriveAtt=localDriveCaps().iDriveAtt; |
|
123 |
|
124 // hijack the iBattery member to report back the number of times MountL() has been called |
|
125 anInfo.iBattery = (TBatteryState) iMountAttempts; |
|
126 } |
|
127 |
|
128 /** |
|
129 Reports whether the specified interface is supported - if it is, |
|
130 the supplied interface object is modified to it |
|
131 |
|
132 @param aInterfaceId The interface of interest |
|
133 @param aInterface The interface object |
|
134 @return KErrNone if the interface is supported, otherwise KErrNotFound |
|
135 |
|
136 @see CFileSystem::GetInterface() |
|
137 */ |
|
138 TInt CTestFileSystem::GetInterface(TInt aInterfaceId, TAny*& aInterface,TAny* aInput) |
|
139 { |
|
140 switch(aInterfaceId) |
|
141 { |
|
142 case CFileSystem::EProxyDriveSupport: // The FAT Filesystem supports proxy drives |
|
143 return KErrNone; |
|
144 |
|
145 default: |
|
146 return(CFileSystem::GetInterface(aInterfaceId, aInterface, aInput)); |
|
147 } |
|
148 } |
|
149 |
|
150 CFileSystem* CTestFileSystem::NewL() |
|
151 // |
|
152 // |
|
153 // |
|
154 { |
|
155 CFileSystem* testFSys = new(ELeave) CTestFileSystem; |
|
156 return testFSys; |
|
157 } |
|
158 |
|
159 |
|
160 CTestMountCB::CTestMountCB() : iFileSystem(NULL) |
|
161 { |
|
162 }; |
|
163 |
|
164 CTestMountCB::~CTestMountCB(){}; |
|
165 CTestDirCB::CTestDirCB(){}; |
|
166 CTestDirCB::~CTestDirCB(){}; |
|
167 CTestFileCB::CTestFileCB(){}; |
|
168 CTestFileCB::~CTestFileCB(){}; |
|
169 CTestFormatCB::CTestFormatCB(){}; |
|
170 CTestFormatCB::~CTestFormatCB(){}; |
|
171 void CTestMountCB::MountL(TBool /*aForceMount*/) |
|
172 { |
|
173 if (iFileSystem) |
|
174 iFileSystem->iMountAttempts++; |
|
175 |
|
176 User::Leave(KErrCorrupt); |
|
177 } |
|
178 |
|
179 void CTestMountCB::EntryL(const TDesC& /*aName*/,TEntry& /*anEntry*/) const |
|
180 { |
|
181 User::Leave(KErrNotFound); |
|
182 } |
|
183 |
|
184 TInt CTestMountCB::ForceRemountDrive(const TDesC8* /*aMountInfo*/,TInt /*aMountInfoMessageHandle*/,TUint /*aFlags*/) |
|
185 { |
|
186 Drive().SetChanged(ETrue); |
|
187 return(KErrNone); |
|
188 } |
|
189 |
|
190 void CTestMountCB::SetFsy(const CTestFileSystem* aFileSystem) |
|
191 { |
|
192 iFileSystem = const_cast<CTestFileSystem*> (aFileSystem); |
|
193 } |
|
194 |
|
195 extern "C" { |
|
196 |
|
197 EXPORT_C CFileSystem* CreateFileSystem() |
|
198 // |
|
199 // Create a new file system |
|
200 // |
|
201 { |
|
202 return(CTestFileSystem::NewL()); |
|
203 } |
|
204 } |
|
205 |