Update contrib.
1 // Copyright (c) 1995-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
24 IMPORT_C TUint32 DebugRegister();
25 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
26 #define __LOCK_SR_STD__
27 #define __PRINT(t) {if (DebugRegister()&KROFS) RDebug::Print(t);}
28 #define __PRINT1(t,d) {if (DebugRegister()&KROFS) RDebug::Print(t,d);}
29 #define __PRINT2(t,d,d1) {if (DebugRegister()&KROFS) RDebug::Print( t, d , d1);}
33 #define __PRINT2(t,d,d1)
38 #define _USE_TRUE_LRU_CACHE
40 const TUint KFileHidden = 0xFFFFFFFF;
42 class CRofs : public CFileSystem
51 EPanicEntryBeforeDirectory,
52 EPanicEntryAfterDirectory,
54 EPanicRemountNotSupported,
61 static void Panic( TPanic aPanic );
70 CMountCB* NewMountL() const;
71 CFileCB* NewFileL() const;
72 CDirCB* NewDirL() const;
73 CFormatCB* NewFormatL() const;
75 void DriveInfo(TDriveInfo& anInfo,TInt aDriveNumber) const;
76 TInt DefaultPath(TDes& aPath) const;
77 TInt TotalSupportedDrives() const;
78 TBool IsExtensionSupported() const{ return(ETrue);};
80 TInt iTotalSupportedDrives;
85 class CDirectoryCache : public CBase
88 CDirectoryCache( CRofsMountCB& aMount, CProxyDrive& aLocalDrive, const TRofsHeader& aHeader );
93 void FindLeafDirL(const TDesC& aName, const TRofsDir*& aDir) const;
94 void FindFileEntryL(const TDesC& aName, const TRofsEntry*& aEntry) const;
95 void FindDirectoryEntryL(const TDesC& aName, const TRofsDir*& aDir) const;
96 void GetNextMatchingL(const TDesC& aName, TUint aAtt, const TRofsDir*& aDir, const TRofsEntry*& aEntry, TInt aError, TBool bUseBinarySearch) const;
97 void FindGeneralEntryL(const TDesC& aName, TUint aAtt, const TRofsDir*& aDir, const TRofsEntry*& aEntry ) const;
99 static inline const TText* NameAddress( const TRofsEntry* aEntry );
100 TUint8 GetMountId(void);
104 static inline TUint32 AlignUp( TUint32 aValue );
105 inline const TRofsDir* RootDirectory() const;
106 inline const TRofsDir* RofsDirFromMediaOffset( TUint aMediaOffset ) const;
107 inline const TRofsDir* RofsDirFromSubDirEntry( const TRofsEntry* aEntry ) const;
108 static inline const TRofsEntry* FirstSubDirEntryFromDir( const TRofsDir* aDir );
109 inline const TRofsEntry* FirstFileEntryFromDir( const TRofsDir* aDir ) const;
110 inline const TAny* EndOfFileBlockPlusOne( const TRofsDir* aDir ) const;
111 inline const TAny* EndOfDirPlusOne( const TRofsDir* aDir ) const;
112 static inline const TRofsEntry* NextEntry( const TRofsEntry* aEntry );
114 TInt DoFindSubDir(const TDesC& aName, TUint aAtt, const TRofsDir* aDir, const TRofsEntry*& aEntry) const;
115 TInt DoFindFile(const TDesC& aName, TUint aAtt, const TRofsDir* aDir, const TRofsEntry*& aEntry) const;
117 TInt DoBinaryFindSubDir(const TDesC& aName, TUint aAtt, const TRofsDir* aDir, const TRofsEntry*& aEntry) const;
118 TInt DoBinaryFindFile(const TDesC& aName, TUint aAtt, const TRofsDir* aDir, const TRofsEntry*& aEntry) const;
120 TInt GetDirCount(const TRofsDir* aDir) const;
121 TInt GetFileCount(const TRofsDir* aDir) const;
122 TInt Compare(const TDesC& aLeft, const TDesC& aRight) const;
123 TInt ExtractMangleInfo(const TDesC& searchName, TUint8 &MountId, TUint8 &Reserved) const;
125 CRofsMountCB& iMount;
126 CProxyDrive& iLocalDrive;
127 const TUint iTreeMediaOffset;
128 const TUint iTreeSize;
129 const TUint iFilesMediaOffset;
130 const TUint iFilesSize;
132 HBufC8* iFilesBuffer;
140 class CRofsMountCB : public CLocDrvMountCB, public CMountCB::MFileAccessor
144 void MountL(TBool aForceMount);
147 void VolumeL(TVolumeInfo& aVolume) const;
148 void SetVolumeL(TDes& aName);
149 void MkDirL(const TDesC& aName);
150 void RmDirL(const TDesC& aName);
151 void DeleteL(const TDesC& aName);
152 void RenameL(const TDesC& anOldName,const TDesC& anNewName);
153 void ReplaceL(const TDesC& anOldName,const TDesC& anNewName);
154 void EntryL(const TDesC& aName,TEntry& anEntry) const;
155 void SetEntryL(const TDesC& aName,const TTime& aTime,TUint aMask,TUint aVal);
156 void FileOpenL(const TDesC& aName,TUint aMode,TFileOpen anOpen,CFileCB* aFile);
157 void DirOpenL(const TDesC& aName,CDirCB* aDir);
158 void RawReadL(TInt64 aPos,TInt aLength,const TAny* aTrg,TInt anOffset,const RMessagePtr2& aMessage) const;
159 void RawWriteL(TInt64 aPos,TInt aLength,const TAny* aSrc,TInt anOffset,const RMessagePtr2& aMessage);
160 void GetShortNameL(const TDesC& aLongName,TDes& aShortName);
161 void GetLongNameL(const TDesC& aShortName,TDes& aLongName);
162 void ReadSectionL(const TDesC& aName,TInt aPos,TAny* aTrg,TInt aLength,const RMessagePtr2& aMessage);
163 void ReadUidL( TUint aMediaOffset, TEntry& aEntry, TRofsEntry* aRofsEntry) const;
164 inline CRofs& FileSystem() const;
165 virtual TInt GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput);
166 virtual TInt GetFileUniqueId(const TDesC& aName, TInt64& aUniqueId);
167 virtual TInt Spare3(TInt aVal, TAny* aPtr1, TAny* aPtr2);
168 virtual TInt Spare2(TInt aVal, TAny* aPtr1, TAny* aPtr2);
169 virtual TInt Spare1(TInt aVal, TAny* aPtr1, TAny* aPtr2);
171 #ifdef _USE_TRUE_LRU_CACHE
172 void CacheReadL(TInt aPos, TInt aLength, const TAny* aDes, TInt anOffset, const RMessagePtr2& aMessage) const;
177 TInt CheckHeader() const;
178 TInt CheckExtension();
181 TPckgBuf<TRofsHeader> iHeader;
182 CDirectoryCache* iDirectoryCache;
185 #ifdef _USE_TRUE_LRU_CACHE
186 CRofsLruCache* iDataCache;
191 class CRofsFileCB : public CFileCB, public CFileCB::MBlockMapInterface, public CFileCB::MExtendedFileInterface
195 void RenameL(const TDesC& aNewName);
196 void ReadL(TInt aPos,TInt& aLength,const TAny* aDes,const RMessagePtr2& aMessage);
197 void WriteL(TInt aPos,TInt& aLength,const TAny* aDes,const RMessagePtr2& aMessage);
198 void SetSizeL(TInt aSize);
199 void SetEntryL(const TTime& aTime,TUint aMask,TUint aVal);
202 inline void SetMediaBase(const TUint aBase);
203 inline void SetAttExtra( TUint8 aAttExtra );
204 TInt GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput);
206 // from CFileCB::MExtendedFileInterface
207 virtual void ReadL(TInt64 aPos,TInt& aLength,TDes8* aDes,const RMessagePtr2& aMessage, TInt aOffset);
208 virtual void WriteL(TInt64 aPos,TInt& aLength,const TDesC8* aDes,const RMessagePtr2& aMessage, TInt aOffset);
209 virtual void SetSizeL(TInt64 aSize);
212 inline CRofsMountCB& RofsMount();
213 TInt BlockMap(SBlockMapInfo& aInfo, TInt64& aStartPos, TInt64 aEndPos);
220 class CRofsDirCB : public CDirCB
225 void ReadL(TEntry& anEntry);
226 void SetDir(const TRofsDir* aDir, const TDesC& aMatch, TInt64& aTimeStamp );
227 inline void SetCache( CDirectoryCache* aCache );
231 CDirectoryCache* iCache;
234 const TRofsDir* iDir;
235 const TRofsEntry* iNext;
239 #ifdef _USE_TRUE_LRU_CACHE
240 const TInt KSizeOfCacheInPages = 5; // 5K Cache
241 const TInt KSizeOfSegment = 1024; //Two pages
242 const TInt KPageSize = 512;
249 TUint8* Data() {return(((TUint8*)this)+sizeof(TCacheSegment));}
256 //Data cache for Rofs, (read only cache)
258 class CRofsLruCache: public CBase
262 static CRofsLruCache* New(TInt aSegmentSize, CRofsMountCB* aMount, TInt64 aMediaSize);
263 TUint8* Find(TInt aPos , TInt aLength);
264 TUint8* ReadL(TInt aPos , TInt aLength);
266 CRofsLruCache(CRofsMountCB* aMount, TInt64 aMediaSize);
268 TDblQue<TCacheSegment> iQue;
269 CRofsMountCB* iMount;
275 #include "sr_rofs.inl"