Function

CFURLCopyLastPathComponent

Returns the last path component of a given URL.

Declaration

CFStringRef CFURLCopyLastPathComponent(CFURLRef url);

Parameters

url

The CFURL object to examine.

Return Value

The last path component of url. Ownership follows the create rule. See The Create Rule.

Discussion

Note that if there is no last path component, this function returns an empty string. In the code sample shown in Listing 1, lastPathComponent is an empty string.

Listing 1

Code sample illustrating CFURLCopyLastPathComponent

CFStringRef urlString = CFSTR("http://www.apple.com");
CFURLRef url = CFURLCreateWithString(NULL, urlString, NULL);
CFStringRef lastPathComponent = CFURLCopyLastPathComponent (url);

If urlString were created with CFSTR("http://www.apple.com/"), then lastPathComponent would be a CFString object containing the character “/“.

See also CFURLCopyPathExtension.

See Also

Accessing the Parts of a URL

CFURLCanBeDecomposed

Determines if the given URL conforms to RFC 1808 and therefore can be decomposed.

CFURLCopyFileSystemPath

Returns the path portion of a given URL.

CFURLCopyFragment

Returns the fragment from a given URL.

CFURLCopyHostName

Returns the host name of a given URL.

CFURLCopyNetLocation

Returns the net location portion of a given URL.

CFURLCopyParameterString

Returns the parameter string from a given URL.

Deprecated
CFURLCopyPassword

Returns the password of a given URL.

CFURLCopyPath

Returns the path portion of a given URL.

CFURLCopyPathExtension

Returns the path extension of a given URL.

CFURLCopyQueryString

Returns the query string of a given URL.

CFURLCopyResourceSpecifier

Returns any additional resource specifiers after the path.

CFURLCopyScheme

Returns the scheme portion of a given URL.

CFURLCopyStrictPath

Returns the path portion of a given URL.

CFURLCopyUserName

Returns the user name from a given URL.

CFURLGetPortNumber

Returns the port number from a given URL.

CFURLHasDirectoryPath

Determines if a given URL's path represents a directory.