Skip to content

Add level argument to File.dirname - #6463

Merged
matz merged 2 commits into
mruby:masterfrom
dearblue:dirname
Jan 2, 2025
Merged

Add level argument to File.dirname#6463
matz merged 2 commits into
mruby:masterfrom
dearblue:dirname

Conversation

@dearblue

@dearblue dearblue commented Jan 2, 2025

Copy link
Copy Markdown
Contributor

Please also check the commit message.

The purpose is as follows:

  - Stop using `mrb_locale_from_utf8()`.
      - Because there is no corresponding `mrb_utf8_from_locale()`.
      - Because on Windows, for example, if the code page is 932 (CP932, likely ShiftJIS), it cannot be distinguished from the second byte 0x5c (\), and returns wrong results.
  - Stop using `dirname(3)`.
      - Because leading consecutive slashes are not truncated.
        For example, if `/////a/b` is given, CRuby returns `/a`, but mruby so far returns `/////a`.
      - Because the `path` argument cannot be passed in an immutable form.
  - Stop using `_splitpath()` in the Windows implementation.
      - Because there is no support for UNC paths with up to 32767 characters.
        ref. https://learn.microsoft.com/ja-jp/dotnet/standard/io/file-path-formats#unc-paths
      - Because modifying the result of paths terminated by a directory separator.
        Previously, for example, `C:/` would return `C:.` instead of `C:/`, and `a/b/` would return `a/b` instead of `a`.
@dearblue
dearblue requested a review from matz as a code owner January 2, 2025 09:59
@matz
matz merged commit e35c027 into mruby:master Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants