@@ -211,12 +211,13 @@ public class NSFileManager : NSObject {
211
211
212
212
This method replaces fileAttributesAtPath:traverseLink:.
213
213
*/
214
- public func attributesOfItemAtPath( path: String ) throws -> [ String : AnyObject ] {
214
+ /// - Experiment: Note that the return type of this function is different than on Darwin Foundation (Any instead of AnyObject). This is likely to change once we have a more complete story for bridging in place.
215
+ public func attributesOfItemAtPath( path: String ) throws -> [ String : Any ] {
215
216
var s = stat ( )
216
217
guard lstat ( path, & s) == 0 else {
217
218
throw _NSErrorWithErrno ( errno, reading: true , path: path)
218
219
}
219
- var result = [ String : AnyObject ] ( )
220
+ var result = [ String : Any ] ( )
220
221
result [ NSFileSize] = NSNumber ( unsignedLongLong: UInt64 ( s. st_size) )
221
222
222
223
#if os(OSX) || os(iOS)
@@ -233,14 +234,14 @@ public class NSFileManager : NSObject {
233
234
234
235
let pwd = getpwuid ( s. st_uid)
235
236
if pwd != nil && pwd. memory. pw_name != nil {
236
- if let name = NSString ( bytes : pwd . memory . pw_name , length : Int ( strlen ( pwd. memory. pw_name) ) , encoding : NSUTF8StringEncoding ) {
237
+ if let name = String . fromCString ( pwd. memory. pw_name) {
237
238
result [ NSFileOwnerAccountName] = name
238
239
}
239
240
}
240
241
241
242
let grd = getgrgid ( s. st_gid)
242
243
if grd != nil && grd. memory. gr_name != nil {
243
- if let name = NSString ( bytes : grd . memory . gr_name , length : Int ( strlen ( grd. memory. gr_name) ) , encoding : NSUTF8StringEncoding ) {
244
+ if let name = String . fromCString ( grd. memory. gr_name) {
244
245
result [ NSFileGroupOwnerAccountID] = name
245
246
}
246
247
}
@@ -255,7 +256,7 @@ public class NSFileManager : NSObject {
255
256
case S_IFSOCK: type = NSFileTypeSocket
256
257
default : type = NSFileTypeUnknown
257
258
}
258
- result [ NSFileType] = NSString ( type)
259
+ result [ NSFileType] = type
259
260
260
261
if type == NSFileTypeBlockSpecial || type == NSFileTypeCharacterSpecial {
261
262
result [ NSFileDeviceIdentifier] = NSNumber ( unsignedLongLong: UInt64 ( s. st_rdev) )
0 commit comments