るりまサーチ (Ruby 2.6.0)

最速Rubyリファレンスマニュアル検索!
1件ヒット [1-1件を表示] (0.027秒)
トップページ > バージョン:2.6.0[x] > クエリ:nil[x] > クエリ:Stat[x] > クエリ:size?[x]

別のキーワード

  1. _builtin stat
  2. gc stat
  3. csv stat
  4. pathname stat
  5. stat size?

ライブラリ

クラス

検索結果

File::Stat#size? -> Integer | nil (63745.0)

サイズが0の時にはnil、それ以外の場合はファイルサイズを返します。

サイズが0の時にはnil、それ以外の場合はファイルサイズを返します。

//emlist[][ruby]{
require 'tempfile'

fp = Tempfile.new("temp")
p fp.size #=> 0
p File::Stat.new(fp.path).size? #=> nil
fp.print "not 0 "
fp.close
p FileTest.exist?(fp.path) #=> true
p File::Stat.new(fp.path).size? #=> 6
//}