8 Contributors: |
8 Contributors: |
9 --> |
9 --> |
10 <!DOCTYPE task |
10 <!DOCTYPE task |
11 PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd"> |
11 PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd"> |
12 <task id="GUID-A7C26FE4-54B2-58D6-9FDF-4B0A565D00DE" xml:lang="en"><title>Seeking |
12 <task id="GUID-A7C26FE4-54B2-58D6-9FDF-4B0A565D00DE" xml:lang="en"><title>Seeking |
13 a Position in a Large File </title><shortdesc>This tutorial shows how to seek a particular position in a large |
13 a Position in a Large File </title><shortdesc>How to seek a particular position in a large file. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody> |
14 file. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody> |
14 <context id="GUID-68715AD0-95E7-41A3-A431-B8991A9A91B2"><p>The function <xref href="GUID-83A415A0-F417-3CA5-BA10-5AEF119AB1F7.dita#GUID-83A415A0-F417-3CA5-BA10-5AEF119AB1F7/GUID-58F3EDD5-7DEF-38AA-A9B6-B68782B3FE83"><apiname>RFile64::Seek()</apiname></xref> is the 64-bit |
15 <context><p>The function <xref href="GUID-83A415A0-F417-3CA5-BA10-5AEF119AB1F7.dita#GUID-83A415A0-F417-3CA5-BA10-5AEF119AB1F7/GUID-58F3EDD5-7DEF-38AA-A9B6-B68782B3FE83"><apiname>RFile64::Seek()</apiname></xref> is the 64-bit |
|
16 version of <xref href="GUID-BE0804F6-4375-3C8A-8C83-968F510466E0.dita#GUID-BE0804F6-4375-3C8A-8C83-968F510466E0/GUID-07136402-8D95-3256-9591-EE4141748E15"><apiname>RFile::Seek()</apiname></xref>. The <codeph>Seek()</codeph> function |
15 version of <xref href="GUID-BE0804F6-4375-3C8A-8C83-968F510466E0.dita#GUID-BE0804F6-4375-3C8A-8C83-968F510466E0/GUID-07136402-8D95-3256-9591-EE4141748E15"><apiname>RFile::Seek()</apiname></xref>. The <codeph>Seek()</codeph> function |
17 can modify the file pointer to point to any position addressable by the <codeph>aPos</codeph> parameter. </p> <p> <xref href="GUID-83A415A0-F417-3CA5-BA10-5AEF119AB1F7.dita#GUID-83A415A0-F417-3CA5-BA10-5AEF119AB1F7/GUID-C4E483DB-4292-3619-95F3-87F70AC6EB19"><apiname>RFile64::Seek(TSeek |
16 can modify the file pointer to point to any position addressable by the <codeph>aPos</codeph> parameter. </p><p>See <xref href="GUID-83A415A0-F417-3CA5-BA10-5AEF119AB1F7.dita#GUID-83A415A0-F417-3CA5-BA10-5AEF119AB1F7/GUID-C4E483DB-4292-3619-95F3-87F70AC6EB19"><apiname>RFile64::Seek(TSeek |
18 aMode, TInt64& aPos)</apiname></xref>. </p> <p>To get the current position of |
17 aMode, TInt64& aPos)</apiname></xref>. </p><p>To get the current position of |
19 the file pointer use the <xref href="GUID-CA98DC2A-4B7D-336D-A251-C29120DDD444.dita"><apiname>TSeek</apiname></xref> mode <xref href="GUID-054ECFC9-C8C2-32B6-81DE-0526B3B17FF1.dita"><apiname>ESeekCurrent</apiname></xref>. |
18 the file pointer, use the <xref href="GUID-CA98DC2A-4B7D-336D-A251-C29120DDD444.dita"><apiname>TSeek</apiname></xref> mode <xref href="GUID-054ECFC9-C8C2-32B6-81DE-0526B3B17FF1.dita"><apiname>ESeekCurrent</apiname></xref>. |
20 The function updates the output parameter with the new file pointer position |
19 The function updates the output parameter with the new file pointer position |
21 in 64-bits. </p><p>Different modes of operation can be specified. These modes |
20 in 64-bits. </p><p>Different modes of operation can be specified. These modes |
22 are defined by <xref href="GUID-CA98DC2A-4B7D-336D-A251-C29120DDD444.dita"><apiname>TSeek</apiname></xref>.</p> </context> |
21 are defined by <xref href="GUID-CA98DC2A-4B7D-336D-A251-C29120DDD444.dita"><apiname>TSeek</apiname></xref>.</p></context> |
23 <steps id="GUID-DFFBEA03-D0B8-55BB-97F4-6C2B68AB0276"> |
22 <steps id="GUID-DFFBEA03-D0B8-55BB-97F4-6C2B68AB0276"> |
24 <step id="GUID-AEA38679-553B-54C1-8DC7-1AAC09777C9A"><cmd>Use <codeph>TInt64</codeph> instead |
23 <step id="GUID-AEA38679-553B-54C1-8DC7-1AAC09777C9A"><cmd>Use <codeph>TInt64</codeph> instead |
25 of <codeph>TInt</codeph> for the offset from the location specified in <codeph>aMode</codeph>. </cmd> |
24 of <codeph>TInt</codeph> for the offset from the location specified in <codeph>aMode</codeph>. </cmd> |
26 <stepxmp><codeblock id="GUID-F64A228F-0D34-5EBA-9579-17C87BD8FCF0" xml:space="preserve">// Remove TInt filePosition = 0; |
25 <stepxmp><codeblock id="GUID-F64A228F-0D34-5EBA-9579-17C87BD8FCF0" xml:space="preserve">// Remove TInt filePosition = 0; |
27 TInt64 filePosition = 0;</codeblock> </stepxmp> |
26 TInt64 filePosition = 0;</codeblock> </stepxmp> |
32 <stepxmp><codeblock id="GUID-FFEA160C-2DB6-527B-89C7-ECD5D447974B" xml:space="preserve">TInt64 filePosition = 0; |
31 <stepxmp><codeblock id="GUID-FFEA160C-2DB6-527B-89C7-ECD5D447974B" xml:space="preserve">TInt64 filePosition = 0; |
33 // Remove r = file.Seek(ESeekCurrent, filePosition); |
32 // Remove r = file.Seek(ESeekCurrent, filePosition); |
34 r = file.Seek64(ESeekCurrent, filePosition);</codeblock> </stepxmp> |
33 r = file.Seek64(ESeekCurrent, filePosition);</codeblock> </stepxmp> |
35 </step> |
34 </step> |
36 <step id="GUID-F5738D61-A81A-542B-AC29-B9AE76785CEE"><cmd>To set the file |
35 <step id="GUID-F5738D61-A81A-542B-AC29-B9AE76785CEE"><cmd>To set the file |
37 pointer to a particular positionwithin a large file use <codeph>RFile::Seek64()</codeph> with |
36 pointer to a particular position within a large file use <codeph>RFile::Seek64()</codeph> with |
38 the seek mode <xref href="GUID-458B652E-537A-3FC0-9DF7-396907A13522.dita"><apiname>ESeekStart</apiname></xref> and a seek position value that |
37 the seek mode <xref href="GUID-458B652E-537A-3FC0-9DF7-396907A13522.dita"><apiname>ESeekStart</apiname></xref> and a seek position value that |
39 is of type <xref href="GUID-AAE85115-A8AA-3F6C-BA8C-69F5A23B0D90.dita"><apiname>TInt64</apiname></xref>. </cmd> |
38 is of type <xref href="GUID-AAE85115-A8AA-3F6C-BA8C-69F5A23B0D90.dita"><apiname>TInt64</apiname></xref>. </cmd> |
40 <stepxmp><codeblock id="GUID-FFB160EE-6FE6-56C3-A486-0329BC9EFEC3" xml:space="preserve">TInt64 seekPos = 3000000000; |
39 <stepxmp><codeblock id="GUID-FFB160EE-6FE6-56C3-A486-0329BC9EFEC3" xml:space="preserve">TInt64 seekPos = 3000000000; |
41 // Remove r = file.Seek(ESeekStart, seekPos); |
40 // Remove r = file.Seek(ESeekStart, seekPos); |
42 r = file.Seek64(ESeekStart, seekPos);</codeblock> </stepxmp> |
41 r = file.Seek64(ESeekStart, seekPos);</codeblock> </stepxmp> |
43 </step> |
42 </step> |
44 </steps> |
43 </steps> |
45 <example><title>Seek position example</title> <p>If large file seek is required |
44 <example><title>Seek position example</title><p>If a large file seek is required, |
46 use <xref href="GUID-83A415A0-F417-3CA5-BA10-5AEF119AB1F7.dita#GUID-83A415A0-F417-3CA5-BA10-5AEF119AB1F7/GUID-58F3EDD5-7DEF-38AA-A9B6-B68782B3FE83"><apiname>RFile64::Seek()</apiname></xref> instead of <xref href="GUID-BE0804F6-4375-3C8A-8C83-968F510466E0.dita#GUID-BE0804F6-4375-3C8A-8C83-968F510466E0/GUID-07136402-8D95-3256-9591-EE4141748E15"><apiname>RFile::Seek()</apiname></xref> and |
45 use <xref href="GUID-83A415A0-F417-3CA5-BA10-5AEF119AB1F7.dita#GUID-83A415A0-F417-3CA5-BA10-5AEF119AB1F7/GUID-58F3EDD5-7DEF-38AA-A9B6-B68782B3FE83"><apiname>RFile64::Seek()</apiname></xref> instead of <xref href="GUID-BE0804F6-4375-3C8A-8C83-968F510466E0.dita#GUID-BE0804F6-4375-3C8A-8C83-968F510466E0/GUID-07136402-8D95-3256-9591-EE4141748E15"><apiname>RFile::Seek()</apiname></xref> and |
47 use a TInt64 value to specify the location. </p> <codeblock id="GUID-24BE4FD9-A4C0-5AC9-9253-B810D7237189" xml:space="preserve"> // RFile file; |
46 use a <codeph>TInt64</codeph> value to specify the location. </p><codeblock id="GUID-24BE4FD9-A4C0-5AC9-9253-B810D7237189" xml:space="preserve"> // RFile file; |
48 RFile64 file; |
47 RFile64 file; |
49 TInt err = file.Open(TheFs, _L(“BIGFILE.BIG”), EFileWrite); |
48 TInt err = file.Open(TheFs, _L(“BIGFILE.BIG”), EFileWrite); |
50 if(err != KErrNone) |
49 if(err != KErrNone) |
51 { |
50 { |
52 // We will only get here if a real error condition occurs. |
51 // unrelated error |
53 return err; |
52 return err; |
54 } |
53 } |
55 |
54 |
56 // Large file access is now supported! |
55 // Large file access is now supported! |
57 // TInt seekPos = 0; |
56 // TInt seekPos = 0; |