sl@0
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// f32test\testfsys\t_tfsys2.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include "t_tfsys2.h"
|
sl@0
|
19 |
|
sl@0
|
20 |
|
sl@0
|
21 |
const TInt KMajorVersionNumber=1;
|
sl@0
|
22 |
const TInt KMinorVersionNumber=0;
|
sl@0
|
23 |
|
sl@0
|
24 |
//TInt gMountAttempts = 0;
|
sl@0
|
25 |
|
sl@0
|
26 |
CTestFileSystem::CTestFileSystem()
|
sl@0
|
27 |
//
|
sl@0
|
28 |
// Constructor
|
sl@0
|
29 |
//
|
sl@0
|
30 |
{
|
sl@0
|
31 |
__DECLARE_NAME(_S("CTestFileSystem2"));
|
sl@0
|
32 |
}
|
sl@0
|
33 |
|
sl@0
|
34 |
CTestFileSystem::~CTestFileSystem()
|
sl@0
|
35 |
//
|
sl@0
|
36 |
// Destructor
|
sl@0
|
37 |
//
|
sl@0
|
38 |
{}
|
sl@0
|
39 |
|
sl@0
|
40 |
TInt CTestFileSystem::Install()
|
sl@0
|
41 |
//
|
sl@0
|
42 |
// Install the file system
|
sl@0
|
43 |
//
|
sl@0
|
44 |
{
|
sl@0
|
45 |
iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KF32BuildVersionNumber);
|
sl@0
|
46 |
TPtrC name=_L("Test2");
|
sl@0
|
47 |
return(SetName(&name));
|
sl@0
|
48 |
}
|
sl@0
|
49 |
|
sl@0
|
50 |
CMountCB* CTestFileSystem::NewMountL() const
|
sl@0
|
51 |
//
|
sl@0
|
52 |
// Create a new mount control block
|
sl@0
|
53 |
//
|
sl@0
|
54 |
{
|
sl@0
|
55 |
CTestMountCB* mount = new(ELeave) CTestMountCB;
|
sl@0
|
56 |
mount->SetFsy(this);
|
sl@0
|
57 |
return mount;
|
sl@0
|
58 |
}
|
sl@0
|
59 |
|
sl@0
|
60 |
CFileCB* CTestFileSystem::NewFileL() const
|
sl@0
|
61 |
//
|
sl@0
|
62 |
// Create a new file
|
sl@0
|
63 |
//
|
sl@0
|
64 |
{
|
sl@0
|
65 |
return (new(ELeave) CTestFileCB);
|
sl@0
|
66 |
}
|
sl@0
|
67 |
|
sl@0
|
68 |
CDirCB* CTestFileSystem::NewDirL() const
|
sl@0
|
69 |
//
|
sl@0
|
70 |
// create a new directory lister
|
sl@0
|
71 |
//
|
sl@0
|
72 |
{
|
sl@0
|
73 |
return (new(ELeave) CTestDirCB);
|
sl@0
|
74 |
}
|
sl@0
|
75 |
|
sl@0
|
76 |
CFormatCB* CTestFileSystem::NewFormatL() const
|
sl@0
|
77 |
//
|
sl@0
|
78 |
// Create a new media formatter
|
sl@0
|
79 |
//
|
sl@0
|
80 |
{
|
sl@0
|
81 |
return (new(ELeave) CTestFormatCB);
|
sl@0
|
82 |
}
|
sl@0
|
83 |
|
sl@0
|
84 |
TInt CTestFileSystem::DefaultPath(TDes& aPath) const
|
sl@0
|
85 |
//
|
sl@0
|
86 |
// Return the intial default path
|
sl@0
|
87 |
//
|
sl@0
|
88 |
{
|
sl@0
|
89 |
aPath=_L("C:\\");
|
sl@0
|
90 |
return (KErrNone);
|
sl@0
|
91 |
}
|
sl@0
|
92 |
|
sl@0
|
93 |
void CTestFileSystem::DriveInfo(TDriveInfo& anInfo,TInt aDriveNumber) const
|
sl@0
|
94 |
//
|
sl@0
|
95 |
// Return drive info
|
sl@0
|
96 |
//
|
sl@0
|
97 |
{
|
sl@0
|
98 |
CFileSystem::DriveInfo(anInfo, aDriveNumber);
|
sl@0
|
99 |
|
sl@0
|
100 |
// hijack the iBattery member to report back the number of times MountL() has been called
|
sl@0
|
101 |
anInfo.iBattery = (TBatteryState) iMountAttempts;
|
sl@0
|
102 |
}
|
sl@0
|
103 |
|
sl@0
|
104 |
/**
|
sl@0
|
105 |
Reports whether the specified interface is supported - if it is,
|
sl@0
|
106 |
the supplied interface object is modified to it
|
sl@0
|
107 |
|
sl@0
|
108 |
@param aInterfaceId The interface of interest
|
sl@0
|
109 |
@param aInterface The interface object
|
sl@0
|
110 |
@return KErrNone if the interface is supported, otherwise KErrNotFound
|
sl@0
|
111 |
|
sl@0
|
112 |
@see CFileSystem::GetInterface()
|
sl@0
|
113 |
*/
|
sl@0
|
114 |
TInt CTestFileSystem::GetInterface(TInt aInterfaceId, TAny*& aInterface,TAny* aInput)
|
sl@0
|
115 |
{
|
sl@0
|
116 |
switch(aInterfaceId)
|
sl@0
|
117 |
{
|
sl@0
|
118 |
case CFileSystem::EProxyDriveSupport: // The FAT Filesystem supports proxy drives
|
sl@0
|
119 |
return KErrNone;
|
sl@0
|
120 |
|
sl@0
|
121 |
default:
|
sl@0
|
122 |
return(CFileSystem::GetInterface(aInterfaceId, aInterface, aInput));
|
sl@0
|
123 |
}
|
sl@0
|
124 |
}
|
sl@0
|
125 |
|
sl@0
|
126 |
CFileSystem* CTestFileSystem::NewL()
|
sl@0
|
127 |
//
|
sl@0
|
128 |
//
|
sl@0
|
129 |
//
|
sl@0
|
130 |
{
|
sl@0
|
131 |
CFileSystem* testFSys = new(ELeave) CTestFileSystem;
|
sl@0
|
132 |
return testFSys;
|
sl@0
|
133 |
}
|
sl@0
|
134 |
|
sl@0
|
135 |
|
sl@0
|
136 |
CTestMountCB::CTestMountCB() : iFileSystem(NULL)
|
sl@0
|
137 |
{
|
sl@0
|
138 |
};
|
sl@0
|
139 |
|
sl@0
|
140 |
CTestMountCB::~CTestMountCB(){};
|
sl@0
|
141 |
CTestDirCB::CTestDirCB(){};
|
sl@0
|
142 |
CTestDirCB::~CTestDirCB(){};
|
sl@0
|
143 |
CTestFileCB::CTestFileCB(){};
|
sl@0
|
144 |
CTestFileCB::~CTestFileCB(){};
|
sl@0
|
145 |
CTestFormatCB::CTestFormatCB(){};
|
sl@0
|
146 |
CTestFormatCB::~CTestFormatCB(){};
|
sl@0
|
147 |
void CTestMountCB::MountL(TBool /*aForceMount*/)
|
sl@0
|
148 |
{
|
sl@0
|
149 |
if (iFileSystem)
|
sl@0
|
150 |
iFileSystem->iMountAttempts++;
|
sl@0
|
151 |
|
sl@0
|
152 |
User::Leave(KErrCorrupt);
|
sl@0
|
153 |
}
|
sl@0
|
154 |
|
sl@0
|
155 |
void CTestMountCB::EntryL(const TDesC& /*aName*/,TEntry& /*anEntry*/) const
|
sl@0
|
156 |
{
|
sl@0
|
157 |
User::Leave(KErrNotFound);
|
sl@0
|
158 |
}
|
sl@0
|
159 |
|
sl@0
|
160 |
TInt CTestMountCB::ForceRemountDrive(const TDesC8* /*aMountInfo*/,TInt /*aMountInfoMessageHandle*/,TUint /*aFlags*/)
|
sl@0
|
161 |
{
|
sl@0
|
162 |
Drive().SetChanged(ETrue);
|
sl@0
|
163 |
return(KErrNone);
|
sl@0
|
164 |
}
|
sl@0
|
165 |
|
sl@0
|
166 |
void CTestMountCB::SetFsy(const CTestFileSystem* aFileSystem)
|
sl@0
|
167 |
{
|
sl@0
|
168 |
iFileSystem = const_cast<CTestFileSystem*> (aFileSystem);
|
sl@0
|
169 |
}
|
sl@0
|
170 |
|
sl@0
|
171 |
extern "C" {
|
sl@0
|
172 |
|
sl@0
|
173 |
EXPORT_C CFileSystem* CreateFileSystem()
|
sl@0
|
174 |
//
|
sl@0
|
175 |
// Create a new file system
|
sl@0
|
176 |
//
|
sl@0
|
177 |
{
|
sl@0
|
178 |
return(CTestFileSystem::NewL());
|
sl@0
|
179 |
}
|
sl@0
|
180 |
}
|
sl@0
|
181 |
|