Skip to content

Fixed file's groupOwnerName in attributesOfItem() #885

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

Merged
merged 2 commits into from
Feb 20, 2017
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Foundation/NSFileManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ open class FileManager : NSObject {
let grd = getgrgid(s.st_gid)
if grd != nil && grd!.pointee.gr_name != nil {
let name = String(cString: grd!.pointee.gr_name)
result[.groupOwnerAccountID] = name
result[.groupOwnerAccountName] = name
}

var type : FileAttributeType
Expand Down
17 changes: 17 additions & 0 deletions TestFoundation/TestNSFileManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,23 @@ class TestNSFileManager : XCTestCase {
let fileOwnerAccountID = attrs[.ownerAccountID] as? NSNumber
XCTAssertNotNil(fileOwnerAccountID)

let fileGroupOwnerAccountID = attrs[.groupOwnerAccountID] as? NSNumber
XCTAssertNotNil(fileGroupOwnerAccountID)

if let fileOwnerAccountName = attrs[.ownerAccountName] {
XCTAssertNotNil(fileOwnerAccountName as? String)
if let fileOwnerAccountNameStr = fileOwnerAccountName as? String {
XCTAssertFalse(fileOwnerAccountNameStr.isEmpty)
}
}

if let fileGroupOwnerAccountName = attrs[.groupOwnerAccountName] {
XCTAssertNotNil(fileGroupOwnerAccountName as? String)
if let fileGroupOwnerAccountNameStr = fileGroupOwnerAccountName as? String {
XCTAssertFalse(fileGroupOwnerAccountNameStr.isEmpty)
}
}

} catch let err {
XCTFail("\(err)")
}
Expand Down