# \[ruby-trunk - Feature #9647\] File::Stat#birthtimeの追加

**URL:** <https://www.ruby-forum.com/t/ruby-trunk-feature-9647-file-stat-birthtime/239868>\
**Category:** Development\
**Created:** [March 18, 2014, 5:53am UTC](https://www.ruby-forum.com/t/ruby-trunk-feature-9647-file-stat-birthtime/239868 "2014-03-18T05:53:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [March 18, 2014, 5:53am UTC](https://www.ruby-forum.com/t/ruby-trunk-feature-9647-file-stat-birthtime/239868/1 "2014-03-18T05:53:42Z")

</div>

Issue #9647 has been updated by Yui NARUSE.

Motohiro KOSAKI wrote:

> 

Linuxの場合、媒体にはbirthtimeが記録されていて、syscallの追加が自転車置き場の議論で進まないという感じなのでctimeが帰ってくるのはうれしくないなあ。将来的に混乱が予想されるので。

> いまでもrootならdebugfs使って作成日とれます。  
> この辺参照してください（一番下）  
> [c - How to get file creation date in Linux? - Stack Overflow](http://stackoverflow.com/questions/5929419/how-to-get-file-creation-date-in-linux)
> 
> こっから先は雑談なんだけど、なにが自転車置き場の議論かというと、birthtime追加 → やったSambaの実装が楽になるよ！ →  
> だがちょっと待って欲しい、Windowsはctimeユーザが変更できる、それが出来ないならSambaで使えない → それもう birthtimeじゃねーだろアホか  
> → えーい、usecaseで揉めるような機能なら入れない！！  
> という非常にばかばかしい議論をしたことがあるのだ。

はい。  
なもんでLinuxが実装するの待っていたんですが、もう見捨てるという結論にしました（どーん

Windowsの方はなるほど…なので、とりあえずWindowsもNotImpErrorにしてうささんに実装してもらいますかね（ゎ

* * *

Feature #9647: File::Stat#birthtimeの追加

> **[Feature #9647: File::Stat#birthtimeの追加 - Ruby master - Ruby Issue Tracking...](https://bugs.ruby-lang.org/issues/9647#change-45855)**
>
> Redmine

- Author: Yui NARUSE
- Status: Assigned
- Priority: Normal
- Assignee: Yukihiro M.
- Category: core
- Target version:

* * *

File::Stat#birthtimeを追加しませんか。

以下の様なシステムの stat(2) には st\_birthtimespec があり、  
(ctime = change time ではなく) ファイルを作成した日時を得ることができます。  
[http://netbsd.gw.com/cgi-bin/man-cgi?stat+2+NetBSD-current](http://netbsd.gw.com/cgi-bin/man-cgi?stat+2+NetBSD-current)  
[http://www.freebsd.org/cgi/man.cgi?query=stat&sektion=2&apropos=0&manpath=FreeBSD+10.0-RELEASE](http://www.freebsd.org/cgi/man.cgi?query=stat&sektion=2&apropos=0&manpath=FreeBSD+10.0-RELEASE)  
[https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/stat.2.html](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/stat.2.html)

また、Windowsはbirthtimeがあるがctimeがないという環境ですので、birthtimeはctimeを返します。  
[http://msdn.microsoft.com/ja-jp/library/ms350241(v=vs.71).aspx](http://msdn.microsoft.com/ja-jp/library/ms350241(v=vs.71).aspx)

今回のパッチではLinuxやOpenBSDなど、struct statにbirthtimeがない環境では、  
Windows同様ctimeを返すようにしています。  
（が、意味が違うからWindows以外ではNotImpErrorの方がいいかも）

[https://github.com/nurse/ruby/compare/ruby:trunk...birthtime](https://github.com/nurse/ruby/compare/ruby:trunk...birthtime)
