Skip to content

6.1: Support for building with 64-bit time_t/off_t on 32-bit platforms #1388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: release/6.1
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Sources/FoundationEssentials/FileManager/FileManager+Files.swift
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,12 @@ extension _FileManagerImpl {
let blockSize = UInt64(result.f_bsize)
#else
let fsNumber = result.f_fsid
#if canImport(Glibc)
let blockSize = fsblkcnt_t(result.f_frsize) // support 64-bit block sizes on 32-bit platforms
#else
let blockSize = UInt(result.f_frsize)
#endif
#endif
var totalSizeBytes = result.f_blocks * blockSize
var availSizeBytes = result.f_bavail * blockSize
var totalFiles = result.f_files
Expand Down Expand Up @@ -947,6 +951,12 @@ extension _FileManagerImpl {
#endif
}

#if canImport(Glibc)
// support for 64-bit timestamps on 32-bit platforms; unfortunately
// suseconds_t is not an alias of the appropriate type, but time_t is
typealias suseconds_t = time_t
#endif

if let date = attributes[.modificationDate] as? Date {
let (isecs, fsecs) = modf(date.timeIntervalSince1970)
if let tv_sec = time_t(exactly: isecs),
Expand Down