如何在Windows上使用Ruby获取文件创建时间?

前端之家收集整理的这篇文章主要介绍了如何在Windows上使用Ruby获取文件创建时间?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何在 Windows上使用 Ruby获取文件创建时间?

File.ctime应该返回更改时间.

cmd.exe中的dir / tc返回创建时间和其他一些东西.

有没有比执行它和解析更好的方法

显然,文件的“ctime”(“创建”或“更改”时间)元数据属性system dependent,因为某些系统(例如Windows)存储创建文件的时间(其“出生日期”)和其他(Posix系统),例如Linux)跟踪上次更新的时间. Windows使用ctime属性 as the actual creation time,因此您可以在Ruby中使用各种ctime函数.

File类具有名为ctime的静态和实例方法,它返回上次修改时间,File::Stat具有实例方法(由于不发生跟踪更改而不同).

File.ctime("foo.txt") # => Sun Oct 24 10:16:47 -0700 2010 (Time)

f = File.new("foo.txt")
f.ctime # => Will change if the file is replaced (deleted then created).

fs = File::Stat.new("foo.txt")
fs.ctime # => Will never change,regardless of any action on the file.
原文链接:https://www.f2er.com/windows/365277.html

猜你在找的Windows相关文章