Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -510,3 +510,27 @@ extension _FileManagerImpl {
#endif
}
}

@_cdecl("_NSCurrentDirectoryPath")
internal func _NSCurrentDirectoryPath(_ buffer: UnsafeMutablePointer<CChar>?, _ size: Int) -> Bool {
guard let buffer = buffer, size > 0 else {
return false // Invalid parameters
}

let currentPath = FileManager.default.currentDirectoryPath

// Convert to C string representation
let cString = currentPath.utf8CString
let requiredSize = cString.count // includes null terminator

if requiredSize > size {
return false // Buffer too small
}

// Copy the string to the buffer
cString.withUnsafeBufferPointer { sourceBuffer in
buffer.initialize(from: sourceBuffer.baseAddress!, count: requiredSize)
}

return true // Success
}