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.
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:
|
//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:
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
.
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
.
For related information, see: