diff --git a/FoundationExtras/Sources/FoundationExtras/Calendar+RSCore.swift b/FoundationExtras/Sources/FoundationExtras/Calendar+RSCore.swift index 9de5e199d..c59d1263e 100644 --- a/FoundationExtras/Sources/FoundationExtras/Calendar+RSCore.swift +++ b/FoundationExtras/Sources/FoundationExtras/Calendar+RSCore.swift @@ -21,10 +21,4 @@ public extension Calendar { static func dateIsToday(_ date: Date) -> Bool { return cached.isDateInToday(date) } - - /// The first moment of today. - static var startOfToday: Date { - cached.startOfDay(for: Date()) - } - } diff --git a/FoundationExtras/Sources/FoundationExtras/Character+RSCore.swift b/FoundationExtras/Sources/FoundationExtras/Character+RSCore.swift deleted file mode 100644 index 233de03ee..000000000 --- a/FoundationExtras/Sources/FoundationExtras/Character+RSCore.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// Character+RSCore.swift -// RSCore -// -// Created by Maurice Parker on 4/20/20. -// Copyright © 2020 Ranchero Software, LLC. All rights reserved. -// - -import Foundation - -public extension Character { - - var isSimpleEmoji: Bool { - guard let firstScalar = unicodeScalars.first else { return false } - return firstScalar.properties.isEmoji && firstScalar.value > 0x238C - } - - var isCombinedIntoEmoji: Bool { unicodeScalars.count > 1 && unicodeScalars.first?.properties.isEmoji ?? false } - - var isEmoji: Bool { isSimpleEmoji || isCombinedIntoEmoji } -} diff --git a/FoundationExtras/Sources/FoundationExtras/Data+RSCore.swift b/FoundationExtras/Sources/FoundationExtras/Data+RSCore.swift index 18211d012..a88136f4e 100644 --- a/FoundationExtras/Sources/FoundationExtras/Data+RSCore.swift +++ b/FoundationExtras/Sources/FoundationExtras/Data+RSCore.swift @@ -7,40 +7,15 @@ // import Foundation -#if canImport(CryptoKit) import CryptoKit -#endif -import CommonCrypto public extension Data { /// The MD5 hash of the data. var md5Hash: Data { - #if canImport(CryptoKit) - if #available(macOS 10.15, *) { - let digest = Insecure.MD5.hash(data: self) - return Data(digest) - } else { - return ccMD5Hash - } - #else - return ccMD5Hash - #endif - - } - - @available(macOS, deprecated: 10.15) - @available(iOS, deprecated: 13.0) - private var ccMD5Hash: Data { - let len = Int(CC_MD5_DIGEST_LENGTH) - let md = UnsafeMutablePointer.allocate(capacity: len) - - let _ = self.withUnsafeBytes { - CC_MD5($0.baseAddress, numericCast($0.count), md) - } - - return Data(bytes: md, count: len) + let digest = Insecure.MD5.hash(data: self) + return Data(digest) } /// The MD5 has of the data, as a hexadecimal string. diff --git a/FoundationExtras/Sources/FoundationExtras/FileManager+RSCore.swift b/FoundationExtras/Sources/FoundationExtras/FileManager+RSCore.swift index 21759ee56..69a90c310 100644 --- a/FoundationExtras/Sources/FoundationExtras/FileManager+RSCore.swift +++ b/FoundationExtras/Sources/FoundationExtras/FileManager+RSCore.swift @@ -10,7 +10,6 @@ import Foundation public extension FileManager { - /// Returns whether a path refers to a folder. /// /// - Parameter path: The file path to check. @@ -27,35 +26,6 @@ public extension FileManager { return false } - /// Copies files from one folder to another, overwriting any existing files with the same name. - /// - /// - Parameters: - /// - source: The path of the folder from which to copy files. - /// - destination: The path to the folder at which to place the copied files. - /// - /// - Note: This function does not copy files whose names begin with a period. - func copyFiles(fromFolder source: String, toFolder destination: String) throws { - assert(isFolder(atPath: source)) - assert(isFolder(atPath: destination)) - - let sourceURL = URL(fileURLWithPath: source) - let destinationURL = URL(fileURLWithPath: destination) - - let filenames = try self.contentsOfDirectory(atPath: source) - - for oneFilename in filenames { - if oneFilename.hasPrefix(".") { - continue - } - - let sourceFile = sourceURL.appendingPathComponent(oneFilename) - let destinationFile = destinationURL.appendingPathComponent(oneFilename) - - try copyFile(atPath: sourceFile.path, toPath: destinationFile.path, overwriting: true) - } - - } - /// Retrieve the names of files contained in a folder. /// /// - Parameter folder: The path to the folder whose contents to retrieve. @@ -86,27 +56,4 @@ public extension FileManager { let url = URL(fileURLWithPath: folder) return filenames.map { url.appendingPathComponent($0).path } } - -} - -private extension FileManager { - - /// Copies a single file, possibly overwriting any existing file. - /// - /// - Parameters: - /// - source: The source path. - /// - destination: The destination path. - /// - overwriting: `true` if an existing file at `destination` should be overwritten. - func copyFile(atPath source: String, toPath destination: String, overwriting: Bool) throws { - assert(fileExists(atPath: source)) - - if fileExists(atPath: destination) { - if (overwriting) { - try removeItem(atPath: destination) - } - } - - try copyItem(atPath: source, toPath: destination) - } - } diff --git a/FoundationExtras/Sources/FoundationExtras/PropertyList.swift b/FoundationExtras/Sources/FoundationExtras/PropertyList.swift deleted file mode 100644 index 2246b0e5b..000000000 --- a/FoundationExtras/Sources/FoundationExtras/PropertyList.swift +++ /dev/null @@ -1,32 +0,0 @@ -// -// PropertyList.swift -// RSCore -// -// Created by Brent Simmons on 7/12/17. -// Copyright © 2017 Ranchero Software, LLC. All rights reserved. -// - -import Foundation - -// These functions eat errors. - -public func propertyList(withData data: Data) -> Any? { - - do { - return try PropertyListSerialization.propertyList(from: data, options: [], format: nil) - } catch { - return nil - } -} - -// Create a binary plist. - -public func data(withPropertyList plist: Any) -> Data? { - - do { - return try PropertyListSerialization.data(fromPropertyList: plist, format: .binary, options: 0) - } - catch { - return nil - } -} diff --git a/FoundationExtras/Sources/FoundationExtras/Set+Extensions.swift b/FoundationExtras/Sources/FoundationExtras/Set+Extensions.swift index 4e127e0bb..c936b4c83 100755 --- a/FoundationExtras/Sources/FoundationExtras/Set+Extensions.swift +++ b/FoundationExtras/Sources/FoundationExtras/Set+Extensions.swift @@ -10,15 +10,6 @@ import Foundation public extension Set { - func anyObjectPassingTest( _ test: (Element) -> Bool) -> Element? { - - guard let index = self.firstIndex(where: test) else { - return nil - } - - return self[index] - } - func anyObject() -> Element? { if self.isEmpty { diff --git a/FoundationExtras/Sources/FoundationExtras/String+RSCore.swift b/FoundationExtras/Sources/FoundationExtras/String+RSCore.swift index 12fd2d172..3d0c141d3 100644 --- a/FoundationExtras/Sources/FoundationExtras/String+RSCore.swift +++ b/FoundationExtras/Sources/FoundationExtras/String+RSCore.swift @@ -353,17 +353,3 @@ public extension String { } } - -public extension String { - var isSingleEmoji: Bool { count == 1 && containsEmoji } - - var containsEmoji: Bool { contains { $0.isEmoji } } - - var containsOnlyEmoji: Bool { !isEmpty && !contains { !$0.isEmoji } } - - var emojiString: String { emojis.map { String($0) }.reduce("", +) } - - var emojis: [Character] { filter { $0.isEmoji } } - - var emojiScalars: [UnicodeScalar] { filter { $0.isEmoji }.flatMap { $0.unicodeScalars } } -}