This repository has been archived by the owner on Aug 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/Ranchero-Software/RSWeb int…
…o main
- Loading branch information
Showing
7 changed files
with
1,077 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// Data+Extensions.swift | ||
// PunyCocoa Swift | ||
// | ||
// Created by Nate Weaver on 2020-04-12. | ||
// | ||
|
||
import Foundation | ||
import zlib | ||
|
||
extension Data { | ||
|
||
var crc32: UInt32 { | ||
return self.withUnsafeBytes { | ||
let buffer = $0.bindMemory(to: UInt8.self) | ||
let initial = zlib.crc32(0, nil, 0) | ||
return UInt32(zlib.crc32(initial, buffer.baseAddress, numericCast(buffer.count))) | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// Scanner+Extensions.swift | ||
// PunyCocoa Swift | ||
// | ||
// Created by Nate Weaver on 2020-04-20. | ||
// | ||
|
||
import Foundation | ||
|
||
// Wrapper functions for < 10.15 compatibility | ||
// TODO: Remove when support for < 10.15 is dropped. | ||
extension Scanner { | ||
|
||
func shimScanUpToCharacters(from set: CharacterSet) -> String? { | ||
if #available(macOS 10.15, iOS 13.0, *) { | ||
return self.scanUpToCharacters(from: set) | ||
} else { | ||
var str: NSString? | ||
self.scanUpToCharacters(from: set, into: &str) | ||
return str as String? | ||
} | ||
} | ||
|
||
func shimScanCharacters(from set: CharacterSet) -> String? { | ||
if #available(macOS 10.15, iOS 13.0, *) { | ||
return self.scanCharacters(from: set) | ||
} else { | ||
var str: NSString? | ||
self.scanCharacters(from: set, into: &str) | ||
return str as String? | ||
} | ||
} | ||
|
||
func shimScanUpToString(_ substring: String) -> String? { | ||
if #available(macOS 10.15, iOS 13.0, *) { | ||
return self.scanUpToString(substring) | ||
} else { | ||
var str: NSString? | ||
self.scanUpTo(substring, into: &str) | ||
return str as String? | ||
} | ||
} | ||
|
||
func shimScanString(_ searchString: String) -> String? { | ||
if #available(macOS 10.15, iOS 13.0, *) { | ||
return self.scanString(searchString) | ||
} else { | ||
var str: NSString? | ||
self.scanString(searchString, into: &str) | ||
return str as String? | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.