0001 #if os(Linux) 0002 import Glibc 0003 #else 0004 import Darwin 0005 #endif 0006 0007 public protocol ByteType{ 0008 static var encodingType: EncodingType { get } 0009 static func fromString(string: String) -> [Self] 0010 } 0011 0012 extension UInt8: ByteType { 0013 public static var encodingType
Data.swift:12 extension UInt8: ByteType {: EncodingType { 0014 return .UTF8 0015 } 0016 0017 public static func fromString(string: String) -> [UInt8] { 0018 let buf = [UInt8](string.utf8) 0019 return buf 0020 } 0021 } 0022 0023 enum EncodingError
Data.swift:60 encoding: UInt8.encodingType.encoding, freeWhenDone: false) else {: ErrorType { 0024 case Failed
Data.swift:61 throw EncodingError.Failed0025 } 0026 0027 public final class Data
Data.swift:61 throw EncodingError.Failed{ 0028 0029 public let bytes
Vaquita.swift:44 handler: (data: Data?, error: ErrorType?) -> ()) {Vaquita.swift:55 public class func readFileSync(path path: String) throws -> Data {Vaquita.swift:70 return Data(bytes: buffer, count: fileLength);Vaquita.swift:73 public class func writeData(data: Data, toFilePath path: String,Vaquita.swift:85 public class func writeDataSync(data: Data, toFilePath path: String) throws {: UnsafeMutablePointer<UInt8> 0030 0031 public var size
Data.swift:38 self.bytes = bytesData.swift:45 self.bytes = string.withCString {Data.swift:59 guard let str = String(bytesNoCopy: &bytes.memory, length: count,Vaquita.swift:90 fwrite(data.bytes, 1, data.size, fileptr): Int { 0032 return count * sizeof(UInt8) 0033 } 0034 0035 let count
Vaquita.swift:90 fwrite(data.bytes, 1, data.size, fileptr): Int 0036 0037 public init
Data.swift:32 return count * sizeof(UInt8)Data.swift:39 self.count = countData.swift:50 self.count = Int(count)Data.swift:59 guard let str = String(bytesNoCopy: &bytes.memory, length: count,(bytes: UnsafeMutablePointer<UInt8>, count: Int) { 0038 self.bytes = bytes 0039 self.count = count 0040 } 0041 0042 public init(string: String) { 0043 var count: UInt = 0 0044 0045 self.bytes = string.withCString { 0046 count = strlen($0) 0047 return UnsafeMutablePointer<UInt8>($0) 0048 } 0049 0050 self.count = Int(count) 0051 } 0052 0053 deinit { 0054 // free(bytes) 0055 } 0056 0057 public func toString() throws -> String { 0058 0059 guard let str = String(bytesNoCopy: &bytes.memory, length: count, 0060 encoding: UInt8.encodingType.encoding, freeWhenDone: false) else { 0061 throw EncodingError.Failed 0062 } 0063 0064 return str 0065 } 0066 } 0067
Vaquita.swift:70 return Data(bytes: buffer, count: fileLength);