equal
deleted
inserted
replaced
91 |
91 |
92 if (iFilePos != 0) |
92 if (iFilePos != 0) |
93 { |
93 { |
94 // We need to seek to the start and fill the buffer. |
94 // We need to seek to the start and fill the buffer. |
95 iFilePos = 0; |
95 iFilePos = 0; |
96 TInt err = iFile->Seek(ESeekStart, iFilePos); |
96 TInt filepos = 0; |
|
97 TInt err = iFile->Seek(ESeekStart, filepos); |
97 if (err == KErrNone) |
98 if (err == KErrNone) |
98 { |
99 { |
99 err = iFile->Read(iFileBuffer); |
100 err = iFile->Read(iFileBuffer); |
100 } |
101 } |
101 |
102 |
133 // we can use it for seeking. This function checks if a 64-bit value |
134 // we can use it for seeking. This function checks if a 64-bit value |
134 // is compatible with RFile's 32-bit operations. |
135 // is compatible with RFile's 32-bit operations. |
135 // |
136 // |
136 void CFileReader::SeekL(TInt64 aOffset) |
137 void CFileReader::SeekL(TInt64 aOffset) |
137 { |
138 { |
138 if (aOffset < (TInt64)KMinTInt) |
139 if (aOffset < KMinTInt64) |
139 { |
140 { |
140 User::Leave(KErrNotSupported); |
141 User::Leave(KErrNotSupported); |
141 } |
142 } |
142 |
143 |
143 if (aOffset > (TInt64)KMaxTInt) |
144 if (aOffset > KMaxTInt64) |
144 { |
145 { |
145 User::Leave(KErrNotSupported); |
146 User::Leave(KErrNotSupported); |
146 } |
147 } |
147 |
148 |
148 TInt low = (TInt)I64LOW(aOffset); |
149 if (aOffset < (TInt64)KMaxTInt) |
149 SeekL(low); |
150 { |
|
151 TInt low = (TInt)I64LOW(aOffset); |
|
152 SeekL(low); |
|
153 } |
|
154 else |
|
155 { |
|
156 TInt err = CReader::Seek(aOffset); |
|
157 if (err == KErrUnderflow) |
|
158 { |
|
159 TInt64 bufPos = CBufferReader::Position(); |
|
160 aOffset += bufPos - iFileBuffer.Length(); |
|
161 User::LeaveIfError(PhysicallySeekAndRead(aOffset)); |
|
162 } |
|
163 } |
150 } |
164 } |
151 |
165 |
152 // |
166 // |
153 // This function seeks forward/backward aOffset bytes |
167 // This function seeks forward/backward aOffset bytes |
154 // and fills the buffer from that point. |
168 // and fills the buffer from that point. |
159 |
173 |
160 // New buffer contents so read from the start of it. |
174 // New buffer contents so read from the start of it. |
161 CBufferReader::Reset(); |
175 CBufferReader::Reset(); |
162 |
176 |
163 iFilePos = aOffset; |
177 iFilePos = aOffset; |
164 err = iFile->Seek(ESeekCurrent, iFilePos); |
178 err = iFile->Seek(ESeekCurrent, aOffset); |
|
179 |
|
180 if (err != KErrNone) |
|
181 { |
|
182 return err; |
|
183 } |
|
184 |
|
185 err = iFile->Read(iFileBuffer); |
|
186 if (err != KErrNone) |
|
187 { |
|
188 return err; |
|
189 } |
|
190 return (iFileBuffer.Length() == 0 ? KErrEof : KErrNone); |
|
191 } |
|
192 TInt CFileReader::PhysicallySeekAndRead(TInt64 aOffset) |
|
193 { |
|
194 TInt err; |
|
195 // New buffer contents so read from the start of it. |
|
196 CBufferReader::Reset(); |
|
197 |
|
198 iFilePos = aOffset; |
|
199 RFile64* tempfile; |
|
200 tempfile = static_cast<RFile64*> (iFile); |
|
201 |
|
202 err = tempfile->Seek(ESeekCurrent, iFilePos); |
165 if (err != KErrNone) |
203 if (err != KErrNone) |
166 { |
204 { |
167 return err; |
205 return err; |
168 } |
206 } |
169 |
207 |