Open q962 opened 1 month ago
Bot detected the issue body's language is not English, translate it automatically.
Title: io.open does not support r+
xmake v2.9.5+HEAD.d30de52e9
windows10 22H2
io.open does not support r+
Unable to modify file
-
file = io.open("r.lua", "r+")
print(file)
file:seek('set', 0)
print(file)
file:write(string.char(0x22))
print(file)
file:close()
print(file)
file(780.000B) "r.lua"
file(780.000B) "r.lua"
file(780.000B) "r.lua"
error: @programdir\core\main.lua:329: ...mdir\core\sandbox\modules\import\core\sandbox\module.lua:563: cannot import module: r, stack traceback:
[C]: in function 'error'
[@programdir\core\base\os.lua:1015]:
[@programdir\core\sandbox\modules\io.lua:56]: in function 'close'
[.\r.lua:32]: in function 'a'
[.\r.lua:38]: in main chunk
stack traceback:
[C]: in function 'error'
@programdir\core\base\os.lua:1004: in function 'base/os.raiselevel'
(...tail calls...)
@programdir\core\main.lua:329: in upvalue 'cotask'
@programdir\core\base\scheduler.lua:406: in function <@programdir\core\base\scheduler.lua:399>
不支持
会打算支持吗?
不打算的话,那能否暴露 lua 原生 os ?
直接用 w
不行么。
不打算的话,那能否暴露 lua 原生 os ?
不考虑,我全部重写的,原生 io 连 unicode 都不支持
我是要修改二进制文件的,所以无关编码
不行,文件被截断。我尝试过了
function a()
local filePath = "r.lua"
local file = io.open(filePath, "wb")
-- file:seek('set', 2)
file:write(string.char(0x22))
file:close()
end
a()
Bot detected the issue body's language is not English, translate it automatically.
Will you plan to support it?
If not, can the native OS of Lua be exposed?
Bot detected the issue body's language is not English, translate it automatically.
Not supported
Bot detected the issue body's language is not English, translate it automatically.
Can't you just use
w
directly?If not, can Lua native OS be exposed?
Regardless, I rewrote everything. Native io doesn’t even support unicode.
我是要修改二进制文件的,所以无关编码
我知道,但是我不可能为了支持你这一个需求,重新暴露 lua 原生 io ,废弃掉当前的实现,让其他 99% 的读写,都支持不了 unicode
不行,文件被截断。我尝试过了
那目前不支持,只能等后面有空了再看看了。
Bot detected the issue body's language is not English, translate it automatically.
I want to modify the binary file, so the encoding has nothing to do with it
I know, but in order to support your demand, I may re-expose Lua's native io, abandon the current implementation, and make the other 99% of reading and writing unable to support unicode
Bot detected the issue body's language is not English, translate it automatically.
No, the file is truncated. i tried
That’s not supported at the moment, so we’ll have to wait and see when we have time later.
试下这个 patch https://github.com/xmake-io/xmake/pull/5724
不过二进制写入要加 b
,用 r+b
我咋试?
github actions 不是可以下载结果的吗?为啥你这个没有下载列表。
xmake update github:xmake-io/xmake#io
我咋试?
github actions 不是可以下载结果的吗?为啥你这个没有下载列表。
这不是有的么 https://github.com/xmake-io/xmake/actions/runs/11366002478?pr=5724
咋还报 : not support to update from unofficial source on windows, missing '--scriptonly' flag?
哦哦,在 windows 里,晓得了。我在 msys2 里找没找到。
Bot detected the issue body's language is not English, translate it automatically.
How should I try?
Isn't it possible to download the results from github actions? Why don't you have a download list?
还是不行,存在一个有趣的错误
使用 r+b 模式下,先读后写会导致写无效,无事发生。
Bot detected the issue body's language is not English, translate it automatically.
Still not working, there is an interesting bug
In r+b mode, reading first and then writing will cause the writing to be invalid and nothing will happen.
Xmake 版本
xmake v2.9.5+HEAD.d30de52e9
操作系统版本和架构
windows10 22H2
描述问题
io.open 不支持 r+
r+b 不报错,但是不会修改文件
期待的结果
-
工程配置
附加信息和错误日志