Skip to content

Xcode 13 hotfix #81

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

Closed
wants to merge 2 commits into from
Closed
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
10 changes: 7 additions & 3 deletions Sources/PathKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,9 @@ extension Path {
extension Path {
public static func glob(_ pattern: String) -> [Path] {
var gt = glob_t()
let cPattern = strdup(pattern)
guard let cPattern = strdup(pattern) else {
fatalError("strdup returned null: Likely out of memory")
}
defer {
globfree(&gt)
free(cPattern)
Expand Down Expand Up @@ -619,8 +621,10 @@ extension Path {
}

public func match(_ pattern: String) -> Bool {
let cPattern = strdup(pattern)
let cPath = strdup(path)
guard let cPattern = strdup(pattern),
let cPath = strdup(path) else {
fatalError("strdup returned null: Likely out of memory")
}
defer {
free(cPattern)
free(cPath)
Expand Down
20 changes: 10 additions & 10 deletions Tests/PathKitTests/PathKitSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,12 @@ describe("PathKit") {
let current = Path.current
let error = ThrowError()

try expect {
try expect({
try Path("/usr/bin").chdir {
try expect(Path.current) == Path("/usr/bin")
throw error
}
}.toThrow(error)
}).toThrow(error)

try expect(Path.current) == current
}
Expand Down Expand Up @@ -324,9 +324,9 @@ describe("PathKit") {
$0.it("errors when you read from a non-existing file as NSData") {
let path = Path("/tmp/pathkit-testing")

try expect {
try expect({
try path.read() as Data
}.toThrow()
}).toThrow()
}

$0.it("can read a String from a file") {
Expand All @@ -339,9 +339,9 @@ describe("PathKit") {
$0.it("errors when you read from a non-existing file as a String") {
let path = Path("/tmp/pathkit-testing")

try expect {
try expect({
try path.read() as String
}.toThrow()
}).toThrow()
}
}

Expand All @@ -364,9 +364,9 @@ describe("PathKit") {
let path = Path("/")
let data = "Hi".data(using: String.Encoding.utf8, allowLossyConversion: true)

try expect {
try expect({
try path.write(data!)
}.toThrow()
}).toThrow()
#endif
}

Expand All @@ -384,9 +384,9 @@ describe("PathKit") {
#else
let path = Path("/")

try expect {
try expect({
try path.write("hi")
}.toThrow()
}).toThrow()
#endif
}
}
Expand Down