Symbian3/SDK/Source/GUID-4B7352BF-4BF8-5FF2-8835-F146BB7D4EAC.dita
changeset 7 51a74ef9ed63
equal deleted inserted replaced
6:43e37759235e 7:51a74ef9ed63
       
     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 concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept id="GUID-4B7352BF-4BF8-5FF2-8835-F146BB7D4EAC" xml:lang="en"><title>Generating
       
    13 a File Name from the URI</title><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    14 <p>This tutorial describes the steps to generate a file name from URI. </p>
       
    15 <section><title>Introduction</title> <p> <xref href="GUID-A81CD022-5AD4-3BD8-B006-B3891C4F4F74.dita"><apiname>TUriC8</apiname></xref> provides
       
    16 functionality to generate a fully qualified file name from a file URI object.
       
    17 This function supports only URIs with file scheme. </p> <p><b> URI path component </b> </p> <p>The <codeph>path</codeph> component
       
    18 encodes the file's location on the file system. The generic path component
       
    19 is of the form: </p> <p>"/" [<i>keyword</i> "/" ] [<i>drive</i> *("/"<i>keyword</i>)["/"<i>filename</i> ]] </p> <p>where, </p> <ul>
       
    20 <li id="GUID-44ABA994-B265-50EB-9529-D8D319C27CDD"><p> <i>keyword</i> indicates
       
    21 path limitations. The only valid value of this is <i>private</i>, which indicates
       
    22 that the path is to be resolved relative to the application’s private directory. </p> </li>
       
    23 <li id="GUID-FCFB99C0-8331-5D20-989E-384DC5B9B395"><p> <i>drive</i> is either
       
    24 the drive letter (upper or lowercase), or the term “ext-media”, indicating
       
    25 that the file is on a removable drive. </p> </li>
       
    26 </ul> <p>Examples of file names resolved from variants of URIs using <xref href="GUID-A81CD022-5AD4-3BD8-B006-B3891C4F4F74.dita#GUID-A81CD022-5AD4-3BD8-B006-B3891C4F4F74/GUID-AD8DC94E-743B-3347-9AC4-B37AE23AA786"><apiname>TUriC8::GetFileNameL()</apiname></xref> are
       
    27 as follows: </p> <table id="GUID-EBAA947D-9DC1-5727-BFE1-7071E23ACCB6">
       
    28 <tgroup cols="3"><colspec colname="col0"/><colspec colname="col1"/><colspec colname="col2"/>
       
    29 <thead>
       
    30 <row>
       
    31 <entry>File type</entry>
       
    32 <entry>File URI</entry>
       
    33 <entry>File name after resolving</entry>
       
    34 </row>
       
    35 </thead>
       
    36 <tbody>
       
    37 <row>
       
    38 <entry><p>File on a fixed drive </p> </entry>
       
    39 <entry><p> <filepath>file:///c/path/to/file/name.ext</filepath>  </p> </entry>
       
    40 <entry><p> <filepath>c:\path\to\file\name.ext</filepath>  </p> </entry>
       
    41 </row>
       
    42 <row>
       
    43 <entry><p>File on a removable media drive </p> </entry>
       
    44 <entry><p> <filepath> file:///ext-media/path/to/file/name.ext</filepath>  </p> </entry>
       
    45 <entry><p> <filepath>f:\path\to\file\name.ext</filepath>  </p> </entry>
       
    46 </row>
       
    47 <row>
       
    48 <entry><p>Private file on a fixed drive </p> </entry>
       
    49 <entry><p> <filepath>file:///private/c/path/to/file/name.ext</filepath>  </p> </entry>
       
    50 <entry><p> <filepath>c:\private\0x1001234f\path\to\file\name.ext</filepath>  </p> </entry>
       
    51 </row>
       
    52 <row>
       
    53 <entry><p>Private file on a removable drive </p> </entry>
       
    54 <entry><p>f<filepath>ile:///private/ext-media/path/to/file/name.ext</filepath>  </p> </entry>
       
    55 <entry><p> <filepath> h:\private\0x1001234f\path\to\file\name.ext</filepath>  </p> </entry>
       
    56 </row>
       
    57 </tbody>
       
    58 </tgroup>
       
    59 </table> </section>
       
    60 <section><title>Procedure </title> <p>The following code generates the file
       
    61 name from the file URI provided. </p> <codeblock id="GUID-34C6DFA2-379C-5BE8-8968-D1467C4AACA7" xml:space="preserve">//Parse the URI descriptor
       
    62 TUriParser8* uriComponent; 
       
    63 _LIT8( KUriDes,"http://web.intra/Dev/SysDoc/devlib.htm" );  
       
    64 uriComponent-&gt;Parse( KUriDes );
       
    65 // Extract the file name from the file URI
       
    66 HBufC* fileName = uriComponent-&gt;GetFileNameL();  //returns the string 'devlib.htm'</codeblock> <p>Another
       
    67 variant of <xref href="GUID-A81CD022-5AD4-3BD8-B006-B3891C4F4F74.dita#GUID-A81CD022-5AD4-3BD8-B006-B3891C4F4F74/GUID-AD8DC94E-743B-3347-9AC4-B37AE23AA786"><apiname>TUriC8::GetFileNameL()</apiname></xref> is used to get either
       
    68 the full file name, only the file path or only the file name. </p> <codeblock id="GUID-AE92CAAB-E00C-5708-8A2A-3116CBC3601E" xml:space="preserve">HBufC16* filename = HBufC* TUriC8::GetFileNameL( EUriFileNameFull )    </codeblock> <p>The
       
    69 code returns a full file name. </p> <p> <b>Note</b>: <xref href="GUID-1FBE2971-8486-34FE-AA20-D7D4A920C18D.dita#GUID-1FBE2971-8486-34FE-AA20-D7D4A920C18D/GUID-4E851A12-C61C-39A6-9C34-DF445A402429"><apiname>UriC8::GetFileNameL()</apiname></xref> can
       
    70 be used only for file URIs and will leave if used on any other scheme. </p> <p>Other
       
    71 two options available are as follows: </p> <ol id="GUID-CEA2464C-5273-50D3-B1FA-2918A5660368">
       
    72 <li id="GUID-83ECAC38-CF24-5980-8C62-8B52DBF6FF89"><p> <codeph>EUriFileNamePath</codeph> generates
       
    73 the filename containing only the path component. </p> <p>For example, <codeph>http://www.foo.com/MyDir/MyFiles/MyFile.doc;param1;param2</codeph> retrieves <filepath>MyDir\MyFiles\MyFile.doc</filepath>. </p> </li>
       
    74 <li id="GUID-722BEC57-07AF-5B32-8C30-FE0B0C738CB1"><p> <codeph>EUriFileNameTail</codeph> generates
       
    75 the file name containing just the file name. </p> <p>For example, <codeph>http://www.foo.com/MyDir/MyFiles/MyFile.doc;param1;param2</codeph> retrieves <filepath>MyFile.doc</filepath>. </p> </li>
       
    76 </ol> </section>
       
    77 </conbody><related-links>
       
    78 <link href="GUID-795B41AF-FBEA-56CE-AE20-EF17BE754723.dita"><linktext>HTTP Utilities
       
    79 Library Overview</linktext></link>
       
    80 </related-links></concept>