Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 91dcc522b5e0
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1cb8a41c11ed
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on May 28, 2015

  1. fix whitespace

    tak1n committed May 28, 2015
    Copy the full SHA
    3d40bdd View commit details
  2. Copy the full SHA
    1cb8a41 View commit details
Showing with 39 additions and 26 deletions.
  1. +1 −1 configure
  2. +38 −25 kernel/common/file.rb
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
@@ -1231,7 +1231,7 @@ int main() { return tgetnum(""); }
end

if has_function("birthtime", ["sys/stat.h"])
@defines << "HAVE_ST_BIRTHTIME"
@defines << "HAVE_ST_BIRTHTIME"
end

# glibc has useless lchmod() so we don't try to use lchmod() on linux
63 changes: 38 additions & 25 deletions kernel/common/file.rb
Original file line number Diff line number Diff line change
@@ -113,6 +113,11 @@ def self.ctime(path)
Stat.new(path).ctime
end

##
# Returns the birthtime for the named file
#
# Note this is not supported on all platforms.
# See stat(2) for more information.
def self.birthtime(path)
Stat.new(path).birthtime
end
@@ -125,6 +130,31 @@ def self.mtime(path)
Stat.new(path).mtime
end

##
# Sets the access and modification times of each named
# file to the first two arguments. Returns the number
# of file names in the argument list.
# #=> Integer
def self.utime(a_in, m_in, *paths)
a_in ||= Time.now
m_in ||= Time.now
FFI::MemoryPointer.new(POSIX::TimeVal, 2) do |ptr|
atime = POSIX::TimeVal.new ptr
mtime = POSIX::TimeVal.new ptr[1]
atime[:tv_sec] = a_in.to_i
atime[:tv_usec] = 0

mtime[:tv_sec] = m_in.to_i
mtime[:tv_usec] = 0

paths.each do |path|

n = POSIX.utimes(Rubinius::Type.coerce_to_path(path), ptr)
Errno.handle unless n == 0
end
end
end

##
# Returns the last component of the filename given
# in file_name, which must be formed using forward
@@ -1076,31 +1106,6 @@ def self.unlink(*paths)
paths.size
end

##
# Sets the access and modification times of each named
# file to the first two arguments. Returns the number
# of file names in the argument list.
# #=> Integer
def self.utime(a_in, m_in, *paths)
a_in ||= Time.now
m_in ||= Time.now
FFI::MemoryPointer.new(POSIX::TimeVal, 2) do |ptr|
atime = POSIX::TimeVal.new ptr
mtime = POSIX::TimeVal.new ptr[1]
atime[:tv_sec] = a_in.to_i
atime[:tv_usec] = 0

mtime[:tv_sec] = m_in.to_i
mtime[:tv_usec] = 0

paths.each do |path|

n = POSIX.utimes(Rubinius::Type.coerce_to_path(path), ptr)
Errno.handle unless n == 0
end
end
end

def self.world_readable?(path)
path = Rubinius::Type.coerce_to_path path
return nil unless exist? path
@@ -1226,18 +1231,26 @@ def initialize(path_or_fd, mode=undefined, perm=undefined, options=undefined)

private :initialize

##
# see File.atime
def atime
Stat.new(@path).atime
end

##
# see File.ctime
def ctime
Stat.new(@path).ctime
end

##
# see File.birthtime
def birthtime
Stat.new(@path).birthtime
end

##
# see File.mtime
def mtime
Stat.new(@path).mtime
end