|
@@ -115,7 +115,9 @@ extension String {
|
|
|
var name = ent.pointee.d_name
|
|
var name = ent.pointee.d_name
|
|
|
let fileName = withUnsafePointer(to: &name) { (ptr) -> String? in
|
|
let fileName = withUnsafePointer(to: &name) { (ptr) -> String? in
|
|
|
#if os(Linux)
|
|
#if os(Linux)
|
|
|
- return String(validatingUTF8: [CChar](UnsafeBufferPointer<CChar>(start: UnsafePointer(unsafeBitCast(ptr, to: UnsafePointer<CChar>.self)), count: 256)))
|
|
|
|
|
|
|
+ return String(validatingUTF8: ptr.withMemoryRebound(to: CChar.self, capacity: Int(ent.pointee.d_reclen), { (ptrc) -> [CChar] in
|
|
|
|
|
+ return [CChar](UnsafeBufferPointer(start: ptrc, count: 256))
|
|
|
|
|
+ }))
|
|
|
#else
|
|
#else
|
|
|
var buffer = ptr.withMemoryRebound(to: CChar.self, capacity: Int(ent.pointee.d_reclen), { (ptrc) -> [CChar] in
|
|
var buffer = ptr.withMemoryRebound(to: CChar.self, capacity: Int(ent.pointee.d_reclen), { (ptrc) -> [CChar] in
|
|
|
return [CChar](UnsafeBufferPointer(start: ptrc, count: Int(ent.pointee.d_namlen)))
|
|
return [CChar](UnsafeBufferPointer(start: ptrc, count: Int(ent.pointee.d_namlen)))
|