Add save file option for profile sharing

Add "Save File" and "Save Content JSON" options to profile share menu,
allowing users to save profiles directly to a chosen location using
fileExporter instead of the system share sheet.
This commit is contained in:
世界
2026-01-01 20:25:28 +08:00
parent 55e01a89b5
commit 313cb5d213
11 changed files with 1674 additions and 26 deletions
@@ -0,0 +1,28 @@
import Foundation
enum CRC32 {
private static let table: [UInt32] = {
var table = [UInt32](repeating: 0, count: 256)
for i in 0 ..< 256 {
var crc = UInt32(i)
for _ in 0 ..< 8 {
if crc & 1 != 0 {
crc = (crc >> 1) ^ 0xEDB8_8320
} else {
crc = crc >> 1
}
}
table[i] = crc
}
return table
}()
static func checksum(_ data: Data, k: Int) -> UInt32 {
var crc: UInt32 = 0xFFFF_FFFF
for byte in data {
let index = Int((crc ^ UInt32(byte)) & 0xFF)
crc = (crc >> 8) ^ table[index]
}
return crc ^ UInt32(k) ^ 0xFFFF_FFFF
}
}