---
title: "init(fileURLWithFileSystemRepresentation:isDirectory:relativeTo:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nsurl/init(fileurlwithfilesystemrepresentation:isdirectory:relativeto:)"
---

# init(fileURLWithFileSystemRepresentation:isDirectory:relativeTo:)

Initializes a URL object with a C string representing a local file system path.

## Declaration

```swift
init(fileURLWithFileSystemRepresentation path: UnsafePointer<CChar>, isDirectory isDir: Bool, relativeTo baseURL: URL?)
```

## Parameters

- `path`: A null-terminated C string in file system representation containing the path to represent as a URL. If this path is a relative path, it is treated as being relative to the current working directory.
- `isDir`: doc://com.apple.documentation/documentation/Swift/true if the last path part is a directory, otherwise doc://com.apple.documentation/documentation/Swift/false.
- `baseURL`: The base URL for the new URL object. This must be a file URL. If path is absolute, this URL is ignored.

## Return Value

Return Value Returns the initialized object.

## Discussion

Discussion The file system representation format is described in File Encodings and Fonts.

## See Also

### Creating a URL object

- [init(string:)](foundation/nsurl/init(string:).md)
- [init(string:encodingInvalidCharacters:)](foundation/nsurl/init(string:encodinginvalidcharacters:).md)
- [init(string:relativeTo:)](foundation/nsurl/init(string:relativeto:).md)
- [fileURL(withPath:isDirectory:)](foundation/nsurl/fileurl(withpath:isdirectory:).md)
- [init(fileURLWithPath:isDirectory:)](foundation/nsurl/init(fileurlwithpath:isdirectory:).md)
- [fileURL(withPath:relativeTo:)](foundation/nsurl/fileurl(withpath:relativeto:).md)
- [init(fileURLWithPath:relativeTo:)](foundation/nsurl/init(fileurlwithpath:relativeto:).md)
- [fileURL(withPath:isDirectory:relativeTo:)](foundation/nsurl/fileurl(withpath:isdirectory:relativeto:).md)
- [init(fileURLWithPath:isDirectory:relativeTo:)](foundation/nsurl/init(fileurlwithpath:isdirectory:relativeto:).md)
- [fileURL(withPath:)](foundation/nsurl/fileurl(withpath:).md)
- [init(fileURLWithPath:)](foundation/nsurl/init(fileurlwithpath:).md)
- [fileURL(withPathComponents:)](foundation/nsurl/fileurl(withpathcomponents:).md)
- [init(resolvingAliasFileAt:options:)](foundation/nsurl/init(resolvingaliasfileat:options:).md)
- [init(resolvingBookmarkData:options:relativeTo:bookmarkDataIsStale:)](foundation/nsurl/init(resolvingbookmarkdata:options:relativeto:bookmarkdataisstale:).md)
- [fileURL(withFileSystemRepresentation:isDirectory:relativeTo:)](foundation/nsurl/fileurl(withfilesystemrepresentation:isdirectory:relativeto:).md)
