aboutsummaryrefslogtreecommitdiffstats
path: root/dir.c
Commit message (Collapse)AuthorAgeFilesLines
* dir.c: cast to suppress a warningnobu2017-11-011-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir: Dir.mkdir and Dir.rmdir release GVLnormal2017-11-011-5/+34
| | | | | | | | | | | | | | This avoids blocking the entire VM when operating on slow or unreliable filesystems. Instead, only the thread performing the mkdir or rmdir operation is blocked and other threads are free to proceed. * dir.c (nogvl_mkdir): new function (nogvl_rmdir): ditto (dir_s_mkdir): release GVL (dir_s_rmdir): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* use mode_t where applicable (instead of int)normal2017-10-311-2/+2
| | | | | | | | | | | | | | | | mode_t is the correct type for these syscalls and it can be easier-to-understand. It may also help portability to future platforms and improve type checking. * dir.c (dir_s_mkdir): use mode_t for mkdir(2) * file.c (chmod_internal): use mode_t for chmod(2) (rb_file_s_chmod): s/int/mode_t/ (lchmod_internal): ditto, deref pointer as in chmod_internal (rb_file_s_lchmod): pass pointer as in rb_file_s_chmod (rb_file_s_rename): use mode_t for umask(2) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir: Dir.chdir releases GVLnormal2017-10-301-1/+13
| | | | | | | | | | | | chdir(2) is subject to all the pathological slowdowns and caveats as open(2) on slow or unreliable filesystems, so ensure other threads can proceed while this is happening. * dir.c (nogvl_chdir): new function * dir.c (dir_chdir): release GVL git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "Dir.glob with FNM_EXTGLOB is optimized [Feature #13873]"naruse2017-10-271-82/+10
| | | | | | | | This reverts commit r60341,r60342,r60344,r60345. Breaking compabitility of the order of result breaks many tests. To avoid such effort to fix tests, the order should be kept. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Drop to support NaCl platform.hsbt2017-10-231-4/+0
| | | | | | | | | | | Because NaCl and PNaCl are already sunset status. see https://bugs.chromium.org/p/chromium/issues/detail?id=239656#c160 configure.ac: Patch for this file was provided by @nobu. [Feature #14041][ruby-core:83497][fix GH-1726] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: adjust indent [ci skip]nobu2017-10-221-44/+45
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Dir.glob with FNM_EXTGLOB is optimized [Feature #13873]naruse2017-10-221-10/+81
| | | | | | The order of resulted array is changed in some cases. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "ignore server side error"naruse2017-10-211-76/+8
| | | | | | This reverts commit r60314. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60315 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ignore server side errornaruse2017-10-211-8/+76
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60314 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "Dir.glob with FNM_EXTGLOB is optimized [Feature #13873]"naruse2017-10-211-76/+8
| | | | | | This reverts commit r60253 because it causes on error on Linux. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Dir.glob with FNM_EXTGLOB is optimized [Feature #13873]naruse2017-10-211-8/+76
| | | | | | The order of resulted array is changed in some cases. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Get rid of shadowing local variablesnobu2017-10-181-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Dir.empty? releases GVLnormal2017-10-041-24/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | This converts all slow syscalls in the Dir.empty? implementation to release GVL. We avoid unnecessarily GVL release and reacquire for each slow call (opendir, readdir, closedir) and instead only release and acquire the GVL once in the common case. Benchmark results show a small degradation in single-threaded performance: Execution time (sec) name trunk built dir_empty_p 0.689 0.758 Speedup ratio: compare with the result of `trunk' (greater is better) name built dir_empty_p 0.909 * dir.c (rb_gc_for_fd_with_gvl): new function (nogvl_dir_empty_p): ditto (dir_s_empty_p): use new functions to release GVL * benchmark/bm_dir_empty_p.rb: new benchmark [ruby-core:83071] [Feature #13958] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: fix up r59527nobu2017-08-081-1/+2
| | | | | | | | * dir.c (glob_helper): fix up r59527, dot files other than current directory should not be included unless FNM_DOTMATCH is given. [ruby-core:82266] [Bug #13785] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59529 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: fix up r59481 for old kernelsnobu2017-08-081-6/+10
| | | | | | | | * dir.c (glob_helper): fix up r59481 for old kernels, which provide d_type member but just always set DT_UNKNOWN for any entries. [ruby-core:82266] [Bug #13785] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: reduce syscallsnobu2017-08-031-6/+4
| | | | | | | | * dir.c (glob_helper): utilize d_type even if no recursive pattern, to reduce stat/lstat syscalls in subsequent glob_helper. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: relative path Dir basenobu2017-08-031-5/+8
| | | | | | | * dir.c (glob_helper): fix globbing based on a relative path Dir. [Feature #13056] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c: relax base optionnobu2017-08-031-1/+2
| | | | | | | * dir.c (dir_glob_options): relax base option. ignore when nil or an empty string as :base option. [Feature #13056] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dir.c (ruby_brace_expand): RB_GC_GUARD safetynormal2017-07-251-6/+6
| | | | | | | | | | | | | The lifetime of a String VALUE must match or exceed the lifetime of its R*_PTR result; otherwise the GC can while reclaim the VALUE while the R*_PTR result is in use. * dir.c (ruby_brace_expand): add var parameter for GC guard (ruby_brace_glob_with_enc): adjust call (file_s_fnmatch): ditto (push_glob): remove misplaced GC guard git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* 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