Yukihiro "Matz" Matsumoto
b7e3b2be72
fix io file time accessor typo
2025-07-18 15:00:44 +09:00
Yukihiro "Matz" Matsumoto
ae39a9e56f
mruby-io (mrb_file_basename): add type cast to fix mixed signedness
2025-06-25 17:47:48 +09:00
John Bampton
383cd6a936
misc: fix spelling word case
2025-06-25 10:46:23 +10:00
Yukihiro Matz Matsumoto
dcd661efb8
File.basename: add support for suffix removal and enhance tests
2025-06-23 22:49:43 +00:00
Yukihiro "Matz" Matsumoto
35fafe57fb
mruby-io: make IO#initialize_copy private
2025-06-16 12:42:22 +09:00
Yukihiro "Matz" Matsumoto
18c43c2a5a
mruby-io: provide Kernel#p in this gem
...
To prevent ordering instability when output from mruby-io and Kernel#p
mixed.
2025-05-19 13:31:01 +09:00
Yukihiro "Matz" Matsumoto
29964b3ba7
mruby-io (mrb_file_size): add check for MRB_32BIT and MRB_INT64
2025-04-14 22:09:33 +09:00
John Bampton
b1d910f6f4
mrbgems: fix spelling
2025-04-04 15:05:13 +10:00
Yukihiro "Matz" Matsumoto
b8351d6191
mruby-io/file.c: use ptrdiff_t for pointer difference
2025-03-24 22:30:53 +09:00
Yukihiro "Matz" Matsumoto
dd2950211c
mruby-io/mruby_io_test.c: use -1 for length (means strlen(s))
2025-03-24 15:19:54 +09:00
Yukihiro "Matz" Matsumoto
4aae7be949
mruby-io (path_gethome): move local variable declarations
2025-03-24 14:03:13 +09:00
Yukihiro "Matz" Matsumoto
a33426da15
mruby-io (mrb_file_s_chmod): check string type before casting
2025-03-23 20:04:25 +09:00
Yukihiro "Matz" Matsumoto
11f6251d23
mruby-io (mrb_file_basename): fixed a silly mistake
2025-03-22 13:01:38 +09:00
Yukihiro "Matz" Matsumoto
aa06aff50d
mruby-io/file.c: use mrb_sys_fail instead of mrb_raise (w/ errno info)
2025-03-22 11:02:05 +09:00
Yukihiro "Matz" Matsumoto
f3b79fcc23
mruby-io (mrb_file_s_readlink): increase buffer size linearly
2025-03-21 19:34:05 +09:00
Yukihiro "Matz" Matsumoto
ca693dec30
mruby-io (mrb_file_s_readlink): when rc == bufsize, rc never be -1
2025-03-21 19:31:12 +09:00
Yukihiro "Matz" Matsumoto
9e315af2a5
mruby-io (mrb_file_basename): fixed wrong strncmp usage
2025-03-21 10:37:05 +09:00
Yukihiro "Matz" Matsumoto
90d4805f5b
mruby-io (mrb_file_realpath): use mrb_str_cat instead of mrb_str_append
2025-03-20 22:04:49 +09:00
Yukihiro "Matz" Matsumoto
5bc391e170
mruby-io (mrb_file_basename): use mrb_str_cat() instead of snprintf(3)
2025-03-20 22:03:30 +09:00
Yukihiro "Matz" Matsumoto
dbafada7be
mruby-io (mrb_file_basename): use "z" specifier for mrb_get_args()
2025-03-20 13:39:38 +09:00
Yukihiro "Matz" Matsumoto
96113a2ed9
mruby-io: define File.absolute_path method; ref #6482
2025-03-08 11:12:12 +09:00
Yukihiro "Matz" Matsumoto
6f97c842d2
mruby-io: use ... for argument forwarding
2025-03-07 17:17:42 +09:00
Yukihiro "Matz" Matsumoto
a736ddcbb7
mruby-io: make some methods private
...
- open
- print
- printf
- gets
2025-03-07 17:17:42 +09:00
Yukihiro "Matz" Matsumoto
bfcc1e3c2c
mruby-io: puts should print nothing for empty arrays
2025-03-07 17:17:38 +09:00
dearblue
c796729fa8
Add File.absolute_path? method
2025-03-05 22:23:49 +09:00
dearblue
f77ebfe102
Reimplementation of File.expand_path method
...
The reason for this is to fix the following problems
- Even on non-Windows, drive letter recognition was still being handled.
- On Windows, paths starting with a slash were not expanded correctly.
- On Windows, relative paths containing drive letters behaved differently than in CRuby.
Due to reimplementation, the internal methods `File._concat_path`, `File._gethome` and `File._getwd` methods have been removed.
2025-02-26 21:55:25 +09:00
dearblue
437065997f
Redefine some macros in mruby-io
...
To improve uniformity of names and definition locations.
2025-02-26 21:55:17 +09:00
Yukihiro "Matz" Matsumoto
b623f5c149
mruby-io: define HAVE_MRUBY_IO_GEM if present; ref #6466
2025-01-14 13:24:16 +09:00
Yukihiro "Matz" Matsumoto
e35c027966
Merge pull request #6463 from dearblue/dirname
2025-01-02 21:58:01 +09:00
dearblue
5c91014530
Add level argument to File.dirname
...
from Ruby-3.1
https://bugs.ruby-lang.org/issues/12194
2025-01-02 18:10:14 +09:00
dearblue
ef11cd94e7
Reimplement the File.dirname method
...
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`.
2025-01-02 17:42:40 +09:00
dearblue
3b659f5320
Properly cast the return value of memchr()
2025-01-02 15:34:36 +09:00
dearblue
7c69a37aa6
FileTest is a module
...
It has been incorrectly defined as a class.
2024-12-23 22:45:47 +09:00
dearblue
ce1abfb2c9
Change MRB_WITH_IO_PREAD_PWRITE configuration name
...
Change to `MRB_USE_IO_PREAD_PWRITE` for consistency with mruby configuration macros.
Similarly, `MRB_WITHOUT_IO_PREAD_PWRITE` is changed to `MRB_NO_IO_PREAD_PWRITE`.
The previous names are available for compatibility but are deprecated.
2024-12-12 22:18:34 +09:00
Yukihiro "Matz" Matsumoto
c495d08c5b
mruby-io (mrb_file__gethome): add casts to stop type warnings
2024-12-12 16:13:56 +09:00
Yukihiro "Matz" Matsumoto
989c133c9f
Merge pull request #6449 from dearblue/presym.2
2024-12-11 10:46:27 +09:00
Yukihiro "Matz" Matsumoto
a77e917d78
Merge pull request #6448 from dearblue/presym.1
2024-12-11 10:08:22 +09:00
Yukihiro "Matz" Matsumoto
19cb0fc374
Merge pull request #6447 from dearblue/File.expand_path
...
Fixed `File.expand_path`
2024-12-10 13:54:46 +09:00
dearblue
27082d143c
Using presym in the mruby-io/src/file_test.c file
2024-12-09 22:09:15 +09:00
dearblue
384db9054d
Suppress presym in mruby/ext/io.h file
...
When defining macro constants for error classes in public header files, it is preferable to use `MRB_ERROR_SYM()`.
2024-12-09 22:05:01 +09:00
dearblue
88e3ce1b58
Fix File.expand_path for Windows
...
- The inner method `File._gethome` could be read as intending to use the `USERPROFILE` environment variable instead on Windows when the `HOME` environment variable is not available.
In reality, however, this was not the case.
- The result of `File.expand_path` should unify path separators with `/`, but it did not.
2024-12-08 10:43:20 +09:00
dearblue
06bb54d380
Improved File.expand_path test in `mruby-io
...
Since `mruby-io` does not depend on `mruby-env` even for test builds, it is impossible that `ENV` constants are defined.
Therefore, define `MRubyIOTestUtil::ENV_HOME` for alternative use.
2024-12-08 10:43:20 +09:00
dearblue
1326017d1d
Omit the _WIN64 definition check
...
Checking the official MSVC documentation, if `_WIN64` is defined, then `_WIN32` is also defined.
https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros
I could not find any documentation on MinGW, but I assume it is not a problem.
2024-12-07 22:47:28 +09:00
dearblue
a92b97ff45
Improve compliance with C++ standards
...
- Avoid "Designated initializer"
C++20 is required for C++.
- Avoid "Compound literals"
Not available for C++.
2024-11-05 22:07:53 +09:00
ArtSin
0afc7ae13b
io_read: use %i instead of %d in call to mrb_raisef
...
`length` is `mrb_int`, not `int`.
2024-11-04 13:56:46 +04:00
Yukihiro "Matz" Matsumoto
a38dd0c988
Merge pull request #6350 from dearblue/io-filepath
2024-09-11 07:10:45 +09:00
dearblue
9cb42438e1
Remove unnecessary mrb_gc_arena_restore()
...
When a function defined as a method returns, there is no need to call `mrb_gc_arena_restore()` immediately before it.
2024-09-10 21:45:44 +09:00
dearblue
33cf729a39
Fixed character encoding conversion function mismatch
2024-09-10 21:34:05 +09:00
Yukihiro "Matz" Matsumoto
1d12097bae
mruby-io (mrb_file__gethome): allow avoiding getpwnam(3); ref #5358
...
You have to define `MRB_IO_NO_PWNAM` to skip calling getpwname(3).
2024-09-03 15:27:29 +09:00
Yukihiro "Matz" Matsumoto
7be10097a0
mruby-io: use presym for initialization
2024-06-14 02:00:17 +09:00