|
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 // Contains all of the delay filesystem classes. |
|
15 // |
|
16 |
|
17 //! @file f32test\concur\cfafsdly.h |
|
18 |
|
19 #ifndef __CFAFSDLY_H__ |
|
20 #define __CFAFSDLY_H__ |
|
21 |
|
22 #include <f32file.h> |
|
23 #include "common.h" |
|
24 #include <f32fsys.h> |
|
25 #include <f32ver.h> |
|
26 #include <f32dbg.h> |
|
27 #include <e32svr.h> |
|
28 |
|
29 const TInt KMaxFiles = 10; ///< Maximum number of files in the filesystem |
|
30 const TInt KMaxFileLen = 8192; ///< Maximum length of an individual file |
|
31 |
|
32 class TTestFile |
|
33 /// Describe a file, including the data. |
|
34 { |
|
35 public: |
|
36 TTestFile(); |
|
37 void Entry(TEntry& aEntry) const; |
|
38 public: |
|
39 TFileName iName; ///< name of the file. |
|
40 TUint8 iData[KMaxFileLen]; ///< data in the file (fixed maximum length). |
|
41 TInt iSize; ///< current size of the file (length of data). |
|
42 TTime iTime; ///< timestamp of last modification. |
|
43 }; |
|
44 |
|
45 class TTestDir |
|
46 /// Holds the directory for the filesystem (there is only one!), including all |
|
47 /// of the files with their data. Only practical for a simple test system. |
|
48 { |
|
49 public: |
|
50 TTestDir(); |
|
51 TTestFile* Create(const TDesC& aName); |
|
52 TTestFile* Find(const TDesC& aName); |
|
53 const TTestFile* Find(const TDesC& aName) const; |
|
54 void Delete(const TDesC& aName); |
|
55 TTestFile* Entry(TInt aIndex); |
|
56 private: |
|
57 TTestFile iFile[KMaxFiles]; ///< All of the file data. |
|
58 }; |
|
59 |
|
60 class CTestMountCB : public CMountCB |
|
61 /// Data and functions associated with a mounted filesystem. It is allocated |
|
62 /// by the file server when the filesystem is mounted and destroyed when it is |
|
63 /// unmounted (hence losing all of the data in files in this case). |
|
64 { |
|
65 public: |
|
66 CTestMountCB(); |
|
67 ~CTestMountCB(); |
|
68 void MountL(TBool aForceMount); |
|
69 TInt ReMount(); |
|
70 void Dismounted(); |
|
71 void VolumeL(TVolumeInfo& aVolume) const; |
|
72 void SetVolumeL(TDes& aName); |
|
73 void MkDirL(const TDesC& aName); |
|
74 void RmDirL(const TDesC& aName); |
|
75 void DeleteL(const TDesC& aName); |
|
76 void RenameL(const TDesC& anOldName,const TDesC& anNewName); |
|
77 void ReplaceL(const TDesC& anOldName,const TDesC& anNewName); |
|
78 void EntryL(const TDesC& aName,TEntry& anEntry) const; |
|
79 void SetEntryL(const TDesC& aName,const TTime& aTime,TUint aSetAttMask,TUint learAttMask); |
|
80 void FileOpenL(const TDesC& aName,TUint aMode,TFileOpen anOpen,CFileCB* aFile); |
|
81 void DirOpenL(const TDesC& aName,CDirCB* aDir); |
|
82 void RawReadL(TInt64 aPos,TInt aLength,const TAny* aDes,TInt anOffset,const RMessagePtr2& aMessage) const; |
|
83 void RawWriteL(TInt64 aPos,TInt aLength,const TAny* aDes,TInt anOffset,const RMessagePtr2& aMessage); |
|
84 void ReadUidL(const TDesC& aName,TEntry& anEntry) const; |
|
85 void GetShortNameL(const TDesC& aLongName,TDes& aShortName); |
|
86 void GetLongNameL(const TDesC& aShortName,TDes& aLongName); |
|
87 void IsFileInRom(const TDesC& aFileName,TUint8*& aFileStart); |
|
88 void ReadSectionL(const TDesC& aName,TInt aPos,TAny* aTrg,TInt aLength,const RMessagePtr2& aMessage); |
|
89 private: |
|
90 TTestDir iDir; ///< The directory information, including all files and their data. |
|
91 }; |
|
92 |
|
93 |
|
94 |
|
95 class CTestFileCB : public CFileCB |
|
96 /// Data about a specific open file. |
|
97 { |
|
98 public: |
|
99 CTestFileCB(); |
|
100 ~CTestFileCB(); |
|
101 void RenameL(const TDesC& aNewName); |
|
102 void ReadL(TInt aPos,TInt& aLength,const TAny* aDes,const RMessagePtr2& aMessage); |
|
103 void WriteL(TInt aPos,TInt& aLength,const TAny* aDes,const RMessagePtr2& aMessage); |
|
104 TInt Address(TInt& aPos) const; |
|
105 void SetSizeL(TInt aSize); |
|
106 void SetEntryL(const TTime& aTime,TUint aSetAttMask,TUint aClearAttMask); |
|
107 void FlushDataL(); |
|
108 void FlushAllL(); |
|
109 void CheckPos(TInt aPos); |
|
110 |
|
111 public: |
|
112 TUint8 iPadding[128]; // in case we're passed a CFATFileCB |
|
113 TTestFile* iFile; ///< Points to the file structure of the open file. |
|
114 TUint8* iData; ///< Points to the data area of the file. |
|
115 }; |
|
116 |
|
117 class CTestDirCB : public CDirCB |
|
118 /// Data for accessing a directory for search etc. |
|
119 { |
|
120 public: |
|
121 CTestDirCB(); |
|
122 ~CTestDirCB(); |
|
123 void ReadL(TEntry& anEntry); |
|
124 |
|
125 public: |
|
126 TFileName iName; ///< Name of the current file. |
|
127 TTestDir* iDir; ///< Pointer to the directory data. |
|
128 TInt iIndex; ///< Current position in the directory. |
|
129 }; |
|
130 |
|
131 class CTestFormatCB : public CFormatCB |
|
132 /// Functions for formatting the filesystem. Not used. |
|
133 { |
|
134 public: |
|
135 CTestFormatCB(); |
|
136 ~CTestFormatCB(); |
|
137 void DoFormatStepL(); |
|
138 }; |
|
139 |
|
140 class CTestFileSystem : public CFileSystem |
|
141 /// Describes the filesysem, and creates a new one when it is mounted. |
|
142 { |
|
143 public: |
|
144 CTestFileSystem(); |
|
145 ~CTestFileSystem(); |
|
146 TInt Install(); |
|
147 TInt DefaultPath(TDes& aPath) const; |
|
148 void DriveInfo(TDriveInfo& anInfo, TInt aDriveNumber) const; |
|
149 TBusLocalDrive& DriveNumberToLocalDrive(TInt aDriveNumber); |
|
150 TInt GetInterface(TInt aInterfaceId, TAny*& aInterface,TAny* aInput); |
|
151 private: |
|
152 CMountCB* NewMountL() const; |
|
153 CFileCB* NewFileL() const; |
|
154 CDirCB* NewDirL() const; |
|
155 CFormatCB* NewFormatL() const; |
|
156 public: |
|
157 static CFileSystem* NewL(); |
|
158 }; |
|
159 |
|
160 #endif |