summaryrefslogtreecommitdiff
path: root/file.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix missing paren [ci skip]Kazuhiro NISHIYAMA2022-05-061-2/+2
|
* File rdoc (#5888)Burdette Lamar2022-05-051-14/+29
| | | | | | | | | Treats: ::pipe? ::symlink? ::socket? ::blockdev? ::chardev?
* Enhanced RDoc for File (#5849)Burdette Lamar2022-04-261-35/+67
| | | | | | | | | | | Treats: #path ::stat ::lstat #lstat ::directory? Also adds section "Example Files" that explains assumptions about example files. I'm using t.txt already, and I'm pretty sure I'll need t.dat (binary data). I don't know whether I'll need t.rus (Russian text).
* [DOC] Use consistent terms [Bug #18680]Nobuyoshi Nakada2022-04-181-3/+3
|
* Return `false` where sticky-bit is not provided [Bug #18734]Nobuyoshi Nakada2022-04-151-1/+1
|
* Use an empty string when building File.expand_pathPeter Zhu2022-04-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allocating a string of length MAXPATHLEN and then shrinking the string is inefficient when the resulting path is short. Preallocating a large string is also a problem for Variable Width Allocation since we can't easily downsize the capacity. I ran the following benchmark: ```ruby Benchmark.ips do |x| { "empty" => "", "short" => "a/" * 10, "medium" => "a/" * 100, "long" => "a/" * 500 }.each do |name, path| x.report(name) do |times| i = 0 while i < times File.expand_path(path) i += 1 end end end end ``` On this commit: ``` empty 97.486k (± 0.7%) i/s - 492.915k in 5.056507s short 96.026k (± 2.4%) i/s - 486.489k in 5.068966s medium 86.304k (± 1.3%) i/s - 435.336k in 5.045112s long 59.395k (± 1.7%) i/s - 302.175k in 5.089026s ``` On master: ``` empty 94.138k (± 1.4%) i/s - 472.158k in 5.016590s short 92.043k (± 1.4%) i/s - 468.180k in 5.087496s medium 84.910k (± 2.3%) i/s - 425.750k in 5.017007s long 61.503k (± 2.7%) i/s - 309.723k in 5.039429s ```
* Fix formatting of What's Here for File (#5717)Burdette Lamar2022-03-251-93/+93
|
* [DOC] Replace with IO@ModesPeter Zhu2022-02-071-1/+1
|
* [DOC] Use RDoc link style for links in the same class/modulePeter Zhu2022-02-071-4/+4
| | | | | | | | | | I used this regex: (?<=\[)#(?:class|module)-([A-Za-z]+)-label-([A-Za-z0-9\-\+]+) And performed a global find & replace for this: rdoc-ref:$1@$2
* [DOC] Use RDoc link style for links to other classes/modulesPeter Zhu2022-02-071-2/+2
| | | | | | | | | | I used this regex: ([A-Za-z]+)\.html#(?:class|module)-[A-Za-z]+-label-([A-Za-z0-9\-\+]+) And performed a global find & replace for this: rdoc-ref:$1@$2
* [DOC] Fix links in documentation for File and IOPeter Zhu2022-02-071-1/+1
| | | | Fixes some typos and dead links.
* File rdoc (#5438)Burdette Lamar2022-01-131-28/+59
| | | | | | | | Treats: File introduction File.open File.new
* Removed deprecated Dir.exists? and File.exists?Nobuyoshi Nakada2021-12-281-18/+0
|
* Adjust styles [ci skip]Nobuyoshi Nakada2021-12-241-1/+2
|
* Improved exception usage/classes.Samuel Williams2021-12-211-10/+14
|
* size_t is not for file sizeNobuyoshi Nakada2021-11-101-2/+3
|
* IO::Buffer for scheduler interface.Samuel Williams2021-11-101-7/+14
|
* [DOC] Fix indent as single paragraph [ci skip]Nobuyoshi Nakada2021-11-051-1/+1
|
* rb_encoding is already constU.Nakamura2021-10-141-1/+1
| | | | | - this change get rid of a warning of mswin build. see include/ruby/internal/encoding/encoding.h(116)
* rb_group_member: SimplifyNobuyoshi Nakada2021-10-141-20/+4
|
* Fix regression on Solaris after change to use realpath on loaded featuresJeremy Evans2021-10-041-1/+27
| | | | | | | | | | | | | | | | | | | | | | | | After the change to use realpath on loaded features, Solaris CI started failing in test_no_curdir (which tests behavior for running ruby without a working directory). I was able to trace the problem to the following call chain: rb_call_inits->Init_Thread->Init_thread_sync->rb_provide-> get_loaded_features_index->rb_check_realpath->rb_dir_getwd_ospath-> ruby_getcwd This will throw an exception, but because Ruby hasn't been fully initialized at the point the exception is thrown, it just exits with a status of 1. The bug here is that rb_check_realpath should not raise an exception, it should return nil. This bug is hit on Solaris because Solaris uses the realpath emulation instead of native realpath, and the realpath emualation raised instead of returning nil if the mode was RB_REALPATH_CHECK. Use rb_rescue in the realpath emulation if the mode is RB_REALPATH_CHECK, and swallow any exceptions raised and return nil.
* Get rid of unused function warning for `_WIN32`xtkoba2021-10-031-1/+1
|
* Associate the encoding to the found pathNobuyoshi Nakada2021-10-011-0/+4
|
* Refactor and Using RBOOL macroS.H2021-09-151-10/+5
|
* Replace RBOOL macroS-H-GAMELINKS2021-09-051-14/+14
|
* Add stat_time functionS-H-GAMELINKS2021-08-241-6/+9
|
* [DOC] Fix the rdoc for File::Stat#size? [ci skip]Akinori MUSHA2021-08-171-3/+5
|
* Using RBOOL macroS.H2021-08-021-2/+0
|
* Add RBOOL macro and use itS.H2021-07-291-12/+8
|
* What's Here for Numeric and ComparableBurdette Lamar2021-06-211-4/+5
|
* What's Here for class File (#4460)Burdette Lamar2021-05-071-0/+132
| | | What's Here for class File
* Support non-standard `struct stat` [Bug #17793]Nobuyoshi Nakada2021-04-121-0/+16
| | | | | | On 32-bit Android: * `st_dev`/`st_rdev` are not `dev_t` * `st_mode` is not `mode_t`
* Fill the ring-buffer with the fallback valueNobuyoshi Nakada2021-04-021-2/+1
| | | | | | | | | Fill with the pointer to the root position, instead of zero and comparing later. Also suppress a false warning by Visual C++. ``` file.c(4759): warning C4090: 'function': different 'const' qualifiers ```
* File.dirname optional levelNobuyoshi Nakada2021-03-151-6/+57
| | | | | * file.c (rb_file_dirname_n): chomp N level of base names. [Feature #12194]
* Explicitly cast __s64 to time_t [Bug #17645]xtkoba (Tee KOBAYASHI)2021-03-141-1/+1
| | | | A workaround of shorten-64-to-32 error where 32-bit linux.
* Keep encoding in the result of File.expand_path [Bug #17517]Nobuyoshi Nakada2021-01-151-6/+20
|
* Revert "Removed deprecated Dir.exists? and File.exists?"Nobuyoshi Nakada2020-12-021-0/+18
| | | | This reverts commit 1a5205536f0c0d6021450b11722919211847df86.
* Removed deprecated Dir.exists? and File.exists?Nobuyoshi Nakada2020-12-021-18/+0
|
* Removed rb_find_file_ext_safe and rb_find_file_safeHiroshi SHIBATA2020-09-231-14/+0
|
* Get rid of the redundant stat() in rb_check_realpath_internalJean Boussier2020-07-071-1/+3
|
* add UNREACHABLE_RETURN卜部昌平2020-06-291-0/+1
| | | | | | Not every compilers understand that rb_raise does not return. When a function does not end with a return statement, such compilers can issue warnings. We would better tell them about reachabilities.
* rb_f_stat: do not goto into a branch卜部昌平2020-06-291-9/+9
| | | | | I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
* Removed execpath argument of path_check_0 as always TRUE nowNobuyoshi Nakada2020-06-231-5/+5
|
* Removed fpath_check, no longer used since taint flag was removedNobuyoshi Nakada2020-06-231-6/+0
|
* Allow Dir.home to work for non-login procs when $HOME not setAlan D. Salewski2020-05-231-15/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow the 'Dir.home' method to reliably locate the user's home directory when all three of the following are true at the same time: 1. Ruby is running on a Unix-like OS 2. The $HOME environment variable is not set 3. The process is not a descendant of login(1) (or a work-alike) The prior behavior was that the lookup could only work for login-descended processes. This is accomplished by looking up the user's record in the password database by uid (getpwuid_r(3)) as a fallback to the lookup by name (getpwname_r(3)) which is still attempted first (based on the name, if any, returned by getlogin_r(3)). If getlogin_r(3), getpwnam_r(3), and/or getpwuid_r(3) is not available at compile time, will fallback on using their respective non-*_r() variants: getlogin(3), getpwnam(3), and/or getpwuid(3). The rationale for attempting to do the lookup by name prior to doing it by uid is to accommodate the possibility of multiple login names (each with its own record in the password database, so each with a potentially different home directory) being mapped to the same uid (as is explicitly allowed for by POSIX; see getlogin(3posix)). Preserves the existing behavior for login-descended processes, and adds the new capability of having Dir.home being able to find the user's home directory for non-login-descended processes. Fixes [Bug #16787] Related discussion: https://bugs.ruby-lang.org/issues/16787 https://github.com/ruby/ruby/pull/3034
* sed -i 's|ruby/impl|ruby/internal|'卜部昌平2020-05-111-1/+1
| | | | To fix build failures.
* sed -i s|ruby/3|ruby/impl|g卜部昌平2020-05-111-1/+1
| | | | This shall fix compile errors.
* Merge pull request #2991 from shyouhei/ruby.h卜部昌平2020-04-081-2/+16
| | | Split ruby.h
* Show the deprecated name in the warningNobuyoshi Nakada2020-04-071-1/+1
| | | | Fixed up a58bbd6a512d95ca010d8bebae4fe590400c1413.
* [DOC] Removed RDoc of deprecated methods [ci skip]Nobuyoshi Nakada2020-04-061-6/+1
|