|
0
|
1 |
/*
|
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
3 |
* All rights reserved.
|
|
|
4 |
* This component and the accompanying materials are made available
|
|
|
5 |
* under the terms of "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 |
* Nokia Corporation - initial contribution.
|
|
|
11 |
*
|
|
|
12 |
* Contributors:
|
|
|
13 |
*
|
|
|
14 |
* Description:
|
|
|
15 |
*
|
|
|
16 |
*/
|
|
|
17 |
|
|
|
18 |
#ifndef __W32FILEREADER_H_
|
|
|
19 |
#define __W32FILEREADER_H_
|
|
|
20 |
|
|
|
21 |
// INCLUDES
|
|
|
22 |
#include <e32base.h>
|
|
|
23 |
#include <emulator.h>
|
|
|
24 |
// CONSTANTS
|
|
|
25 |
|
|
|
26 |
// MACROS
|
|
|
27 |
|
|
|
28 |
// FUNCTION PROTOTYPES
|
|
|
29 |
|
|
|
30 |
// FORWARD DECLARATIONS
|
|
|
31 |
class CW32FileConnection;
|
|
|
32 |
|
|
|
33 |
// CLASS DECLARATION
|
|
|
34 |
|
|
|
35 |
/**
|
|
|
36 |
* This is a simple incremental file reader.
|
|
|
37 |
* @lib resLoader.lib
|
|
|
38 |
* @since 3.1
|
|
|
39 |
*/
|
|
|
40 |
class CW32FileReader : public CActive
|
|
|
41 |
{
|
|
|
42 |
public: // Constructors and destructor
|
|
|
43 |
|
|
|
44 |
/**
|
|
|
45 |
* Two-phased constructor.
|
|
|
46 |
* @since 3.1
|
|
|
47 |
* @param aFile File to read.
|
|
|
48 |
* @param aChunkSize Chunk size to be read in one turn.
|
|
|
49 |
* @param aFileReaderCallback Observer object-file transaction.
|
|
|
50 |
* @return File reader object
|
|
|
51 |
*/
|
|
|
52 |
static CW32FileReader* NewL( HANDLE aFh, TInt aChunkSize, CW32FileConnection* aFileConnection );
|
|
|
53 |
|
|
|
54 |
/**
|
|
|
55 |
* Destructor.
|
|
|
56 |
*/
|
|
|
57 |
virtual ~CW32FileReader();
|
|
|
58 |
|
|
|
59 |
public: // New functions
|
|
|
60 |
|
|
|
61 |
/**
|
|
|
62 |
* Start reading the file from the beginning.
|
|
|
63 |
* @since 3.1
|
|
|
64 |
* @param
|
|
|
65 |
* @return void
|
|
|
66 |
*/
|
|
|
67 |
void StartReading();
|
|
|
68 |
|
|
|
69 |
/**
|
|
|
70 |
* Stop reading
|
|
|
71 |
* @since 3.1
|
|
|
72 |
* @param
|
|
|
73 |
* @return void
|
|
|
74 |
*/
|
|
|
75 |
void StopReading();
|
|
|
76 |
|
|
|
77 |
/**
|
|
|
78 |
* Get partial body buffer.
|
|
|
79 |
* @since 3.1
|
|
|
80 |
* @param aChunkBuffer Pointer to the partial body buffer
|
|
|
81 |
* @return void
|
|
|
82 |
*/
|
|
|
83 |
void GetChunkBuffer( TPtrC8& aChunkBuffer );
|
|
|
84 |
|
|
|
85 |
/**
|
|
|
86 |
* Purge the chunk buffer.
|
|
|
87 |
* @since 3.1
|
|
|
88 |
* @param
|
|
|
89 |
* @return void
|
|
|
90 |
*/
|
|
|
91 |
void ReleaseChunkBuffer();
|
|
|
92 |
|
|
|
93 |
public: // from CActive
|
|
|
94 |
|
|
|
95 |
/**
|
|
|
96 |
* Cancel active object
|
|
|
97 |
* @since 3.1
|
|
|
98 |
* @param
|
|
|
99 |
* @return void
|
|
|
100 |
*/
|
|
|
101 |
void DoCancel();
|
|
|
102 |
|
|
|
103 |
/**
|
|
|
104 |
* Asynchronous handling of transaction events.
|
|
|
105 |
* @since 3.1
|
|
|
106 |
* @param
|
|
|
107 |
* @return void
|
|
|
108 |
*/
|
|
|
109 |
void RunL();
|
|
|
110 |
|
|
|
111 |
private:
|
|
|
112 |
|
|
|
113 |
/**
|
|
|
114 |
* Construct.
|
|
|
115 |
* @since 3.1
|
|
|
116 |
* @param aFile File to read.
|
|
|
117 |
* @param aChunkSize Chunk size to be read in one turn.
|
|
|
118 |
* @param aFileReaderCallback Observer object-file transaction.
|
|
|
119 |
* @return void
|
|
|
120 |
*/
|
|
|
121 |
CW32FileReader( HANDLE aFh, TInt aChunkSize, CW32FileConnection* aFileConnection );
|
|
|
122 |
|
|
|
123 |
/**
|
|
|
124 |
* By default Symbian 2nd phase constructor is private.
|
|
|
125 |
*/
|
|
|
126 |
void ConstructL();
|
|
|
127 |
|
|
|
128 |
/**
|
|
|
129 |
* Read from the file from the current position.
|
|
|
130 |
* @since 3.1
|
|
|
131 |
* @param
|
|
|
132 |
* @return void
|
|
|
133 |
*/
|
|
|
134 |
void ReadFile();
|
|
|
135 |
|
|
|
136 |
private: // Data
|
|
|
137 |
|
|
|
138 |
// file to read
|
|
|
139 |
HANDLE iFh; //file handle
|
|
|
140 |
// actual file position
|
|
|
141 |
TInt m_filePos;
|
|
|
142 |
// chunk size to read in one turn
|
|
|
143 |
TInt m_chunkSize;
|
|
|
144 |
// chunk buffer
|
|
|
145 |
HBufC8* m_chunkBuffer;
|
|
|
146 |
// observer object
|
|
|
147 |
CW32FileConnection* m_fileConnection;
|
|
|
148 |
// pointer to the chunk buffer
|
|
|
149 |
TPtr8 m_chunkBufPtr;
|
|
|
150 |
// ETrue if the file transaction is cancelled
|
|
|
151 |
TBool m_stopReading;
|
|
|
152 |
};
|
|
|
153 |
|
|
|
154 |
#endif // __W32FILEREADER_H__
|
|
|
155 |
|
|
|
156 |
// End of File
|