Contents

init(fileURLWithPath:relativeTo:)

Creates a file URL that references the local file or directory at the given path, relative to a base URL.

Declaration

init(fileURLWithPath path: String, relativeTo base: URL?)

Parameters

  • path:

    The location in the file system.

  • base:

    A URL that provides a file system location that the path extends.

Discussion

If the path is an empty string, the system interprets it as “.”.

This method may perform file system I/O to determine if the path is to a directory. If you know the path is to a directory, use init(fileURLWithPath:isDirectory:relativeTo:) to avoid the file system I/O.

See Also

Creating a file URL from a string path