Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


How to generate a filename from URI

TUriC8 provides functionality to generate a fully qualified filename from a file URI object. The path component encodes the file's location on the file system.

URI path component

The generic path component will be of the form:

"/" [keyword "/" ] [drive*("/"keyword)["/"filename ]]

keyword indicates path limitations. The value private indicates that the path is to be resolved relative to the private directory.

drive can be either lower or upper case drive letter or "ext-media", which means that the file is present on a removable drive.

Examples of filenames resolved from variants of URIs using TUriC8::GetFileNameL() are as follows:

File type File URI File name after resolving

File on a fixed drive

file:///c/path/to/file/name.ext

c:\path\to\file\name.ext

File on a removable media drive

file:///ext-media/path/to/file/name.ext

f:\path\to\file\name.ext

Private file on a fixed drive

file:///private/c/path/to/file/name.ext

c:\private\0x1001234f\path\to\file\name.ext

Private file on a removable drive

file:///private/ext-media/path/to/file/name.ext

h:\private\0x1001234f\path\to\file\name.ext

[Top]


Generating filename from a URI

//Parse the URI descriptor
TUriParser8* uriComponent; 
 _LIT8(KUriDes,"http://web.intra/Dev/SysDoc/devlib.htm");  
uriComponent->Parse(KUriDes);
// Extract the Filename from the file URI
HBufC* fileName = uriComponent->GetFileNameL();  //returns the string 'devlib.htm'

The code above generates the file name from the file URI provided. This function supports only URIs with file scheme.

Another variant of TUriC8::GetFileNameL() is used to get either the full filename, just the file path or just the filename.

HBufC16* filename = HBufC* TUriC8::GetFileNameL(EUriFileNameFull)   

The code returns a full filename. Note that TUriC8::GetFileNameL() can be used only for file URIs and will leave if used on any other scheme.

Other two options available are as follows:

  1. EUriFileNamePath generates the filename containing only the path component.

    For example, http://www.foo.com/MyDir/MyFiles/MyFile.doc;param1;param2 retrieves MyDir\MyFiles\MyFile.doc.

  2. EUriFileNameTail generates the file name containing just the file name.

    For example, http://www.foo.com/MyDir/MyFiles/MyFile.doc;param1;param2 retrieves MyFile.doc.

[Top]


See also

For related information, see:

InetProtUtils Overview