ref: 960f567d8fa9d3a294e9b2c081f4eede5108b5d0
parent: 44ac90449fa714efd31996e60d7e578e02ac91e5
author: halfwit <michaelmisch1985@gmail.com>
date: Mon Dec 1 15:52:03 EST 2025
Push up a bit of code
--- a/Sources/NineSwift/Connection.swift
+++ b/Sources/NineSwift/Connection.swift
@@ -1,6 +1,6 @@
//
// Connection.swift
-// Altid - Connect with a service over 9p
+// Connect with a service over 9p
//
// Created by halfwit on 2024-01-03.
//
@@ -144,6 +144,7 @@
func open(_ wname: String, mode: nineMode, callback: @escaping (Handle) -> Void) {var handle = Handle(fid: 1, tag: 0, name: wname)
+
Again:
for h in handles {/* Walk it off the end of the chain, or pop it in a hole */
--- a/Sources/NineSwift/Handle.swift
+++ b/Sources/NineSwift/Handle.swift
@@ -1,6 +1,5 @@
//
// Handle.swift
-// Altid
//
// Created by halfwit on 2024-01-22.
//
--- a/Sources/NineSwift/NineProtocol.swift
+++ b/Sources/NineSwift/NineProtocol.swift
@@ -1,6 +1,6 @@
//
// NineProtocol.swift
-// Altid - 9p implementation
+// 9p implementation
//
// Created by halfwit on 2024-01-03.
//
@@ -344,7 +344,7 @@
var iounit: UInt32 { get {- if let val = self["fid"] as? UInt32 {+ if let val = self["iounit"] as? UInt32 {return val
}
return 0
@@ -457,7 +457,7 @@
w32(&data, input: length)
w8(&data, input: nineType.Tattach.rawValue)
w16(&data, input: 0)
- w32(&data, input: 0)
+ w32(&data, input: fid)
w32(&data, input: afid)
wstr(&data, input: uname)
wstr(&data, input: aname)
@@ -776,7 +776,6 @@
w32(&data, input: stat.mtime)
w64(&data, input: stat.length)
wstr(&data, input: stat.name)
- wstr(&data, input: stat.name)
wstr(&data, input: stat.uid)
wstr(&data, input: stat.gid)
wstr(&data, input: stat.muid)
@@ -810,33 +809,26 @@
}
func wstr(_ data: inout Data, input: Data) {- let rev = input.reversed()
w16(&data, input: UInt16(input.count))
if input.count == 0 {return
}
- // Write out the rest of our bytes
- for i in 0...rev.count - 1 {- var tempInput = input[i]
- data.append(Data(bytes: &tempInput, count: MemoryLayout<UInt8>.size))
-
+ for byte in input.reversed() {+ data.append(byte)
}
}
func wdata(_ data: inout Data, input: Data) {- let rev = input.reversed()
- // Write out the rest of our bytes
w32(&data, input: UInt32(input.count))
if input.count == 0 {return
}
- for i in 0...rev.count - 1 {- var tempInput = input[i]
- data.append(Data(bytes: &tempInput, count: MemoryLayout<UInt8>.size))
-
+ for byte in input.reversed() {+ data.append(byte)
}
}
+
func r8(buffer: UnsafeMutableRawBufferPointer, _ base: inout Int) -> UInt8 { defer {base += 1
@@ -918,7 +910,7 @@
}
private extension Data {- public var bytes: [UInt8]
+ var bytes: [UInt8]
{return [UInt8](self)
}
--- a/Sources/NineSwift/Queue.swift
+++ b/Sources/NineSwift/Queue.swift
@@ -1,6 +1,5 @@
//
// Queue.swift
-// Altid
//
// Created by halfwit on 2024-01-22.
//
--
⑨