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
import Foundation | |
import TabularData | |
/// OpenStep 格式 Property List 工具集。 | |
/// | |
/// OpenStep 格式 Property List 也称 ASCII Property List 或旧版 Property List。 | |
public enum OldStylePropertyList { | |
// MARK: Property List | |
/// 将 `String` (`NSString`) 转为 OpenStep Property List 输出格式。 |
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
import Foundation | |
/// 递增(正)计时器,基于 `DispatchSource` 和 `CLOCK_MONOTONIC_RAW`,必须在主线程使用。 | |
@MainActor | |
public class CountingTimer { | |
/// 计时原点:创建时刻或上次重置时刻。此数值为系统底层时钟周期,只能通过多次获取后计算时长(单位:纳秒)而不能用于确定当前日期时间。 | |
public private(set) var origin: UInt64 | |
/// 回调间隔。修改间隔时间将以当前时刻重新计算间隔,而非顺延上次回调后已经经过的时间。 | |
public var interval: TimeInterval { |
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
import Foundation | |
import ArgumentParser | |
public enum Path { | |
static let path = ProcessInfo.processInfo.environment["PATH"]!.components(separatedBy: ":") | |
public static func find(_ command: String) throws -> URL { | |
let files = FileManager.default | |
for path in Self.path { | |
let executable = URL(fileURLWithPath: path).appendingPathComponent(command, isDirectory: false) |
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
import AppleArchive | |
import CryptoKit | |
import Foundation | |
import System | |
public enum AA { | |
public static let version = Int(APPLE_ARCHIVE_API_VERSION) | |
static let fields = ArchiveHeader.FieldKeySet("TYP,PAT,LNK,DEV,UID,GID,MOD,FLG,MTM,CTM,SH2,DAT,SIZ")! |
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
import CommonCrypto | |
import CryptoKit | |
import Foundation | |
// MARK: - AES.CBC | |
public extension AES { | |
enum CBC {} | |
} |
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
import UIKit | |
open class UITableViewPlus: UITableView, UITableViewDelegate { | |
// MARK: Scroll | |
override public init(frame: CGRect, style: UITableView.Style) { | |
super.init(frame: frame, style: style) | |
super.delegate = self | |
} |
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
import UIKit | |
open class UICollectionViewPlus: UICollectionView, UICollectionViewDelegate { | |
// MARK: Scroll | |
override public init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) { | |
super.init(frame: frame, collectionViewLayout: layout) | |
super.delegate = self | |
} |
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
import Foundation | |
import Network | |
public typealias TCPClient = TCPConnection | |
/// TCP 节点(客户端)连接 | |
/// | |
/// 由于 TCP 是全双工通讯,服务端也需要作为节点建立连接。 | |
public final class TCPConnection: Sendable { | |
let queue: DispatchQueue |
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
import Foundation | |
import Network | |
/// TCP 监听(服务端) | |
public final class TCPServer: Sendable { | |
let queue: DispatchQueue | |
let listener: NWListener | |
public init(port: Int) throws { | |
guard let unsigned = UInt16(exactly: port), let port = NWEndpoint.Port(rawValue: unsigned) else { |
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
#!/usr/bin/swift | |
import Foundation | |
import Security | |
let manager = FileManager.default | |
// Print usage if called with no arguments. | |
var inputs = CommandLine.arguments | |
if let command = inputs.first { |
OlderNewer