<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "System",
  "identifier" : "/documentation/System/Stat",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "System"
    ],
    "preciseIdentifier" : "s:6System4StatV"
  },
  "title" : "Stat"
}
-->

# Stat

A Swift wrapper of the C `stat` struct.

```
@frozen struct Stat
```

## Overview> Note: Only available on Unix-like platforms.

## Topics

### Structures

[`struct Flags`](/documentation/System/Stat/Flags-swift.struct)

Flags representing those passed to `fstatat()`.

### Initializers

[`init(FilePath, flags: Stat.Flags, retryOnInterrupt: Bool) throws(Errno)`](/documentation/System/Stat/init(_:flags:retryOnInterrupt:)-349q0)

Creates a `Stat` struct from a `FilePath` and `Flags`.

[`init(UnsafePointer<CChar>, flags: Stat.Flags, retryOnInterrupt: Bool) throws(Errno)`](/documentation/System/Stat/init(_:flags:retryOnInterrupt:)-9o008)

Creates a `Stat` struct from an `UnsafePointer<CChar>` path and `Flags`.

[`init(UnsafePointer<CChar>, followTargetSymlink: Bool, retryOnInterrupt: Bool) throws(Errno)`](/documentation/System/Stat/init(_:followTargetSymlink:retryOnInterrupt:)-2szq8)

Creates a `Stat` struct from an `UnsafePointer<CChar>` path.

[`init(FilePath, followTargetSymlink: Bool, retryOnInterrupt: Bool) throws(Errno)`](/documentation/System/Stat/init(_:followTargetSymlink:retryOnInterrupt:)-4apli)

Creates a `Stat` struct from a `FilePath`.

[`init(UnsafePointer<CChar>, relativeTo: FileDescriptor, flags: Stat.Flags, retryOnInterrupt: Bool) throws(Errno)`](/documentation/System/Stat/init(_:relativeTo:flags:retryOnInterrupt:)-5rm1x)

Creates a `Stat` struct from an `UnsafePointer<CChar>` path and `Flags`,
including a `FileDescriptor` to resolve a relative path.

[`init(FilePath, relativeTo: FileDescriptor, flags: Stat.Flags, retryOnInterrupt: Bool) throws(Errno)`](/documentation/System/Stat/init(_:relativeTo:flags:retryOnInterrupt:)-q6e4)

Creates a `Stat` struct from a `FilePath` and `Flags`,
including a `FileDescriptor` to resolve a relative path.

[`init(FileDescriptor, retryOnInterrupt: Bool) throws(Errno)`](/documentation/System/Stat/init(_:retryOnInterrupt:))

Creates a `Stat` struct from a `FileDescriptor`.

[`init(rawValue: CInterop.Stat)`](/documentation/System/Stat/init(rawValue:))

Creates a Swift `Stat` from the raw C struct.

### Instance Properties

[`var blocksAllocated: Int64`](/documentation/System/Stat/blocksAllocated)

Number of 512-byte blocks allocated

[`var deviceID: DeviceID`](/documentation/System/Stat/deviceID)

ID of device containing file

[`var flags: FileFlags`](/documentation/System/Stat/flags-swift.property)

File flags

[`var generationNumber: UInt64`](/documentation/System/Stat/generationNumber)

File generation number

[`var groupID: GroupID`](/documentation/System/Stat/groupID)

Group ID of owner

[`var inode: Inode`](/documentation/System/Stat/inode)

Inode number

[`var linkCount: Int`](/documentation/System/Stat/linkCount)

Number of hard links

[`var mode: FileMode`](/documentation/System/Stat/mode)

File mode

[`var permissions: FilePermissions`](/documentation/System/Stat/permissions)

File permissions for the given mode

[`var preferredIOBlockSize: Int`](/documentation/System/Stat/preferredIOBlockSize)

Block size for file system I/O, in bytes

[`var rawValue: CInterop.Stat`](/documentation/System/Stat/rawValue)

The raw C `stat` struct.

[`var size: Int64`](/documentation/System/Stat/size)

Total size, in bytes

[`var sizeAllocated: Int64`](/documentation/System/Stat/sizeAllocated)

Total size allocated, in bytes

[`var specialDeviceID: DeviceID`](/documentation/System/Stat/specialDeviceID)

Device ID (if special file)

[`var st_atim: timespec`](/documentation/System/Stat/st_atim)

Time of last access, given as a C `timespec` since the Epoch.

[`var st_birthtim: timespec`](/documentation/System/Stat/st_birthtim)

Time of file creation, given as a C `timespec` since the Epoch.

[`var st_ctim: timespec`](/documentation/System/Stat/st_ctim)

Time of last status (inode) change, given as a C `timespec` since the Epoch.

[`var st_mtim: timespec`](/documentation/System/Stat/st_mtim)

Time of last modification, given as a C `timespec` since the Epoch.

[`var type: FileType`](/documentation/System/Stat/type)

File type for the given mode

[`var userID: UserID`](/documentation/System/Stat/userID)

User ID of owner

### Default Implementations

[Equatable Implementations](/documentation/System/Stat/Equatable-Implementations)

[Hashable Implementations](/documentation/System/Stat/Hashable-Implementations)

## Relationships

### Conforms To

[`RawRepresentable`](/documentation/Swift/RawRepresentable)

[`BitwiseCopyable`](/documentation/Swift/BitwiseCopyable)

[`Copyable`](/documentation/Swift/Copyable)

[`Hashable`](/documentation/Swift/Hashable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Equatable`](/documentation/Swift/Equatable)

[`Sendable`](/documentation/Swift/Sendable)

---

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)