aboutsummaryrefslogtreecommitdiffstats
path: root/dir.c
Commit message (Collapse)AuthorAgeFilesLines
* win32.c: rb_dir_getwd_ospathnobu2017-06-121-4/+3
| | | | | | | * win32/win32.c (rb_dir_getwd_ospath): Windows implementation moved from dir.c. get rid of freeing malloced memory by xfree. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* file.c: realpath in OS path encodingnobu2017-06-081-9/+24
| | | | | | | | | * dir.c (rb_dir_getwd_ospath): return cwd path in the OS path encoding. * file.c (rb_realpath_internal): work in the OS path encoding git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* make Dir object WB protected.ko12017-06-011-5/+5
| | | | | | | | * dir.c (dir_data_type): set RUBY_TYPED_WB_PROTECTED. Insert WBs for dir_data::path. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: fix FD leaksnobu2017-05-271-2/+2
| | | | | | | * dir.c (do_opendir): close FD when fdopendir failed, e.g., ENOTDIR. [Feature#13056] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: yield without base partnobu2017-05-261-11/+22
| | | | | | | * dir.c (glob_helper): yield globbed part only without the base directory path part if the base is given. [Feature#13056] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: document base keyword argument of Dir.globstomar2017-05-251-9/+18
| | | | | | | * dir.c: [DOC] document the new `base` keyword argument of Dir.glob [Feature #13056]; also improve docs for Dir.glob and Dir[]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: docs for Dir.each_child and Dir.childrenstomar2017-05-251-2/+2
| | | | | | * dir.c: [DOC] fix examples for Dir.each_child and Dir.children. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: Dir.each_child and Dir.childrennobu2017-05-251-4/+81
| | | | | | | | * dir.c (dir_s_each_child, dir_s_children): Dir.each_child and Dir.children which are similar to Dir.foreach and Dir.entries respectively, except to exclude "." and "..". [Feature #11302] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: dir_each_entriesnobu2017-05-251-3/+25
| | | | | | * dir.c (dir_each_entries): expand entries without method calls. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: prefer NAMLEN to d_namenobu2017-05-241-5/+5
| | | | | | | * dir.c (glob_helper): prefer NAMLEN, do not assume d_name is NUL terminated everywhere. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Dir as base optionnobu2017-05-231-21/+83
| | | | | | | * dir.c (glob_helper): support Dir instance as `base` option. [Feature#13056] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Dir.glob base optionnobu2017-05-231-21/+56
| | | | | | | * dir.c (dir_s_aref, dir_s_glob): add new optional keyword argument, `base`. [Feature#13056] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* potential memory leaknobu2017-05-181-0/+6
| | | | | | | | * dir.c (rb_dir_getwd): get rid of potential memory leak. * util.c (ruby_getcwd): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* rb_w32_ugetcwd: UTF-8 version getcwdnobu2017-05-161-1/+7
| | | | | | | | | * dir.c (rb_dir_getwd): convert from UTF-8. * win32/win32.c (w32_getcwd): codepage aware getcwd using GetCurrentDirectoryW. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: [DOC] Properly refer to keyword argument by its name [Fix GH-1543]ktsj2017-05-041-4/+4
| | | | | | | | | | | | enc is the name of the variable used in the example, not the name of the keyword argument (encoding). The documentation used to wrongly suggest that the keyword argument name was "enc" which could cause people try try to call `Dir.open("thing", enc: "utf-8")` Author: Olivier Lacan <hi@olivierlacan.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: err at glob failurenobu2017-03-271-19/+100
| | | | | | | | | | | | | * dir.c (glob_helper): raise a SystemCallError exception when opendir() failed, except for ENOENT, ENOTDIR, and EACCES. this behavior predates 1.0; the comments in glob.c claimed that glob() returned -1 on error but actualy the pointer to a global variable, then dir_glob() did check only -1 as the comments, and ignored actual errors. [ruby-core:80226] [Bug #13276] dir.c: ruby_glob_funcs_t git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* remove branches in dmark and dfree GC callbacksnormal2017-03-171-3/+2
| | | | | | | | | | | | | | | | | dmark and dfree callbacks are never called in gc.c for NULL DATA_PTR values, not even for zombie objects. * compile.c (ibf_loader_mark): remove branch for pointer validity * compile.c (ibf_loader_free): ditto * cont.c (cont_free): ditto * cont.c (fiber_free): ditto * dir.c (dir_free): ditto * ext/stringio/stringio.c (strio_mark): ditto * proc.c (binding_free): ditto * thread_sync.c (mutex_free): ditto * vm.c (thread_free): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: getattrlist on OSX 10.5nobu2017-01-011-2/+12
| | | | | | | * dir.c (is_case_sensitive): use getattrlist() if fgetattrlist() is unavailable, on OSX 10.5. [ruby-core:68829] [Bug #11054] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57248 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: merge rb_glob2 into rb_globnobu2016-11-051-17/+6
| | | | | | * dir.c (rb_glob): merge rb_glob2 which is used only here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: suppress a warningnobu2016-10-311-1/+1
| | | | | | | * dir.c (to_be_ignored): remove duplicate inline modifier, and suppress a warning by VC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: retry glob with GCnobu2016-10-211-2/+13
| | | | | | | * dir.c (do_opendir): retry after GC when the limit for open file descriptors reached. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56467 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: use rb_gc_for_fdnobu2016-10-211-4/+3
| | | | | | | * dir.c (rb_dir_s_empty_p): use rb_gc_for_fd for the condition to invoke GC by errno. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: inline to_be_ignorednobu2016-10-211-1/+6
| | | | | | | * dir.c (to_be_ignored): make an inline function to get rid of multiple errno function calls. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* prefer rb_syserr_failnobu2016-10-211-4/+6
| | | | | | | | | * dir.c (dir_initialize, dir_read): prefer rb_syserr_fail over rb_sys_fail. * io.c (ruby_dup, rb_sysopen): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56464 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* rb_funcallvnobu2016-07-291-1/+1
| | | | | | | * *.c: rename rb_funcall2 to rb_funcallv, except for extensions which are/will be/may be gems. [Fix GH-1406] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Name USE_NAME_ON_FS constantsnobu2016-06-201-9/+14
| | | | | | | | | | * dir.c (USE_NAME_ON_FS): name constants. * USE_NAME_ON_FS_REAL_BASENAME: platform dependent APIs to get real basenames. * USE_NAME_ON_FS_BY_FNMATCH: select the matching basename by fnmatch. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c (dir_close): update RDoc for 2.3 #close changenormal2016-05-221-2/+2
| | | | | | [ruby-core:75679] [Bug #12413] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: paths as UTF-8nobu2016-02-201-3/+3
| | | | | | | | * dir.c (push_pattern, push_glob): deal with read paths as UTF-8 to stat later, on Windows as well as OS X. [ruby-core:73868] [Bug #12081] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: Dir.empty?nobu2016-02-161-0/+91
| | | | | | | * dir.c (rb_dir_s_empty_p): add Dir.empty? method, which tells the argument is the name of an empty directory. [Feature #10121] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * compile.c: fix typos.hsbt2015-12-141-1/+1
| | | | | | | | | | | | | [ci skip][fix GH-1140] Patch by @jutaz * dir.c: ditto. * gc.c: ditto. * io.c: ditto. * node.h: ditto. * thread_pthread.c: ditto. * vm_insnhelper.c: ditto. * vsnprintf.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c, io.c: use rb_id_encodingnobu2015-12-091-1/+1
| | | | | | | | | * dir.c (dir_initialize): rb_id_encoding() returns same ID with caching. * io.c (Init_IO): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * *.c (*_memsize): do not check ptr.ko12015-12-091-1/+1
| | | | | | | | | | NULL checking is finished Before call of memsize functions. See r52979. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* use rb_gc_for_fd for more callersnormal2015-11-231-2/+1
| | | | | | | | | | | | | | | | * dir.c (dir_initialize): use rb_gc_for_fd for ENOMEM * ext/socket/init.c (rsock_socket): ditto * ext/socket/socket.c (rsock_socketpair): ditto * internal.h (rb_gc_for_fd): prototype * io.c (rb_gc_for_fd): remove static [ruby-core:71623] [Feature #11727] Manpages for opendir(2), socket(2), and socketpair(3posix) describe ENOMEM as a possible error for each of these; handle it consistently with our existing wrappers for open(2)/pipe(2) etc... git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * dir.c (dir_fileno, dirfd): support of Dir#fileno on Solaris 10.ngoto2015-11-061-0/+13
| | | | | | | | | | | | Solaris 10 does not have dirfd, but the file descriptor of a directory is stored in the d_fd or dd_fd member in the DIR struct. Note that Solaris 11 has dirfd(3C). * configure.in: checks for DIR.d_fd and DIR.dd_fd on Solaris 10. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* revert r52336 (commit miss)ko12015-10-291-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c (gc_mark_ptr): remove debug code for #11244.ko12015-10-291-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: glob brace expansion [Fix GH-1061]nobu2015-10-221-1/+1
| | | | | | | | | * dir.c (ruby_brace_expand): glob brace expansion edge case fix. When there are closing braces '}' before a open brace '{' it must be ignored and considered as literal. [ruby-core:71138] [Bug #11609] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: make ASCII-8BITnobu2015-10-041-1/+3
| | | | | | | * dir.c (rb_dir_getwd): make ASCII-8BIT if filesystem encoding is US-ASCII, like as Dir.glob. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: normalize cwdnobu2015-10-041-0/+5
| | | | | | * dir.c (rb_dir_getwd): normalize OS path to UTF-8 on OS X. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: give pathlen from callersnobu2015-09-301-6/+8
| | | | | | | * dir.c (glob_helper): move pathlen to argument which is known in the callers almost. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * dir.c (glob_helper): check pathtype once again by lstat(2) ifkosaki2015-09-161-4/+7
| | | | | | dp->d_type is DT_UNKNOWN. XFS may return DT_UNKNOWN. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: fundamental_encoding_pnobu2015-09-151-9/+19
| | | | | | | * dir.c (fundamental_encoding_p, push_glob): compare by encoding index immediately. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* win32.c: support known reparse points onlynobu2015-08-191-0/+5
| | | | | | | | * dir.c (replace_real_basename), win32/win32.c (opendir_internal): check reparse point tags and treat supported tags only as symbolic links. [ruby-core:70454] [Bug #11462] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: get attributes by fdnobu2015-07-101-3/+1
| | | | | | | * dir.c (is_case_sensitive): get attributes by the file descriptor of open directory, instead of using mount point name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: set errnonobu2015-07-021-2/+7
| | | | | | | * dir.c (replace_real_basename): Win32 API does not set errno, get the last error by GetLastError() and map to errno. [Bug #10015] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: show warningsnobu2015-07-021-4/+9
| | | | | | | * dir.c (replace_real_basename): show warnings at errors. [Bug #10015] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: update path typenobu2015-07-021-26/+43
| | | | | | | * dir.c (replace_real_basename): update path type by the target attributes if possible, to improve the performance. [Bug #10015] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ensure paths NUL-terminatednobu2015-06-301-0/+1
| | | | | | | | * dir.c (check_dirname): ensure path name NUL-terminated for SHARABLE_MIDDLE_SUBSTRING. * io.c (rb_sysopen): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c (check_dirname): avoid volatile, use return valuenormal2015-06-231-7/+7
| | | | | | | | | | | | | | | | volatile is unnecessary since we use rb_sys_fail_path nowadays and that prevents the path argument from being GC-ed. Using a return value instead of modifying the argument directly simplifies the generated code (on 32-bit x86): text data bss dec hex filename 20744 40 20 20804 5144 dir.o-orig 20720 40 20 20780 512c dir.o * dir.c (check_dirname): avoid volatile, use return value (dir_s_chroot, dir_s_mkdir, dir_s_rmdir): adjust callers git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h: $SAFE=2 is now obsolete.hsbt2015-06-181-2/+0
| | | | | | | | | | * dir.c, ext/fiddle/handle.c, ext/socket/basicsocket.c, file.c gc.c, io.c, process.c, safe.c, signal.c, win32/file.c: removed code for $SAFE=2 * test/erb/test_erb.rb, test/fiddle/test_handle.rb test/ruby/test_env.rb: removed tests for $SAFE=2. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e