diff --git a/Sources/FoundationEssentials/FileManager/FileManager+Directories.swift b/Sources/FoundationEssentials/FileManager/FileManager+Directories.swift index e1db5a9f4..48ca66849 100644 --- a/Sources/FoundationEssentials/FileManager/FileManager+Directories.swift +++ b/Sources/FoundationEssentials/FileManager/FileManager+Directories.swift @@ -510,3 +510,27 @@ extension _FileManagerImpl { #endif } } + +@_cdecl("_NSCurrentDirectoryPath") +internal func _NSCurrentDirectoryPath(_ buffer: UnsafeMutablePointer?, _ 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 +} \ No newline at end of file