Skip to content

Fix TestNSData on Windows #2218

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 1 commit into from
May 5, 2019
Merged
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
9 changes: 6 additions & 3 deletions TestFoundation/TestNSData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4205,11 +4205,14 @@ extension TestNSData {
let filePath = dirPath.appendingPathComponent("temp_file")
guard FileManager.default.createFile(atPath: filePath.path, contents: nil, attributes: nil) else { XCTAssertTrue(false, "Unable to create temporary file"); return}
guard let fh = FileHandle(forWritingAtPath: filePath.path) else { XCTAssertTrue(false, "Unable to open temporary file"); return }
defer { try! FileManager.default.removeItem(atPath: dirPath.path) }

defer {
fh.closeFile()
try! FileManager.default.removeItem(atPath: dirPath.path)
}

// Now use this data with some Objective-C code that takes NSData arguments
fh.write(data)

// Get the data back
do {
let url = URL(fileURLWithPath: filePath.path)
Expand Down