Граф коммитов

198 Коммитов

Автор SHA1 Сообщение Дата
卜部昌平 a19228f878 brace the fact that lchmod(2) can EOPNOTSUPP
Musl libc has this function as a tiny wrapper of fchmodat(3posix).  On
the other hand Linux kernel does not support changing modes of a symlink.
The operation always fails with EOPNOTSUPP.  This fchmodat behaviour is
defined in POSIX.  We have to take care of such exceptions.
2020-01-24 10:49:35 +09:00
Hiroshi SHIBATA 08c866d528 [ruby/fileutils] Bump version to 1.4.1
https://github.com/ruby/fileutils/commit/da15e3ce06
2019-11-30 18:09:41 +09:00
Hiroshi SHIBATA 32e547954f
Revert "[ruby/fileutils] Fix #install with "X" mode option"
This reverts commit eab88d20ea.

  The some CI was broken with this.
2019-11-30 17:58:39 +09:00
Hiroshi SHIBATA ea4272d02b [ruby/fileutils] Bump version to 1.4.0
https://github.com/ruby/fileutils/commit/f92145b10b
2019-11-30 17:36:13 +09:00
Nobuyoshi Nakada eab88d20ea [ruby/fileutils] Fix #install with "X" mode option
`FileUtils#install` methed raises an unexpected `TypeError`, when
called with `mode:` option which has `"X"`.

```
$ ruby -rfileutils -e 'FileUtils.install("tmp/a", "tmp/b", mode: "o+X")'
/opt/local/lib/ruby/2.7.0/fileutils.rb:942:in `directory?': no implicit conversion of File::Stat into String (TypeError)
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:942:in `block (3 levels) in symbolic_modes_to_i'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:933:in `each_char'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:933:in `each'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:933:in `inject'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:933:in `block (2 levels) in symbolic_modes_to_i'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:931:in `each'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:931:in `each_slice'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:931:in `block in symbolic_modes_to_i'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:926:in `each'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:926:in `inject'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:926:in `symbolic_modes_to_i'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:973:in `fu_mode'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:883:in `block in install'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:1588:in `block in fu_each_src_dest'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:1604:in `fu_each_src_dest0'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:1586:in `fu_each_src_dest'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:877:in `install'
	from -e:1:in `<main>'
```

In spite of that `symbolic_modes_to_i` considers the `File::Stat`
`path` case at the beginning, in `"X"` case, `path` is passed to
`FileTest.directory?` method which requires a `String`.  In such
case, the mode in `path` should be examined instead.

https://github.com/ruby/fileutils/commit/2ea54ade2f
2019-11-30 17:31:35 +09:00
Nobuyoshi Nakada 0a7d26bea1
[ruby/fileutils] Remove version.rb
Loading separate version.rb unnecessary increases every start-up
time.  In the other hand, the gemspec file is parsed only when
building the gem file.

https://github.com/ruby/fileutils/commit/8359cf7cce
2019-11-30 17:30:50 +09:00
Jeremy Evans e4cd0d7287 [ruby/fileutils] Remove use of untaint on Ruby 2.7 to avoid deprecation warnings
https://github.com/ruby/fileutils/commit/5ac9a8a1f7
2019-10-31 15:41:46 +09:00
Kazuhiro NISHIYAMA d5355123cc
[ruby/fileutils] Reduce global variables
https://github.com/ruby/fileutils/commit/ba81f024cf
2019-09-27 11:39:02 +09:00
Jeremy Evans 06c35cfa65
[ruby/fileutils] Fix cp_r with symlink root on Windows
Previously this would copy the symlink root as a symlink instead
of creating a new root directory.  This modifies the source
to expand it using File.realpath before starting the copy.

Fixes Ruby Bug 12123

https://github.com/ruby/fileutils/commit/7359cef359
2019-09-27 11:39:02 +09:00
Jeremy Evans 9494ef8b2d
[ruby/fileutils] Do not break in verbose mode if using FileUtils with a frozen object
If FileUtils is included into another object, and verbose mode is
used, a FrozenError is currently raised unless the object has the
@fileutils_output and @fileutils_label instance variables.

This fixes things so that it does not attempt to set the instance
variables, but it still uses them if they are present.

https://github.com/ruby/fileutils/commit/689cb9c56a
2019-09-27 11:39:02 +09:00
Jeremy Evans 1d99163aa5
[ruby/fileutils] Make copy methods handle FIFOs and UNIX sockets
Previously, this was broken.  Trying to copy a FIFO would raise a
NoMethodError if File.mkfifo was defined.  Trying to copy a UNIX
socket would raise a RuntimeError as File.mknod is not something
Ruby defines.

Handle the FIFO issue using File.mkfifo instead of mkfifo.

Handle the UNIX Socket issue by creating a unix socket.

Continue to not support character or block devices, raising a
RuntimeError for both.

Add tests for FIFO, UNIX Socket, and character/block devices.

https://github.com/ruby/fileutils/commit/123903532d
2019-09-27 11:39:02 +09:00
zverok 366dd9d803
[ruby/fileutils] Update the documentation content and formatting
https://github.com/ruby/fileutils/commit/b701353c53
2019-09-27 11:39:02 +09:00
Jeremy Evans 80b5a0ff2a
Make rb_scan_args handle keywords more similar to Ruby methods (#2460)
Cfuncs that use rb_scan_args with the : entry suffer similar keyword
argument separation issues that Ruby methods suffer if the cfuncs
accept optional or variable arguments.

This makes the following changes to : handling.

* Treats as **kw, prompting keyword argument separation warnings
  if called with a positional hash.

* Do not look for an option hash if empty keywords are provided.
  For backwards compatibility, treat an empty keyword splat as a empty
  mandatory positional hash argument, but emit a a warning, as this
  behavior will be removed in Ruby 3.  The argument number check
  needs to be moved lower so it can correctly handle an empty
  positional argument being added.

* If the last argument is nil and it is necessary to treat it as an option
  hash in order to make sure all arguments are processed, continue to
  treat the last argument as the option hash. Emit a warning in this case,
  as this behavior will be removed in Ruby 3.

* If splitting the keyword hash into two hashes, issue a warning, as we
  will not be splitting hashes in Ruby 3.

* If the keyword argument is required to fill a mandatory positional
  argument, continue to do so, but emit a warning as this behavior will
  be going away in Ruby 3.

* If keyword arguments are provided and the last argument is not a hash,
  that indicates something wrong. This can happen if a cfunc is calling
  rb_scan_args multiple times, and providing arguments that were not
  passed to it from Ruby.  Callers need to switch to the new
  rb_scan_args_kw function, which allows passing of whether keywords
  were provided.

This commit fixes all warnings caused by the changes above.

It switches some function calls to *_kw versions with appropriate
kw_splat flags. If delegating arguments, RB_PASS_CALLED_KEYWORDS
is used.  If creating new arguments, RB_PASS_KEYWORDS is used if
the last argument is a hash to be treated as keywords.

In open_key_args in io.c, use rb_scan_args_kw.
In this case, the arguments provided come from another C
function, not Ruby.  The last argument may or may not be a hash,
so we can't set keyword argument mode.  However, if it is a
hash, we don't want to warn when treating it as keywords.

In Ruby files, make sure to appropriately use keyword splats
or literal keywords when calling Cfuncs that now issue keyword
argument separation warnings through rb_scan_args.  Also, make
sure not to pass nil in place of an option hash.

Work around Kernel#warn warnings due to problems in the Rubygems
override of the method.  There is an open pull request to fix
these issues in Rubygems, but part of the Rubygems tests for
their override fail on ruby-head due to rb_scan_args not
recognizing empty keyword splats, which this commit fixes.

Implementation wise, adding rb_scan_args_kw is kind of a pain,
because rb_scan_args takes a variable number of arguments.
In order to not duplicate all the code, the function internals need
to be split into two functions taking a va_list, and to avoid passing
in a ton of arguments, a single struct argument is used to handle
the variables previously local to the function.
2019-09-25 11:18:49 -07:00
Justin Collins 4f1a00a746
Improve same directory detection in FileUtils
Closes: https://github.com/ruby/ruby/pull/1425
2019-08-06 09:01:04 +09:00
David Rodríguez e572ff2f95 Require version file relatively 2019-06-25 15:56:20 +09:00
hsbt 191b99c89d Merge fileutils-1.2.0 from ruby/fileutils.
It includes the following updates:

  * https://github.com/ruby/fileutils/pull/26
  * https://github.com/ruby/fileutils/pull/27
  * https://github.com/ruby/fileutils/pull/29
  * https://github.com/ruby/fileutils/pull/34

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-27 08:26:09 +00:00
hsbt 7d3d8e79fe fall back to copy + unlink on EPERM
[Feature #15415][ruby-core:90536]

  Co-authored-by: Eric Wong  <normalperson@yhbt.net>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-11 09:52:31 +00:00
nobu cb5a329814 Fix exception namespace
* lib/fileutils.rb (remove_entry_secure): EISDIR is under the
  Errno namespace.  [ruby-core:91362] [Bug #15577]

From: Tietew (Toru Iwase) <tietew@tietew.net>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-31 14:02:30 +00:00
hsbt 37c08fad04 Dir.children is available since Feature #11302. FileUtils uses
Dir.each on an internal method encapsulated on a private class
`Entry_#entry`, having no '.' neither '..' entries would make
now superfluous a chained reject filtering.

This change can improve the performance of these FileUtils
methods when the provided path covers thousands of files or
directories:

- chmod_R
- chown_R
- remove_entry
- remove_entry_secure
- rm_r
- remove_dir
- copy_entry

Related: Feature #13896 https://bugs.ruby-lang.org/issues/13896

[Feature #14109][Fix GH-1754]

Co-Authored-By: esparta <esparta@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-07 15:55:14 +00:00
hsbt 818648ac40 Merge fileutils from ruby/fileutils on GitHub.
* It was separated version file for gemspec.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20 07:03:55 +00:00
stomar a9d3601b3b fileutils.rb: restore documentation for FileUtils
* lib/fileutils.rb: [DOC] restore documentation for FileUtils module
  which became undocumented with r63430.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-03 19:19:33 +00:00
nobu 36b183ce8c fileutils.rb: split fu_windows?
* lib/fileutils.rb (FileUtils::StreamUtils_#fu_windows?): select
  the method definition for each platforms, and dropped supports
  for deprecated platforms.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-19 00:22:39 +00:00
nobu db5765ba54 fileutils.rb: remove code for OS/2 emx
* lib/fileutils.rb (FileUtils#mv): remove code for OS/2 emx, its
  support has been dropped yeas ago.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-16 01:31:28 +00:00
hsbt ff6520b0f7 Added workaround to fileutils for `make btest` without rbconfig.
Followed up r63430.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-15 10:10:33 +00:00
hsbt 60fbe01353 Retry to merge fileutils-1.1.0.
* Revert "Revert "Merge fileutils-1.1.0.""
    This reverts commit 84bb8e81c2.

  * Added workaround for make mjit-headers

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-15 05:53:18 +00:00
mame 84bb8e81c2 Revert "Merge fileutils-1.1.0."
This reverts commit 99da3d2570e110d3024039102205f6d64174bf5e.
The change caused the following build failure:

```
.../ruby/lib/fileutils.rb:88:in `require': cannot load such file -- rbconfig (LoadError)
uncommon.mk:987: recipe for target 'encdb.h' failed
make: *** [encdb.h] Error 1
```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-15 04:16:08 +00:00
hsbt 6f9609867c Merge fileutils-1.1.0.
This version was migrated JRuby paches.
  https://github.com/ruby/fileutils/pull/18

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-15 01:22:36 +00:00
k0kubun b2839bac44 [DOC] Fix links of cve [ci skip]
`http://www.cve.mitre.org/` seem to move `http://cve.mitre.org/`.
I can't access `http://www.cve.mitre.org/`.

[Fix GH-1857]

From: willnet <netwillnet@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-16 10:20:15 +00:00
stomar d890fabecf lib/fileutils.rb: [DOC] fix typos and grammar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-14 16:47:59 +00:00
kazu f01315a5cf Fix typos [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-13 15:10:59 +00:00
mame d583ee266b Add FileUtils#cp_lr
* lib/fileutils.rb: Add FileUtils#cp_lr.  This method creates hard links
  of each file from directory to another directory recursively.
  This patch is based on Thomas Sawyers and Zachary Scott.
  [Feature #4189] [ruby-core:33820]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-13 08:18:03 +00:00
hsbt 84e462758d Bump up fileutils-1.0.2
Added `FileUtils::VERSION` const variable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-22 08:00:10 +00:00
hsbt 0242f7ccae Overwrite destination symlink file if `remove_destination` is set.
[Bug #13914][ruby-core:82846] Patch by @mzp
  https://github.com/ruby/fileutils/pull/9

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-20 07:03:11 +00:00
nobu 2635984cf2 fileutils.rb: error at rmdir
* lib/fileutils.rb (rmdir): should not ignore errors first, except
  for parent directories.  [ruby-dev:50236] [Bug #13889]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-16 11:59:47 +00:00
stomar ddd37e5491 docs for FileUtils.ln methods
* lib/fileutils.rb: [DOC] add clarifying call-seq's for FileUtil.ln,
  ln_s, and ln_sf, with better argument names for the created link and
  link target.  Reported by Mike Vastola. [ruby-core:62532] [Bug #9829]

* lib/fileutils.rb: [DOC] further improve descriptions of FileUtils.ln
  and related methods; improve examples: relative links probably won't
  work in other dir, avoid `include', use more generic homedir name.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-08 20:41:38 +00:00
stomar 97e946f75a fileutils.rb: improve rdoc for FileUtils
* lib/fileutils.rb: [DOC] fix invalid example code to make it
  syntax highlighted, fix rdoc for lists, nodoc internal methods,
  avoid a dangerous example.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-01 10:17:42 +00:00
stomar 7957042253 fileutils.rb: improve docs for FileUtils.compare_file
* lib/fileutils.rb (compare_file): [DOC] clarify documentation
  by avoiding confusing return value of "maybe false".

[ruby-core:75431] [Misc #12365] reported by Robert A. Heiler.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-01 08:54:37 +00:00
nobu 3261cfd881 fileutils.rb: do not make root
* lib/fileutils.rb (FileUtils#mkdir_p): no need to make root
  directory which should be exist and cannot be made with mkdir
  recent Cygwin can make a directory contains a colon.
  [Bug #13214]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-16 08:42:22 +00:00
hsbt 18a315df43 Fix documentation of options for all of methods in FileUtils.
Patch by galia traub( @galiat ). [Fix GH-1510][ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-19 07:07:17 +00:00
kazu 9144d57b94 lib/fileutils.rb: Specify frozen_string_literal: true.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-07 02:14:07 +00:00
nobu 0785b3e1b7 fileutils.rb: fix error for non-existent entry
* lib/fileutils.rb (FileUtils::Entry_#copy): ensure that the
  source entry exists first, to fix error for non-existent entry.
  [ruby-core:77885] [Bug #12892]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-04 01:35:49 +00:00
nobu e3503ee218 Octal mode in un.rb
* lib/fileutils.rb (FileUtils#symbolic_modes_to_i): revert r55524.

* lib/un.rb (install, chmod): support octal mode string.  fix up
  r55513.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-28 22:03:00 +00:00
arton f2f16f2a35 Tue Jun 28 22:09:09 2017 Akio Tajima <artonx@yahoo.co.jp>
* lib/fileutils.rb: rescue Errno:EACCES for chown.
	  [Bug #12520]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-28 13:14:48 +00:00
nobu d34b3c9a0f Octal mode
* lib/fileutils.rb (symbolic_modes_to_i): support octal mode
  string.  fix up r55513.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55524 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-28 12:33:28 +00:00
nobu 2a5183c2e4 FileUtils#install: symbolic mode
* lib/fileutils.rb (FileUtils#install): accecpt symbolic mode, as
  well as chmod.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-27 07:58:34 +00:00
nobu 10fcca8f15 FileUtils#install: owner/group options
* lib/fileutils.rb (FileUtils#install): add owner and group
  options.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-27 07:55:17 +00:00
nobu 71db7bd3d3 Refactor
* lib/fileutils.rb (FileUtils::Entry_#copy_metadata): eliminate
  common statements.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-27 01:24:46 +00:00
nobu baa43cd0c2 fileutils.rb: keyword arguments
* lib/fileutils.rb: use keyword arguments instead of option
  hashes.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-01 02:26:44 +00:00
nobu 52bdb3ce02 fileutils.rb: LowMethods aliases
* lib/fileutils.rb (LowMethods): make alias methods instead of
  eval for each methods.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-29 12:22:17 +00:00
nobu efa39c3dbd fileutils.rb: reduce private
* lib/fileutils.rb (Verbose, NoWrite, DryRun): make overridden
  methods private by each one calls.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-29 08:36:30 +00:00