|
1 // Copyright (c) 2003-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 // |
|
15 |
|
16 #include "common.h" |
|
17 #include <f32fsys.h> |
|
18 #include <f32ver.h> |
|
19 #include <f32dbg.h> |
|
20 |
|
21 IMPORT_C TUint32 DebugRegister(); |
|
22 #if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
23 #define __PRINT(t) {if (DebugRegister()&KCOMPFS) RDebug::Print(t);} |
|
24 #define __PRINT1(t,a) {if (DebugRegister()&KCOMPFS) RDebug::Print(t,a);} |
|
25 #define __PRINT2(t,a,b) {if (DebugRegister()&KCOMPFS) RDebug::Print(t,a,b);} |
|
26 #define __PRINT3(t,a,b,c) {if (DebugRegister()&KCOMPFS) RDebug::Print(t,a,b,c);} |
|
27 #define __PRINT4(t,a,b,c,d) {if (DebugRegister()&KCOMPFS) RDebug::Print(t,a,b,c,d);} |
|
28 #else |
|
29 #define __PRINT(t) |
|
30 #define __PRINT1(t,a) |
|
31 #define __PRINT2(t,a,b) |
|
32 #define __PRINT3(t,a,b,c) |
|
33 #define __PRINT4(t,a,b,c,d) |
|
34 #endif |
|
35 |
|
36 |
|
37 enum TCompFault |
|
38 { |
|
39 ECompMountRemount, |
|
40 ECompDirReadPending, |
|
41 ECompFsDefaultPath, |
|
42 ECompDirStoreLongEntryNameL, |
|
43 }; |
|
44 |
|
45 class TCompMount |
|
46 { |
|
47 public: |
|
48 inline TCompMount(CFileSystem* aFs, CMountCB* aMount); |
|
49 |
|
50 CFileSystem* iFs; |
|
51 CMountCB* iMount; |
|
52 }; |
|
53 |
|
54 |
|
55 // CCompMountCB |
|
56 |
|
57 class CDirCB; |
|
58 class CCompFileSystem; |
|
59 class CCompMountCB : public CMountCB, public CMountCB::MFileAccessor |
|
60 { |
|
61 public: |
|
62 void MountL(TBool aForceMount); |
|
63 TInt ReMount(); |
|
64 void Dismounted(); |
|
65 void VolumeL(TVolumeInfo& aVolume) const; |
|
66 void SetVolumeL(TDes& aName); |
|
67 void MkDirL(const TDesC& aName); |
|
68 void RmDirL(const TDesC& aName); |
|
69 void DeleteL(const TDesC& aName); |
|
70 void RenameL(const TDesC& anOldName,const TDesC& anNewName); |
|
71 void ReplaceL(const TDesC& anOldName,const TDesC& anNewName); |
|
72 void EntryL(const TDesC& aName,TEntry& anEntry) const; |
|
73 void SetEntryL(const TDesC& aName,const TTime& aTime,TUint aSetAttMask,TUint aClearAttMask); |
|
74 void FileOpenL(const TDesC& aName,TUint aMode,TFileOpen anOpen,CFileCB* aFile); |
|
75 void DirOpenL(const TDesC& aName,CDirCB* aDir); |
|
76 void RawReadL(TInt64 aPos,TInt aLength,const TAny* aTrg,TInt anOffset,const RMessagePtr2& aMessage) const; |
|
77 void RawWriteL(TInt64 aPos,TInt aLength,const TAny* aSrc,TInt anOffset,const RMessagePtr2& aMessage); |
|
78 void GetShortNameL(const TDesC& aLongName,TDes& aShortName); |
|
79 void GetLongNameL(const TDesC& aShortName,TDes& aLongName); |
|
80 void IsFileInRom(const TDesC& aFileName,TUint8*& aFileStart); |
|
81 void ReadSectionL(const TDesC& aName,TInt aPos,TAny* aTrg,TInt aLength,const RMessagePtr2& aMessage); |
|
82 |
|
83 inline void SetMountNumber(TInt aNum); |
|
84 |
|
85 virtual TInt GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput); |
|
86 virtual TInt GetFileUniqueId(const TDesC& aName, TInt64& aUniqueId); |
|
87 virtual TInt Spare3(TInt aVal, TAny* aPtr1, TAny* aPtr2); |
|
88 virtual TInt Spare2(TInt aVal, TAny* aPtr1, TAny* aPtr2); |
|
89 virtual TInt Spare1(TInt aVal, TAny* aPtr1, TAny* aPtr2); |
|
90 |
|
91 private: |
|
92 CCompMountCB(CCompFileSystem * aOwner) {iFileSystem=aOwner;} |
|
93 ~CCompMountCB(); |
|
94 |
|
95 inline CMountCB* RomMount() const; |
|
96 inline void NullCompFileSystem(void); |
|
97 void NewRomMountL(); |
|
98 // TInt GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput); |
|
99 TInt AddFsToCompositeMount(CFileSystem* aFileSystem); |
|
100 |
|
101 TInt64 iSize; |
|
102 CCompFileSystem * iFileSystem; |
|
103 protected: |
|
104 RArray<TCompMount> iMounts; |
|
105 |
|
106 friend class CCompFileSystem; |
|
107 friend class CCompDirCB; |
|
108 }; |
|
109 |
|
110 |
|
111 // CCompDirCB |
|
112 |
|
113 class CCompDirCB : public CDirCB |
|
114 { |
|
115 public: |
|
116 void ReadL(TEntry& anEntry); |
|
117 void StoreLongEntryNameL(const TDesC& aName); |
|
118 |
|
119 TInt InitDir(CDirCB* aTrg, CMountCB* aMount); |
|
120 TInt InitDir(CMountCB* aMount); |
|
121 |
|
122 public: |
|
123 HBufC* iMatch; |
|
124 private: |
|
125 CCompDirCB(); |
|
126 ~CCompDirCB(); |
|
127 |
|
128 TBool IsDuplicate(TFileName& aFilename); |
|
129 |
|
130 RPointerArray<CDirCB> iDirs; |
|
131 TInt iCurrentDir; |
|
132 |
|
133 friend class CCompFileSystem; |
|
134 friend class CCompMountCB; |
|
135 }; |
|
136 |
|
137 |
|
138 // CCompFileCB |
|
139 |
|
140 class CCompFileCB : public CFileCB |
|
141 { |
|
142 public: |
|
143 CCompFileCB(); |
|
144 ~CCompFileCB(); |
|
145 |
|
146 void RenameL(const TDesC& aNewName); |
|
147 void ReadL(TInt aPos,TInt& aLength,const TAny* aDes); |
|
148 void ReadL(TInt aPos,TInt& aLength,const TAny* aDes,const RMessagePtr2& aMessage); |
|
149 void WriteL(TInt aPos,TInt& aLength,const TAny* aDes,const RMessagePtr2& aMessage); |
|
150 TInt Address(TInt& aPos) const; |
|
151 void SetSizeL(TInt aSize); |
|
152 void SetEntryL(const TTime& aTime,TUint aSetAttMask,TUint aClearAttMask); |
|
153 void FlushDataL(); |
|
154 void FlushAllL(); |
|
155 |
|
156 inline void SetTrueFile(CFileCB* aFile); |
|
157 inline CFileCB* TrueFile() const; |
|
158 |
|
159 protected: |
|
160 |
|
161 virtual TInt GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput); |
|
162 |
|
163 private: |
|
164 |
|
165 CFileCB* iTrueFile; |
|
166 }; |
|
167 |
|
168 |
|
169 // CCompFileSystem |
|
170 |
|
171 class CCompFileSystem : public CFileSystem |
|
172 { |
|
173 public: |
|
174 CCompFileSystem(); |
|
175 ~CCompFileSystem(); |
|
176 static CFileSystem* NewL(); |
|
177 TInt Install(); |
|
178 CMountCB* NewMountL() const; |
|
179 CFileCB* NewFileL() const; |
|
180 CDirCB* NewDirL() const; |
|
181 CFormatCB* NewFormatL() const; |
|
182 void DriveInfo(TDriveInfo& anInfo,TInt aDriveNumber) const; |
|
183 TInt DefaultPath(TDes& aPath) const; |
|
184 |
|
185 inline void NullMount(void); |
|
186 private: |
|
187 |
|
188 CCompMountCB* iMount; |
|
189 }; |
|
190 |
|
191 |
|
192 #include "sc_std.inl" |
|
193 |