1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

RubyでFile::Statを使って情報引き出す

Last updated at Posted at 2020-07-23

メモです。
File::Statはファイルの情報を格納したオブジェクトのクラスです。また、ファイルの所有ユーザ・グループを表示させるためにetc使います。

class File::Stat (Ruby 2.7.0 リファレンスマニュアル)

module Etc (Ruby 2.7.0 リファレンスマニュアル)

require "etc"
stat = File::Stat.new("aaa.rb")

puts stat.uid #=> 501
puts stat.gid #=> 20
puts stat.size #=> 1738
puts stat.mtime #=> 2020-07-23 16:46:50.584154183 +0900
puts stat.uid #=> 501
puts Etc.getpwuid(stat.uid).name #=> uetennis
puts Etc.getgrgid(stat.gid).name #=> staff
puts File.basename("aaa.rb") #=> aaa.rb

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?