Symbian3/PDK/Source/GUID-A7C26FE4-54B2-58D6-9FDF-4B0A565D00DE.dita
changeset 1 25a17d01db0c
child 3 46218c8b8afa
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE task
       
    11   PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
       
    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
       
    14 file. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
       
    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
       
    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
       
    18 aMode, TInt64&amp; 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>.
       
    20 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
       
    22 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">
       
    24 <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>
       
    26 <stepxmp><codeblock id="GUID-F64A228F-0D34-5EBA-9579-17C87BD8FCF0" xml:space="preserve">// Remove TInt filePosition = 0;
       
    27 TInt64 filePosition = 0;</codeblock> </stepxmp>
       
    28 </step>
       
    29 <step id="GUID-A867C9DB-6DCE-53CF-9808-1866A64657C7"><cmd>To retrieve the
       
    30 current position of the file pointer in a large file use <codeph>RFile::Seek64()</codeph> with
       
    31 the mode <xref href="GUID-054ECFC9-C8C2-32B6-81DE-0526B3B17FF1.dita"><apiname>ESeekCurrent</apiname></xref>. </cmd>
       
    32 <stepxmp><codeblock id="GUID-FFEA160C-2DB6-527B-89C7-ECD5D447974B" xml:space="preserve">TInt64 filePosition = 0;
       
    33 // Remove r = file.Seek(ESeekCurrent, filePosition);
       
    34 r = file.Seek64(ESeekCurrent, filePosition);</codeblock> </stepxmp>
       
    35 </step>
       
    36 <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
       
    38 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>
       
    40 <stepxmp><codeblock id="GUID-FFB160EE-6FE6-56C3-A486-0329BC9EFEC3" xml:space="preserve">TInt64 seekPos = 3000000000;
       
    41 // Remove r = file.Seek(ESeekStart, seekPos);
       
    42 r = file.Seek64(ESeekStart, seekPos);</codeblock> </stepxmp>
       
    43 </step>
       
    44 </steps>
       
    45 <example><title>Seek position example</title> <p>If 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
       
    47 use a TInt64 value to specify the location. </p> <codeblock id="GUID-24BE4FD9-A4C0-5AC9-9253-B810D7237189" xml:space="preserve">    // RFile file;
       
    48     RFile64 file;
       
    49     TInt err = file.Open(TheFs, _L(“BIGFILE.BIG”), EFileWrite);
       
    50     if(err != KErrNone)
       
    51         {
       
    52         // We will only get here if a real error condition occurs.
       
    53         return err;
       
    54         }
       
    55 
       
    56     // Large file access is now supported!
       
    57     // TInt seekPos = 0;
       
    58     Tint64 seekPos = 0;
       
    59 
       
    60     // Seek the current position. This can be greater than 2GB.
       
    61     err = file.Seek(ESeekEnd, seekPos);
       
    62     if(err != KErrNone)
       
    63         {
       
    64         return err;
       
    65         }</codeblock> </example>
       
    66 </taskbody></task>