【发布时间】:2021-06-12 19:44:06
【问题描述】:
我有一个二进制文件 我试图在文件中间添加一个字符串 (让我们说在 10 个字节之后)
我成功地用我的字符串覆盖了文件 - 但不是追加 如果有人能告诉我如何附加字符串,不胜感激。
这是我的代码示例:
proc write_bit_header {} {
set bit_hdr "#Here is my new string to be added#"
set bit_hdr_len [string length ${bit_hdr}]
set outBinData [binary format a${bit_hdr_len} ${bit_hdr}]
set fp [open "binfile" "a+b"]
fconfigure $fp -translation binary
seek $fp 10
puts -nonewline $fp $outBinData
close $fp
}
【问题讨论】: