<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "System",
  "identifier" : "/documentation/System/CInterop/stat(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "System"
    ],
    "preciseIdentifier" : "s:6System8CInteropO4statys5Int32VSPys4Int8VG_SoADVztFZ"
  },
  "title" : "stat(_:_:)"
}
-->

# stat(_:_:)

Calls the C `stat()` function.

```
static func stat(_ path: UnsafePointer<CChar>, _ s: inout CInterop.Stat) -> Int32
```

## Parameters

`path`

A null-terminated C string representing the file path.

`s`

An `inout` reference to a `CInterop.Stat` struct to populate.

## Return Value

0 on success, -1 on error (check `Errno.current`).

## Discussion

This is a direct wrapper around the C `stat()` system call.
For a more ergonomic Swift API, use `Stat` instead.

> Warning: This API is primarily intended for migration purposes when
> supporting older deployment targets. If your deployment target supports
> it, prefer using the `Stat` API introduced in SYS-0006, which provides
> type-safe, ergonomic access to file metadata in Swift.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)