os/fs: introduce os_fopen()

Windows: Using fopen() directly may need UTF-16 filepath conversion. To
achieve that, os_fopen() goes through os_open().

fix #10586
This commit is contained in:
Justin M. Keyes
2019-07-23 20:56:27 +02:00
parent 8a9c9a9963
commit bb3a0099c6
3 changed files with 85 additions and 6 deletions

View File

@@ -22,6 +22,7 @@ describe('fileio', function()
os.remove('Xtest_startup_file1')
os.remove('Xtest_startup_file1~')
os.remove('Xtest_startup_file2')
os.remove('Xtest_тест.md')
rmdir('Xtest_startup_swapdir')
end)
@@ -85,7 +86,22 @@ describe('fileio', function()
eq('foobar', foobar_contents);
eq('foo', bar_contents);
end)
it('readfile() on multibyte filename #10586', function()
clear()
local text = {
'line1',
' ...line2... ',
'',
'line3!',
'тест yay тест.',
'',
}
local fname = 'Xtest_тест.md'
funcs.writefile(text, fname, 's')
table.insert(text, '')
eq(text, funcs.readfile(fname, 'b'))
end)
end)