---
title: "withUnsafeFileSystemRepresentation(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/url/withunsafefilesystemrepresentation(_:)"
---

# withUnsafeFileSystemRepresentation(_:)

Passes the URL’s path in the file system representation to a closure.

## Declaration

```swift
func withUnsafeFileSystemRepresentation<ResultType>(_ block: (UnsafePointer<Int8>?) throws -> ResultType) rethrows -> ResultType
```

## Parameters

- `block`: A closure to execute, which receives a C string as its parameter, and returns a value of a type you choose. The parameter passed to the closure is nil if the URL cannot be represented by the file system. For example, if the URL contains an accented character and the file system only supports ASCII, no file system representation is possible.

## Return Value

Return Value The value returned by your closure, if any.

## Discussion

Discussion The file system representation is a null-terminated C string with canonical UTF-8 encoding. note: The pointer is not valid outside the context of the closure.

## See Also

### Working with file URLs

- [isFileURL](foundation/url/isfileurl.md)
- [hasDirectoryPath](foundation/url/hasdirectorypath.md)
- [resolveSymlinksInPath()](foundation/url/resolvesymlinksinpath().md)
- [resolvingSymlinksInPath()](foundation/url/resolvingsymlinksinpath().md)
- [standardize()](foundation/url/standardize().md)
