Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ext/etc/etc.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,16 @@ etc_getgrent(VALUE obj)
VALUE rb_w32_special_folder(int type);
UINT rb_w32_system_tmpdir(WCHAR *path, UINT len);
VALUE rb_w32_conv_from_wchar(const WCHAR *wstr, rb_encoding *enc);
#elif defined(LOAD_RELATIVE)
static inline VALUE
rbconfig(void)
{
VALUE config;
rb_require("rbconfig");
config = rb_const_get(rb_path2class("RbConfig"), rb_intern("CONFIG"));
Check_Type(config, T_HASH);
return config;
}
#endif

/* call-seq:
Expand All @@ -710,6 +720,8 @@ etc_sysconfdir(VALUE obj)
{
#ifdef _WIN32
return rb_w32_special_folder(CSIDL_COMMON_APPDATA);
#elif defined(LOAD_RELATIVE)
return rb_hash_aref(rbconfig(), rb_str_new_lit("sysconfdir"));
#else
return rb_filesystem_str_new_cstr(SYSCONFDIR);
#endif
Expand Down
4 changes: 4 additions & 0 deletions test/etc/test_etc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ def test_nprocessors
assert_operator(1, :<=, n)
end

def test_sysconfdir
assert_operator(File, :absolute_path?, Etc.sysconfdir)
end if File.method_defined?(:absolute_path?)

def test_ractor
return unless Etc.passwd # => skip test if no platform support
Etc.endpwent
Expand Down