Advertisement
Guest User

Untitled

a guest
Jun 27th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.65 KB | None | 0 0
  1. diff --git a/kernel/bootstrap/stat.rb b/kernel/bootstrap/stat.rb
  2. index 61cf3d8..b3a51c2 100644
  3. --- a/kernel/bootstrap/stat.rb
  4. +++ b/kernel/bootstrap/stat.rb
  5. @@ -87,6 +87,11 @@ module Rubinius
  6. raise PrimitiveFailure, "Rubinius::Stat#ctime primitive failed"
  7. end
  8.  
  9. + def birthtime
  10. + Rubinius.primitive :stat_birthtime
  11. + raise NotImplementedError, "birthtime() function is unimplemented on this machine"
  12. + end
  13. +
  14. def inspect
  15. "#<#{self.class.name} dev=0x#{self.dev.to_s(16)}, ino=#{self.ino}, " \
  16. "mode=#{sprintf("%07d", self.mode.to_s(8).to_i)}, nlink=#{self.nlink}, " \
  17. diff --git a/kernel/common/file.rb b/kernel/common/file.rb
  18. index fca8498..465a505 100644
  19. --- a/kernel/common/file.rb
  20. +++ b/kernel/common/file.rb
  21. @@ -104,6 +104,28 @@ class File < IO
  22. end
  23.  
  24. ##
  25. + # Returns the change time for the named file (the
  26. + # time at which directory information about the
  27. + # file was changed, not the file itself).
  28. + #
  29. + # File.ctime("testfile") #=> Wed Apr 09 08:53:13 CDT 2003
  30. + def self.ctime(path)
  31. + Stat.new(path).ctime
  32. + end
  33. +
  34. + def self.birthtime(path)
  35. + Stat.new(path).birthtime
  36. + end
  37. +
  38. + ##
  39. + # Returns the modification time for the named file as a Time object.
  40. + #
  41. + # File.mtime("testfile") #=> Tue Apr 08 12:58:04 CDT 2003
  42. + def self.mtime(path)
  43. + Stat.new(path).mtime
  44. + end
  45. +
  46. + ##
  47. # Returns the last component of the filename given
  48. # in file_name, which must be formed using forward
  49. # slashes (``/’’) regardless of the separator used
  50. @@ -305,16 +327,6 @@ class File < IO
  51. end
  52.  
  53. ##
  54. - # Returns the change time for the named file (the
  55. - # time at which directory information about the
  56. - # file was changed, not the file itself).
  57. - #
  58. - # File.ctime("testfile") #=> Wed Apr 09 08:53:13 CDT 2003
  59. - def self.ctime(path)
  60. - Stat.new(path).ctime
  61. - end
  62. -
  63. - ##
  64. # Returns true if the named file is a directory, false otherwise.
  65. #
  66. # File.directory?(".")
  67. @@ -816,14 +828,6 @@ class File < IO
  68. Stat.lstat path
  69. end
  70.  
  71. - ##
  72. - # Returns the modification time for the named file as a Time object.
  73. - #
  74. - # File.mtime("testfile") #=> Tue Apr 08 12:58:04 CDT 2003
  75. - def self.mtime(path)
  76. - Stat.new(path).mtime
  77. - end
  78. -
  79. def self.path(obj)
  80. return obj.to_path if obj.respond_to? :to_path
  81.  
  82. @@ -1226,6 +1230,18 @@ class File < IO
  83. Stat.new(@path).atime
  84. end
  85.  
  86. + def ctime
  87. + Stat.new(@path).ctime
  88. + end
  89. +
  90. + def birthtime
  91. + Stat.new(@path).birthtime
  92. + end
  93. +
  94. + def mtime
  95. + Stat.new(@path).mtime
  96. + end
  97. +
  98. def reopen(other, mode = 'r+')
  99. rewind unless closed?
  100. unless other.kind_of? IO
  101. @@ -1234,10 +1250,6 @@ class File < IO
  102. super(other, mode)
  103. end
  104.  
  105. - def ctime
  106. - Stat.new(@path).ctime
  107. - end
  108. -
  109. def flock(const)
  110. const = Rubinius::Type.coerce_to const, Integer, :to_int
  111.  
  112. @@ -1251,10 +1263,6 @@ class File < IO
  113. Stat.lstat @path
  114. end
  115.  
  116. - def mtime
  117. - Stat.new(@path).mtime
  118. - end
  119. -
  120. def stat
  121. Stat.fstat @descriptor
  122. end
  123. diff --git a/vm/builtin/stat.cpp b/vm/builtin/stat.cpp
  124. index 2bff56b..8c9ecd5 100644
  125. --- a/vm/builtin/stat.cpp
  126. +++ b/vm/builtin/stat.cpp
  127. @@ -77,5 +77,9 @@ namespace rubinius {
  128. return Time::at(state, st_.st_ctime);
  129. }
  130.  
  131. + Time* Stat::stat_birthtime(STATE) {
  132. + return Time::at(state, st_.st_birthtime);
  133. + }
  134. +
  135. }
  136.  
  137. diff --git a/vm/builtin/stat.hpp b/vm/builtin/stat.hpp
  138. index dd17723..e7735b1 100644
  139. --- a/vm/builtin/stat.hpp
  140. +++ b/vm/builtin/stat.hpp
  141. @@ -73,6 +73,9 @@ namespace rubinius {
  142. // Rubinius.primitive+ :stat_ctime
  143. Time* stat_ctime(STATE);
  144.  
  145. + // Rubinius.primitive+ :stat_birthtime
  146. + Time* stat_birthtime(STATE);
  147. +
  148. class Info : public TypeInfo {
  149. public:
  150. BASIC_TYPEINFO(TypeInfo)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement