|
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\fsstress\t_remfsy.h |
|
15 // |
|
16 // |
|
17 |
|
18 #include <e32twin.h> |
|
19 #if !defined(__T_REMFSY_H__) |
|
20 #define __T_REMFSY_H__ |
|
21 #if defined(_UNICODE) |
|
22 #define _WTEXT(c) L ## c |
|
23 #define _STRC LPCWSTR |
|
24 #define _STR LPWSTR |
|
25 #else |
|
26 #define _WTEXT(c) c |
|
27 #define _STRC LPCSTR |
|
28 #define _STR LPSTR |
|
29 #endif |
|
30 |
|
31 #include <f32fsys.h> |
|
32 #include <f32file.h> |
|
33 #include <e32test.h> |
|
34 #include <e32hal.h> |
|
35 #include <e32math.h> |
|
36 #if defined (__DEBUG__)|| defined(_DEBUG_RELEASE) |
|
37 #include <f32dbg.h> |
|
38 #endif |
|
39 |
|
40 |
|
41 // |
|
42 // Common constants used by both EFSRV and the filesystems |
|
43 // |
|
44 |
|
45 const TUint KEntryAttIllegal=(KEntryAttVolume|KEntryAttDir); |
|
46 const TUint KEntryAttModified=0x20000000; |
|
47 const TUint KEntryAttMustBeFile=0x80000000; |
|
48 const TInt KCurrentPosition=KMinTInt; |
|
49 |
|
50 |
|
51 GLDEF_D const TInt KMaxParses=7; |
|
52 GLDEF_D const TInt KHeapSize=0x2000; |
|
53 GLREF_C void TurnAllocFailureOff(); |
|
54 GLREF_C void TurnAllocFailureOn(); |
|
55 GLREF_C void ReportCheckDiskFailure(TInt aRet); |
|
56 GLREF_D RTest test; |
|
57 GLREF_D TFileName gSessionPath; |
|
58 GLREF_D TInt gAllocFailOff; |
|
59 GLREF_D TInt gAllocFailOn; |
|
60 |
|
61 #if defined(_DEBUG) |
|
62 #define SetAllocFailure(a) SetAllocFailure(a) |
|
63 #else |
|
64 #define SetAllocFailure(a) IsRomAddress(NULL) |
|
65 #define KAllocFailureOn 0 |
|
66 #define KAllocFailureOff 0 |
|
67 #endif |
|
68 |
|
69 |
|
70 enum TPanic |
|
71 { |
|
72 EFileTimeToSystemTime, |
|
73 EFileClose, |
|
74 EFileCloseSetAttributes, |
|
75 EDirClose, |
|
76 EMapCouldNotConnect |
|
77 }; |
|
78 |
|
79 |
|
80 class CSessionFs; |
|
81 |
|
82 class CRemoteMountCB : public CMountCB |
|
83 { |
|
84 public: |
|
85 CRemoteMountCB(); |
|
86 ~CRemoteMountCB(); |
|
87 void MountL(TBool aForceMount); |
|
88 TInt ReMount(); |
|
89 void Dismounted(); |
|
90 void VolumeL(TVolumeInfo& aVolume) const; |
|
91 void SetVolumeL(TDes& aName); |
|
92 void MkDirL(const TDesC& aName); |
|
93 void RmDirL(const TDesC& aName); |
|
94 void DeleteL(const TDesC& aName); |
|
95 void RenameL(const TDesC& anOldName,const TDesC& anNewName); |
|
96 void ReplaceL(const TDesC& anOldName,const TDesC& anNewName); |
|
97 void EntryL(const TDesC& aName,TEntry& anEntry) const; |
|
98 void SetEntryL(const TDesC& aName,const TTime& aTime,TUint aSetAttMask,TUint aClearAttMask); |
|
99 void FileOpenL(const TDesC& aName,TUint aMode,TFileOpen anOpen,CFileCB* aFile); |
|
100 void DirOpenL(const TDesC& aName,CDirCB* aDir); |
|
101 void RawReadL(TInt64 aPos,TInt aLength,const TAny* aTrg,TInt anOffset,const RMessagePtr2& aMessage) const; |
|
102 void RawWriteL(TInt64 aPos,TInt aLength,const TAny* aSrc,TInt anOffset,const RMessagePtr2& aMessage); |
|
103 void ReadUidL(const TDesC& aName,TEntry& anEntry) const; |
|
104 void GetShortNameL(const TDesC& aLongName,TDes& aShortName); |
|
105 void GetLongNameL(const TDesC& aShortName,TDes& aLongName); |
|
106 void IsFileInRom(const TDesC& aFileName,TUint8*& aFileStart); |
|
107 void ReadSectionL(const TDesC& aName,TInt aPos,TAny* aTrg,TInt aLength,const RMessagePtr2& aMessage); |
|
108 private: |
|
109 TBool IsRomDrive() const; |
|
110 }; |
|
111 |
|
112 |
|
113 class RConsole; |
|
114 class CRemoteFileCB : public CFileCB |
|
115 { |
|
116 public: |
|
117 CRemoteFileCB(); |
|
118 ~CRemoteFileCB(); |
|
119 void RenameL(const TDesC& aNewName); |
|
120 void ReadL(TInt aPos,TInt& aLength,const TAny* aDes,const RMessagePtr2& aMessage); |
|
121 void WriteL(TInt aPos,TInt& aLength,const TAny* aDes,const RMessagePtr2& aMessage); |
|
122 TInt Address(TInt& aPos) const; |
|
123 void SetSizeL(TInt aSize); |
|
124 void SetEntryL(const TTime& aTime,TUint aSetAttMask,TUint aClearAttMask); |
|
125 void FlushDataL(); |
|
126 void FlushAllL(); |
|
127 // inline void SetHandle(HANDLE aHandle) {iWinHandle=aHandle;} |
|
128 void CheckPos(TInt aPos); |
|
129 private: |
|
130 TBool IsRomDrive() const; |
|
131 private: |
|
132 TInt iCurrentPos; |
|
133 TUint8* iFilePtr; |
|
134 RConsole iConsole; |
|
135 // HANDLE iWinHandle; |
|
136 }; |
|
137 |
|
138 class CRemoteDirCB : public CDirCB |
|
139 { |
|
140 public: |
|
141 CRemoteDirCB(/*CSessionFs* aSession*/); |
|
142 ~CRemoteDirCB(); |
|
143 void ReadL(TEntry& anEntry); |
|
144 // inline void SetHandle(HANDLE aHandle) {iWinHandle=aHandle;} |
|
145 inline void SetFullName(const TDesC& aName) {iFullName.Set(aName,NULL,NULL);} |
|
146 private: |
|
147 TBool MatchUid(); |
|
148 public: |
|
149 TEntry iEntry; |
|
150 private: |
|
151 // HANDLE iWinHandle; |
|
152 TParse iFullName; |
|
153 }; |
|
154 |
|
155 class CRemoteFormatCB : public CFormatCB |
|
156 { |
|
157 public: |
|
158 CRemoteFormatCB(/*CSessionFs* aSession*/); |
|
159 ~CRemoteFormatCB(); |
|
160 public: |
|
161 virtual void DoFormatStepL(); |
|
162 }; |
|
163 |
|
164 class CRemote : public CFileSystem |
|
165 { |
|
166 public: |
|
167 CRemote(); |
|
168 TInt Install(); |
|
169 TInt DefaultPath(TDes& aPath) const; |
|
170 void DriveInfo(TDriveInfo& anInfo,TInt aDriveNumber) const; |
|
171 private: |
|
172 CMountCB* NewMountL() const; // These were not previously implemented |
|
173 CFileCB* NewFileL() const; // They are essential for a CRemote |
|
174 CDirCB* NewDirL() const; // object to be instantiated because they are |
|
175 CFormatCB* NewFormatL() const; // pure virtual in CFileSystem |
|
176 public: |
|
177 static CFileSystem* NewL(); |
|
178 }; |
|
179 |
|
180 struct SParse |
|
181 { |
|
182 const TText* src; |
|
183 const TText* rel; |
|
184 const TText* def; |
|
185 const TText* fullName; |
|
186 const TText* drive; |
|
187 const TText* path; |
|
188 const TText* name; |
|
189 const TText* ext; |
|
190 }; |
|
191 |
|
192 struct SParseServer |
|
193 { |
|
194 const TText* src; |
|
195 const TText* rel; |
|
196 const TText* fullName; |
|
197 const TText* drive; |
|
198 const TText* path; |
|
199 const TText* name; |
|
200 const TText* ext; |
|
201 }; |
|
202 |
|
203 |
|
204 class TMultipleSessionTest |
|
205 { |
|
206 public: |
|
207 TMultipleSessionTest() {}; |
|
208 TMultipleSessionTest(RFs& aFs): iFs(aFs){}; |
|
209 void Initialise(RFs& aFs); |
|
210 void RunTests(RTest& aTest); |
|
211 void testDriveList(RTest& aTest); |
|
212 void testDriveInfo(RTest& aTest); |
|
213 void testVolumeInfo(RTest& aTest); |
|
214 void testPath(RTest& aTest); |
|
215 void testInitialisation(RTest& aTest); |
|
216 void testSubst(RTest& aTest); |
|
217 void CopyFileToTestDirectory(RTest& aTest); |
|
218 void MakeAndDeleteFiles(RTest& aTest); |
|
219 void FillUpDisk(RTest& aTest); |
|
220 void testSetVolume(RTest& aTest); |
|
221 // void testPowerDown(RTest& aTest); |
|
222 // void testMediaChange(RTest& aTest); |
|
223 void DeleteTestDirectory(RTest& aTest); |
|
224 TInt CurrentDrive(RTest& aTest); |
|
225 void SetSessionPath(TInt aDrive); |
|
226 private: |
|
227 RFs iFs; |
|
228 TBuf<30> iSessionPath; |
|
229 }; |
|
230 |
|
231 |
|
232 // |
|
233 // WINS - dependent functions |
|
234 // |
|
235 |
|
236 GLREF_D const TFileName ZPath; |
|
237 |
|
238 GLREF_C TBool GetEnvValue(TInt aDrive,TDes& aDes); |
|
239 GLREF_C TBool MapDrive(TDes& aFileName,TInt aDrive); |
|
240 GLREF_C TBool MapDriveInfo(TDriveInfo& anInfo,TInt aDrive); |
|
241 GLREF_C TBool MapDriveAttributes(TUint& aDriveAtt,TInt aDrive); |
|
242 GLREF_C void CheckAppendL(TDes& aFileName,const TDesC& aName); |
|
243 #endif |
|
244 |
|
245 |