mirror of
https://github.com/skidoodle/ctx.git
synced 2026-04-28 03:07:41 +02:00
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:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user