種類
- インスタンスメソッド (335)
- 特異メソッド (8)
ライブラリ
- ビルトイン (343)
キーワード
- <=> (8)
- atime (8)
- birthtime (7)
- blksize (8)
- blockdev? (8)
- blocks (8)
- chardev? (8)
- ctime (8)
- dev (8)
-
dev
_ minor (8) - directory? (8)
- executable? (8)
-
executable
_ real? (8) - file? (8)
- ftype (8)
- grpowned? (8)
- ino (8)
- mode (8)
- mtime (8)
- new (8)
- nlink (8)
- owned? (8)
- pipe? (8)
- rdev (8)
-
rdev
_ major (8) -
rdev
_ minor (8) - readable? (8)
-
readable
_ real? (8) - setgid? (8)
- setuid? (8)
- size (8)
- size? (8)
- socket? (8)
- sticky? (8)
- uid (8)
-
world
_ readable? (8) -
world
_ writable? (8) - writable? (8)
-
writable
_ real? (8) - zero? (8)
検索結果
先頭5件
-
File
:: Stat # file? -> bool (12120.0) -
通常ファイルの時に真を返します。
...通常ファイルの時に真を返します。
p File::Stat.new($0).file? #=> true... -
File
:: Stat . new(path) -> File :: Stat (6291.0) -
path に関する File::Stat オブジェクトを生成して返します。 File.stat と同じです。
...する File::Stat オブジェクトを生成して返します。
File.stat と同じです。
@param path ファイルのパスを指定します。
@raise Errno::ENOENT pathに該当するファイルが存在しない場合発生します。
p $:[0]
#=> 例
# "C:/Program Files/ruby-1.8....../lib/ruby/site_ruby/1.8"
p File::Stat.new($:[0])
#=> 例
#<File::Stat dev=0x2, ino=0, mode=040755, nlink=1, uid=0, gid=0, rdev=0x2, size=0, blksize=nil, blocks=nil, atime=Sun Sep 02 14:15:20 +0900 2007, mtime=Tue Apr 24 23:03:44 +0900 2007, ctime=Tue Apr 24 23:03:37 +0900 2007>... -
File
:: Stat # world _ readable? -> Integer | nil (6077.0) -
If stat is readable by others, returns an integer representing the file permission bits of stat. Returns nil otherwise. The meaning of the bits is platform dependent; on Unix systems, see stat(2).
...If stat is readable by others, returns an integer representing
the file permission bits of stat. Returns nil otherwise. The
meaning of the bits is platform dependent; on Unix systems, see
stat(2).
m = File.stat("/etc/passwd").world_readable? # => 420
sprintf("%o", m)... -
File
:: Stat # world _ writable? -> Integer | nil (6077.0) -
If stat is writable by others, returns an integer representing the file permission bits of stat. Returns nil otherwise. The meaning of the bits is platform dependent; on Unix systems, see stat(2).
...If stat is writable by others, returns an integer representing
the file permission bits of stat. Returns nil otherwise. The
meaning of the bits is platform dependent; on Unix systems, see
stat(2).
m = File.stat("/tmp").world_writable? # => 511
sprintf("%o", m)... -
File
:: Stat # <=>(o) -> Integer | nil (6073.0) -
ファイルの最終更新時刻を比較します。self が other よりも 新しければ正の数を、等しければ 0 を古ければ負の数を返します。 比較できない場合は nil を返します。
...o File::Stat のインスタンスを指定します。
require 'tempfile' # for Tempfile
fp1 = Tempfile.open("first")
fp1.print "古い方\n"
sleep(1)
fp2 = Tempfile.open("second")
fp2.print "新しい方\n"
p File::Stat.new(fp1.path) <=> File::Stat.new(fp2.path) #=> -1
p File::......Stat.new(fp2.path) <=> File::Stat.new(fp1.path) #=> 1
p File::Stat.new(fp1.path) <=> fp2.path #=> nil... -
File
:: Stat # birthtime -> Time (6073.0) -
作成された時刻を返します。
...
File.write("testfile", "foo")
sleep 10
File.write("testfile", "bar")
sleep 10
File.chmod(0644, "testfile")
sleep 10
File.read("testfile")
File.stat("testfile").birthtime #=> 2014-02-24 11:19:17 +0900
File.stat("testfile").mtime #=> 2014-02-24 11:19:27 +0900
File.stat("t......estfile").ctime #=> 2014-02-24 11:19:37 +0900
File.stat("testfile").atime #=> 2014-02-24 11:19:47 +0900... -
File
:: Stat # symlink? -> false (6057.0) -
シンボリックリンクである時に真を返します。 ただし、File::Statは自動的にシンボリックリンクをたどっていくので 常にfalseを返します。
...し、File::Statは自動的にシンボリックリンクをたどっていくので
常にfalseを返します。
require 'fileutils'
outfile = $0 + ".ln"
FileUtils.ln_s($0, outfile)
p File::Stat.new(outfile).symlink? #=> false
p File.lstat(outfile).symlink? #=> true
p FileTest.s......ymlink?(outfile) #=> true
@see File.lstat... -
File
:: Stat # ftype -> String (6037.0) -
ファイルのタイプを表す文字列を返します。
...列を返します。
文字列は以下のうちのいずれかです。
"file"
"directory"
"characterSpecial"
"blockSpecial"
"fifo"
"link"
"socket"
"unknown"
サンプル
fs = File::Stat.new($0)
p fs.ftype #=> "file"
p File::Stat.new($:[0]).ftype #=> "directory"... -
File
:: Stat # socket? -> bool (6031.0) -
ソケットの時に真を返します。
...ソケットの時に真を返します。
Dir.glob("/tmp/*"){|file|
if File::Stat.new(file).socket?
printf "%s\n", file
end
}
#例
#=> /tmp/uimhelper-hogehoge
#...... -
File
:: Stat # grpowned? -> bool (6025.0) -
グループIDが実効グループIDと等しい時に真を返します。
...効グループIDと等しい時に真を返します。
補助グループIDは考慮されません。
printf "%s %s\n", $:[0], File::Stat.new($:[0]).grpowned?
#例
#=> /usr/local/lib/site_ruby/1.8 false
printf "%s %s\n", $0, File::Stat.new($0).grpowned?
#例
#=> filestat.rb true... -
File
:: Stat # size? -> Integer | nil (6025.0) -
サイズが0の時にはnil、それ以外の場合はファイルサイズを返します。
...時にはnil、それ以外の場合はファイルサイズを返します。
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... -
File
:: Stat # atime -> Time (6013.0) -
最終アクセス時刻を返します。
...最終アクセス時刻を返します。
fs = File::Stat.new($0)
#例
p fs.atime.to_a #=> [45, 5, 21, 5, 9, 2007, 3, 248, false, "\223\214\213\236 (\225W\217\200\216\236) "]
@see Time... -
File
:: Stat # blksize -> Integer (6013.0) -
望ましいI/Oのブロックサイズを返します。
...望ましいI/Oのブロックサイズを返します。
fs = File::Stat.new($0)
#例
p fs.blksize #=> nil...