Project

General

Profile

Bug #11320

reopening stdio streams with non-ANSI filenames fails on Windows

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

Status:
Closed
Priority:
Normal
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.

Associated revisions

Revision 93446fed
Added by nobu (Nobuyoshi Nakada) over 4 years ago

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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 51069
Added by nobu (Nobuyoshi Nakada) over 4 years ago

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.

Revision 51069
Added by nobu (Nobuyoshi Nakada) over 4 years ago

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.

Revision 51069
Added by nobu (Nobuyoshi Nakada) over 4 years ago

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.

Revision 51069
Added by nobu (Nobuyoshi Nakada) over 4 years ago

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.

Revision 51069
Added by nobu (Nobuyoshi Nakada) over 4 years ago

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.

Revision 3e5988b2
Added by nobu (Nobuyoshi Nakada) over 4 years ago

file.c: _wfreopen_s on mingw

  • win32/file.c: some mingw compilers need a tweek for the declarations of _wfreopen_s. [Bug #11320]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 51117
Added by nobu (Nobuyoshi Nakada) over 4 years ago

file.c: _wfreopen_s on mingw

  • win32/file.c: some mingw compilers need a tweek for the declarations of _wfreopen_s. [Bug #11320]

Revision 51117
Added by nobu (Nobuyoshi Nakada) over 4 years ago

file.c: _wfreopen_s on mingw

  • win32/file.c: some mingw compilers need a tweek for the declarations of _wfreopen_s. [Bug #11320]

Revision 51117
Added by nobu (Nobuyoshi Nakada) over 4 years ago

file.c: _wfreopen_s on mingw

  • win32/file.c: some mingw compilers need a tweek for the declarations of _wfreopen_s. [Bug #11320]

Revision 51117
Added by nobu (Nobuyoshi Nakada) over 4 years ago

file.c: _wfreopen_s on mingw

  • win32/file.c: some mingw compilers need a tweek for the declarations of _wfreopen_s. [Bug #11320]

Revision 51117
Added by nobu (Nobuyoshi Nakada) over 4 years ago

file.c: _wfreopen_s on mingw

  • win32/file.c: some mingw compilers need a tweek for the declarations of _wfreopen_s. [Bug #11320]

Revision e60d35e3
Added by nobu (Nobuyoshi Nakada) over 4 years ago

win32/file.c: use allocv buffer and API

  • win32/file.c (rb_freopen): convert path name into allocv buffer and get rid of conversion failure in the case non-terminated string. [ruby-core:69780] [Bug #11320]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 51469
Added by nobu (Nobuyoshi Nakada) over 4 years ago

win32/file.c: use allocv buffer and API

  • win32/file.c (rb_freopen): convert path name into allocv buffer and get rid of conversion failure in the case non-terminated string. [ruby-core:69780] [Bug #11320]

Revision 51469
Added by nobu (Nobuyoshi Nakada) over 4 years ago

win32/file.c: use allocv buffer and API

  • win32/file.c (rb_freopen): convert path name into allocv buffer and get rid of conversion failure in the case non-terminated string. [ruby-core:69780] [Bug #11320]

Revision 51469
Added by nobu (Nobuyoshi Nakada) over 4 years ago

win32/file.c: use allocv buffer and API

  • win32/file.c (rb_freopen): convert path name into allocv buffer and get rid of conversion failure in the case non-terminated string. [ruby-core:69780] [Bug #11320]

Revision 51469
Added by nobu (Nobuyoshi Nakada) over 4 years ago

win32/file.c: use allocv buffer and API

  • win32/file.c (rb_freopen): convert path name into allocv buffer and get rid of conversion failure in the case non-terminated string. [ruby-core:69780] [Bug #11320]

Revision 51469
Added by nobu (Nobuyoshi Nakada) over 4 years ago

win32/file.c: use allocv buffer and API

  • win32/file.c (rb_freopen): convert path name into allocv buffer and get rid of conversion failure in the case non-terminated string. [ruby-core:69780] [Bug #11320]

History

#1

Updated by nobu (Nobuyoshi Nakada) over 4 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.

Also available in: Atom PDF