Project

General

Profile

Actions

Bug #11320

closed

reopening stdio streams with non-ANSI filenames fails on Windows

Added by cremno (cremno phobia) over 8 years ago. Updated over 8 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:69780]

Description

fname = 'ルビー'
File.write(fname, '')
p File.exist?(fname)
$stdin.reopen(fname, 'r')

It fails with Errno::ENOENT on Windows even though the file exists and is readable. It's caused by using freopen() (https://github.com/ruby/ruby/blob/v2_2_2/io.c#L6765). A wrapper that converts to UTF-16LE and then calls wfreopen() has to be added to win32/win32.c.

Actions #1

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

  • Status changed from Open to Closed

Applied in changeset r51069.


io.c: reopen OS encoding path

  • io.c (rb_io_reopen): freopen(3) with OS encoding path.
    [ruby-core:69780] [Bug #11320]
  • win32/file.c (rb_freopen): wrapper of wchar version freopen(3).
    use _wfreopen_s() if available.
Actions

Also available in: Atom PDF

Like0
Like0