Contents

CFURLCreateCopyAppendingPathComponent(_:_:_:_:)

Creates a copy of a given URL and appends a path component.

Declaration

func CFURLCreateCopyAppendingPathComponent(_ allocator: CFAllocator!, _ url: CFURL!, _ pathComponent: CFString!, _ isDirectory: Bool) -> CFURL!

Parameters

  • allocator:

    The allocator to use to allocate memory for the new CFURL object. Pass NULL or Kcfallocatordefault to use the current default allocator.

  • url:

    The CFURL object to which to append a path component.

  • pathComponent:

    The path component to append to url.

  • isDirectory:

    A Boolean value that specifies whether the string is treated as a directory path when resolving against relative path components. Pass true if the new component indicates a directory, false otherwise.

Return Value

A copy of url appended with pathComponent. Ownership follows the create rule. See The Create Rule.

Discussion

The isDirectory argument specifies whether or not the new path component points to a file or a to directory. Note that the URL syntax for a directory and for a file at otherwise the same location are slightly different—directory URLs must end in “/”. If you have the URL http://www.apple.com/foo/ and you append the path component bar, then if isDirectory is true then the resulting URL is http://www.apple.com/foo/bar/, whereas if isDirectory is false then the resulting URL is http://www.apple.com/foo/bar. This difference is particularly important if you resolve another URL against this new URL. file.html relative to http://www.apple.com/foo/bar is http://www.apple.com/foo/file.html, whereas file.html relative to http://www.apple.com/foo/bar/ is http://www.apple.com/foo/bar/file.html.

See Also

Creating a CFURL