Function

CFURLResourceIsReachable

Returns whether the resource pointed to by a file URL can be reached.

Declaration

Boolean CFURLResourceIsReachable(CFURLRef url, CFErrorRef *error);

Parameters

url

The URL to check.

error

The error that occurred when the resource could not be reached.

Return Value

true if the resource is reachable; otherwise, false.

Discussion

This function synchronously checks if the file at the provided URL is reachable. Checking reachability is appropriate when making decisions that do not require other immediate operations on the resource, such as periodic maintenance of user interface state that depends on the existence of a specific document. For example, you might remove an item from a download list if the user deletes the file.

If your app must perform operations on the file, such as opening it or copying resource properties, it is more efficient to attempt the operation and handle any failure that may occur.

If this function returns false, the object pointer referenced by error is populated with additional information.

See Also

Getting URL Properties

CFURLGetBaseURL

Returns the base URL of a given URL if it exists.

CFURLGetBytes

Returns by reference the byte representation of a URL object.

CFURLGetByteRangeForComponent

Returns the range of the specified component in the bytes of a URL.

CFURLGetTypeID

Returns the type identifier for the CFURL opaque type.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software