Use TokenCounter and correct unsafe pointer usage

Record write errors in TokenCounter.Printf and add Println method
to propagate write failures. Route file-read warnings to stderr
instead of mixing them into token output. Use unsafe.Add with a
base pointer when computing the drop target on Windows.
This commit is contained in:
2026-01-31 03:33:36 +01:00
parent 14dfacea29
commit a32b7e4693
3 changed files with 24 additions and 15 deletions
+4 -2
View File
@@ -62,11 +62,13 @@ func CopyFile(path string) error {
return fmt.Errorf("GlobalLock failed")
}
df := (*dropFiles)(unsafe.Pointer(ptrVal))
basePtr := unsafe.Pointer(ptrVal)
df := (*dropFiles)(basePtr)
df.pFiles = dropSize
df.fWide = 1
targetPtr := unsafe.Pointer(ptrVal + uintptr(dropSize))
targetPtr := unsafe.Add(basePtr, dropSize)
srcSlice := unsafe.Slice((*uint16)(unsafe.Pointer(&pathUTF16[0])), len(pathUTF16))
dstSlice := unsafe.Slice((*uint16)(targetPtr), len(pathUTF16))