Contents

CFURLCopyPath(_:)

Returns the path portion of a given URL.

Declaration

func CFURLCopyPath(_ anURL: CFURL!) -> CFString!

Parameters

  • anURL:

    The CFURL object to examine.

Return Value

The path of anURL, or NULL if the URL cannot be decomposed (doesn’t conform to RFC 1808). Ownership follows the create rule. See The Create Rule.

Discussion

This function does not resolve the URL against its base, nor does it replace percent escape sequences. This function’s return value includes any leading slash (giving the path the normal POSIX appearance), if present. If this behavior is not appropriate, use CFURLCopyStrictPath(_:_:) whose return value omits any leading slash. You may also want to use the function CFURLCopyFileSystemPath(_:_:), which returns the URL’s path as a file system path for the given path style. If the path is to be passed to file system calls, you may also want to use the function CFURLGetFileSystemRepresentation(_:_:_:_:), which returns a C string.

See Also

Accessing the Parts of a URL