equal
deleted
inserted
replaced
|
1 // file_reader.h |
|
2 // |
|
3 // Copyright (c) 2005 - 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "Eclipse Public License v1.0" |
|
6 // which accompanies this distribution, and is available |
|
7 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 // |
|
9 // Initial Contributors: |
|
10 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 #ifndef __FILE_READER_H__ |
|
14 #define __FILE_READER_H__ |
|
15 |
|
16 #include <f32file.h> |
|
17 |
|
18 |
|
19 class MFileReaderObserver |
|
20 { |
|
21 public: |
|
22 enum TReadType |
|
23 { |
|
24 EFirst, |
|
25 EMiddle, |
|
26 ELast |
|
27 }; |
|
28 public: |
|
29 virtual void HandleFileData(const TDesC8& aData, TReadType aType, TBool& aContinue) = 0; |
|
30 virtual void HandleFileReadError(TInt aError) = 0; |
|
31 }; |
|
32 |
|
33 |
|
34 class CFileReader : public CActive |
|
35 { |
|
36 public: |
|
37 static CFileReader* NewL(TInt aBlockSize, RFs& aFs, TBool aDirect); |
|
38 ~CFileReader(); |
|
39 void Read(const TDesC& aFileName, MFileReaderObserver& aObserver); |
|
40 void Read(const TDesC& aFileName, TInt aOffset, MFileReaderObserver& aObserver); |
|
41 private: |
|
42 CFileReader(RFs& aFs, TBool aDirect, TInt aBlockSize); |
|
43 void ConstructL(); |
|
44 void ReadNextChunk(); |
|
45 void ReadNextDirectChunk(); |
|
46 private: // From CActive. |
|
47 virtual void DoCancel(); |
|
48 virtual void RunL(); |
|
49 private: |
|
50 RFs& iFs; |
|
51 MFileReaderObserver* iObserver; |
|
52 TFileName iFileName; |
|
53 TInt iBlockSize; |
|
54 HBufC8* iBuf; |
|
55 TPtr8 iPtr; |
|
56 RFile iFile; |
|
57 TBool iFirstRead; |
|
58 TBool iDirect; |
|
59 TInt iDirectOffset; |
|
60 }; |
|
61 |
|
62 |
|
63 #endif // __FILE_READER_H__ |