ライブラリ
- ビルトイン (56)
- pathname (1)
- shell (25)
-
shell
/ command-processor (25) -
shell
/ filter (25) - tempfile (2)
- tmpdir (2)
- zlib (5)
クラス
- Dir (2)
- File (24)
-
File
:: Stat (3) - Pathname (1)
- Shell (25)
-
Shell
:: CommandProcessor (25) -
Shell
:: Filter (25) - Tempfile (2)
-
Zlib
:: GzipWriter (5)
モジュール
- FileTest (27)
キーワード
- Stat (1)
- [] (3)
- blockdev? (5)
- chardev? (5)
- close (1)
- close! (1)
- directory? (6)
- empty? (2)
- executable? (5)
-
executable
_ real? (5) - exist? (5)
- exists? (4)
- file? (6)
- grpowned? (5)
- identical? (2)
- mktmpdir (2)
- new (1)
- open (2)
- owned? (5)
- pipe? (5)
- readable? (5)
-
readable
_ real? (5) -
ruby 1
. 8 . 4 feature (1) - setgid? (5)
- setuid? (5)
- size (5)
- size? (6)
- socket? (5)
- sticky? (5)
- symlink? (6)
- test (3)
-
world
_ readable? (1) -
world
_ writable? (1) - wrap (2)
- writable? (5)
-
writable
_ real? (5) - zero? (5)
- セキュリティモデル (1)
検索結果
先頭5件
-
FileTest (132037.0)
-
ファイルの検査関数を集めたモジュールです。
ファイルの検査関数を集めたモジュールです。
=== 注意
FileTest で定義された各メソッドは、システムコールに失敗しても例外を発生させません。
真を返した時のみ、返り値は意味をもちます。
例えば、
File.exist?('/root/.bashrc')
が false を返しても、それはファイルが存在しないことを保証しません。 -
FileTest
. # file?(file) -> bool (90769.0) -
ファイルが通常ファイルである時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
ファイルが通常ファイルである時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。
例:
FileTest.file?('/bin/bash') # => true
FileTest.file?('/bin') # => false
FileTest.file?('/no_such_file') ... -
File
. file?(path) -> bool (81400.0) -
FileTest.#file? と同じです。
FileTest.#file? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。 -
FileTest
. # identical?(file1 , file2) -> bool (72937.0) -
file1 と file2 が同じファイルを指している時に真を返します。 そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
file1 と file2 が同じファイルを指している時に真を返します。
そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
ruby 1.8.3 以前ではKernel.#test(?-, file1, file2)を使ってください。
open("a", "w") {}
p File.identical?("a", "a") #=> true
p File.identical?("a", "./a") #=> true
File.link("a", "b")
p File.identical... -
FileTest
. # directory?(file) -> bool (72430.0) -
ファイルがディレクトリの時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
ファイルがディレクトリの時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。
例:
FileTest.directory?('/etc') # => true
FileTest.directory?('/etc/passwd') # => false
f = File.open('/etc')... -
FileTest
. # exist?(file) -> bool (72430.0) -
ファイルが存在する時に真を返します。そうでない場合、あるいはシステムコールに失敗した場合などには false を返します。
ファイルが存在する時に真を返します。そうでない場合、あるいはシステムコールに失敗した場合などには false を返します。
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。
例:
FileTest.exist?('/etc/passwd') # => true
FileTest.exist?('/etc') # => true
FileTest.exist?('/etc/no_such_file') # => false... -
FileTest
. # size?(file) -> Integer | nil (72430.0) -
ファイルのサイズを返します。ファイルが存在しない時や ファイルのサイズが0の時には nil を返します。
ファイルのサイズを返します。ファイルが存在しない時や
ファイルのサイズが0の時には nil を返します。
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。
//emlist[例][ruby]{
IO.write("testfile", "test")
FileTest.size?("testfile") # => 4
File.delete("testfile")
FileTest.size?("testfile") ... -
FileTest
. # empty?(file) -> bool (72415.0) -
ファイルが存在して、そのサイズが 0 である時に真を返します。 そうでない場合、あるいはシステムコールに失敗した場合には false を返します。
ファイルが存在して、そのサイズが 0 である時に真を返します。
そうでない場合、あるいはシステムコールに失敗した場合には false を返します。
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。
//emlist[例:][ruby]{
IO.write("zero.txt", "")
FileTest.zero?("zero.txt") # => true
IO.write("nonzero.txt", "1")
Fil... -
FileTest
. # zero?(file) -> bool (72415.0) -
ファイルが存在して、そのサイズが 0 である時に真を返します。 そうでない場合、あるいはシステムコールに失敗した場合には false を返します。
ファイルが存在して、そのサイズが 0 である時に真を返します。
そうでない場合、あるいはシステムコールに失敗した場合には false を返します。
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。
//emlist[例:][ruby]{
IO.write("zero.txt", "")
FileTest.zero?("zero.txt") # => true
IO.write("nonzero.txt", "1")
Fil... -
FileTest
. # blockdev?(file) -> bool (72412.0) -
ファイルがブロックスペシャルファイルである時に真を返します。 そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
ファイルがブロックスペシャルファイルである時に真を返します。
そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。
例:
Dir.glob("/dev/*") { |file|
puts file if FileTest.blockdev?(file)
}
# /dev/disk0
# /dev/di... -
FileTest
. # chardev?(file) -> bool (72412.0) -
ファイルがキャラクタスペシャルファイルの時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
ファイルがキャラクタスペシャルファイルの時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。
例:
Dir.glob("/dev/*") { |file|
puts file if FileTest.chardev?(file)
}
# /dev/console
# /dev/tty... -
FileTest
. # grpowned?(file) -> bool (72412.0) -
ファイルのグループ ID がカレントプロセスの実効グループ ID と等しい時に真を返 します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
ファイルのグループ ID がカレントプロセスの実効グループ ID と等しい時に真を返
します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。
//emlist[例][ruby]{
IO.write("testfile", "")
File.chown(-1, Process.gid, "testfile")
FileT... -
FileTest
. # owned?(file) -> bool (72412.0) -
ファイルのユーザがカレントプロセスの実効ユーザと等しい時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
ファイルのユーザがカレントプロセスの実効ユーザと等しい時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。
//emlist[例][ruby]{
IO.write("testfile", "")
File.chown(Process.uid, -1, "testfile")
FileTest.owned?(... -
FileTest
. # size(file) -> Integer (72412.0) -
ファイルのサイズを返します。
ファイルのサイズを返します。
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@raise Errno::EXXX file が存在しない場合、あるいはシステムコールに失敗した場合に発生します。
@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。
@see FileTest.#size?, FileTest.#zero?
例:
FileTest.size('/etc/passwd') # => 5925 -
FileTest
. # executable _ real?(file) -> bool (72394.0) -
ファイルがカレントプロセスの実ユーザか実グループで実行できる時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
ファイルがカレントプロセスの実ユーザか実グループで実行できる時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
@param file ファイル名を表す文字列を指定します。
//emlist[例][ruby]{
IO.write("empty.txt", "")
File.chmod(0744, "empty.txt")
FileTest.executable_real?("empty.txt") # => true
File.chmod(0644, "empty.txt")
FileTest.ex... -
FileTest
. # readable?(file) -> bool (72394.0) -
ファイルがカレントプロセスにより読み込み可能な時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
ファイルがカレントプロセスにより読み込み可能な時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
@param file ファイル名を表す文字列を指定します。
//emlist[例][ruby]{
IO.write("testfile", "")
File.chmod(0644, "testfile")
FileTest.readable?("testfile") # => true
File.chmod(0200, "testfile")
FileTest.readable?("testfile"... -
FileTest
. # writable?(file) -> bool (72394.0) -
ファイルがカレントプロセスにより書き込み可能である時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
ファイルがカレントプロセスにより書き込み可能である時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
@param file ファイル名を表す文字列を指定します。
//emlist[例][ruby]{
IO.write("testfile", "test")
File.chmod(0600, "testfile")
FileTest.writable?("testfile") # => true
File.chmod(0400, "testfile")
FileTest.writable?("tes... -
FileTest
. # pipe?(file) -> bool (72376.0) -
指定したファイルがパイプである時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
指定したファイルがパイプである時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。
例:
r, w = IO.pipe
FileTest.pipe?(r) # => true
FileTest.pipe?(w) # => true -
FileTest
. # setuid?(file) -> bool (72376.0) -
ファイルが setuid(2) されている時に真を返 します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
ファイルが setuid(2) されている時に真を返
します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。
//emlist[例][ruby]{
require 'fileutils'
IO.write("testfile", "")
FileUtils.chmod("u+s", "testfile")
FileTe... -
FileTest
. # socket?(file) -> bool (72376.0) -
ファイルがソケットである時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
ファイルがソケットである時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。
//emlist[例][ruby]{
require "socket"
IO.write("testfile", "test")
p FileTest.socket?("testfile") ... -
FileTest
. # symlink?(file) -> bool (72376.0) -
ファイルがシンボリックリンクである時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
ファイルがシンボリックリンクである時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
@param file ファイル名を表す文字列を指定します。
//emlist[例][ruby]{
IO.write("testfile", "test")
FileTest.symlink?("testfile") # => false
File.symlink("testfile", "testlink")
FileTest.symlink?("testlink") # => true
//} -
FileTest
. # executable?(file) -> bool (72358.0) -
ファイルがカレントプロセスにより実行できる時に真を返しま す。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
ファイルがカレントプロセスにより実行できる時に真を返しま
す。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
@param file ファイル名を表す文字列を指定します。
例:
FileTest.executable?('/bin') # => true
FileTest.executable?('/bin/bash') # => true -
FileTest
. # setgid?(file) -> bool (72358.0) -
ファイルが setgid(2) されている時に真を返 します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
ファイルが setgid(2) されている時に真を返
します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
//emlist[例][ruby]{
require 'fileutils'
IO.write("testfile", "")
FileUtils.chmod("g+s", "testfile")
FileTest.setgid?("testfile") # => true
FileUtils.chmod("g-s", "... -
FileTest
. # sticky?(file) -> bool (72358.0) -
ファイルの sticky ビット(chmod(2) 参照)が 立っている時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
ファイルの sticky ビット(chmod(2) 参照)が
立っている時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
//emlist[例][ruby]{
require 'fileutils'
IO.write("testfile", "")
FileUtils.chmod("o+t", "testfile")
FileTest.sticky?("testfile") # => true
FileUtils.... -
FileTest
. # exists?(file) -> bool (72352.0) -
このメソッドは Ruby 2.1 から deprecated です。FileTest.#exist? を使用してください。
このメソッドは Ruby 2.1 から deprecated です。FileTest.#exist? を使用してください。 -
FileTest
. # readable _ real?(file) -> bool (72340.0) -
ファイルがカレントプロセスの実ユーザか実グループによって読み込み可能な時に真を 返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
ファイルがカレントプロセスの実ユーザか実グループによって読み込み可能な時に真を
返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
@param file ファイル名を表す文字列を指定します。
@see FileTest.#readable? -
FileTest
. # writable _ real?(file) -> bool (72340.0) -
ファイルがカレントプロセスの実ユーザか実グループによって書き込み可能である時に真 を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
ファイルがカレントプロセスの実ユーザか実グループによって書き込み可能である時に真
を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
@param file ファイル名を表す文字列を指定します。
@see FileTest.#writable? -
FileTest
. # world _ readable?(path) -> Integer | nil (72019.0) -
path が全てのユーザから読めるならばそのファイルのパーミッションを表す 整数を返します。そうでない場合は nil を返します。
path が全てのユーザから読めるならばそのファイルのパーミッションを表す
整数を返します。そうでない場合は nil を返します。
整数の意味はプラットフォームに依存します。
@param path パスを表す文字列を指定します。
m = FileTest.world_readable?("/etc/passwd")
"%o" % m # => "644" -
FileTest
. # world _ writable?(path) -> bool (72019.0) -
path が全てのユーザから書き込めるならば、そのファイルのパーミッションを表す 整数を返します。そうでない場合は nil を返します。
path が全てのユーザから書き込めるならば、そのファイルのパーミッションを表す
整数を返します。そうでない場合は nil を返します。
整数の意味はプラットフォームに依存します。
@param path パスを表す文字列を指定します。
m = FileTest.world_writable?("/tmp")
"%o" % m #=> "777" -
File
. identical?(filename1 , filename2) -> bool (63649.0) -
FileTest.#identical? と同じです。
FileTest.#identical? と同じです。
@param filename1 パスを表す文字列か IO オブジェクトを指定します。
@param filename2 パスを表す文字列か IO オブジェクトを指定します。 -
File
. blockdev?(path) -> bool (63067.0) -
FileTest.#blockdev? と同じです。
FileTest.#blockdev? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。
@see FileTest.#blockdev? -
File
. chardev?(path) -> bool (63049.0) -
FileTest.#chardev? と同じです。
FileTest.#chardev? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。 -
File
. directory?(path) -> bool (63049.0) -
FileTest.#directory? と同じです。
FileTest.#directory? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。 -
File
. empty?(path) -> bool (63049.0) -
FileTest.#zero? と同じです。
FileTest.#zero? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。 -
File
. executable?(path) -> bool (63049.0) -
FileTest.#executable? と同じです。
FileTest.#executable? と同じです。
@param path パスを表す文字列を指定します。 -
File
. executable _ real?(path) -> bool (63049.0) -
FileTest.#executable_real? と同じです。
FileTest.#executable_real? と同じです。
@param path パスを表す文字列を指定します。 -
File
. exist?(path) -> bool (63049.0) -
FileTest.#exist? と同じです。
FileTest.#exist? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。 -
File
. grpowned?(path) -> bool (63049.0) -
FileTest.#grpowned? と同じです。
FileTest.#grpowned? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。 -
File
. owned?(path) -> bool (63049.0) -
FileTest.#owned? と同じです。
FileTest.#owned? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。 -
File
. pipe?(path) -> bool (63049.0) -
FileTest.#pipe? と同じです。
FileTest.#pipe? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。 -
File
. readable?(path) -> bool (63049.0) -
FileTest.#readable? と同じです。
FileTest.#readable? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。 -
File
. readable _ real?(path) -> bool (63049.0) -
FileTest.#readable_real? と同じです。
FileTest.#readable_real? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。 -
File
. setgid?(path) -> bool (63049.0) -
FileTest.#setgid? と同じです。
FileTest.#setgid? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。 -
File
. setuid?(path) -> bool (63049.0) -
FileTest.#setuid? と同じです。
FileTest.#setuid? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。 -
File
. size(path) -> Integer (63049.0) -
FileTest.#size と同じです。
FileTest.#size と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。 -
File
. size?(path) -> Integer | nil (63049.0) -
FileTest.#size? と同じです。
FileTest.#size? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。 -
File
. socket?(path) -> bool (63049.0) -
FileTest.#socket? と同じです。
FileTest.#socket? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。 -
File
. sticky?(path) -> bool (63049.0) -
FileTest.#sticky? と同じです。
FileTest.#sticky? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。 -
File
. symlink?(path) -> bool (63049.0) -
FileTest.#symlink? と同じです。
FileTest.#symlink? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。 -
File
. writable?(path) -> bool (63049.0) -
FileTest.#writable? と同じです。
FileTest.#writable? と同じです。
@param path パスを表す文字列を指定します。 -
File
. writable _ real?(path) -> bool (63049.0) -
FileTest.#writable_real? と同じです。
FileTest.#writable_real? と同じです。
@param path パスを表す文字列を指定します。 -
File
. zero?(path) -> bool (63049.0) -
FileTest.#zero? と同じです。
FileTest.#zero? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。 -
Shell
# file?(file) -> bool (18709.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@see FileTest.#file? -
Shell
:: CommandProcessor # file?(file) -> bool (18709.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@see FileTest.#file? -
Shell
:: Filter # file?(file) -> bool (18709.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@see FileTest.#file? -
Pathname
# file? -> bool (18436.0) -
FileTest.file?(self.to_s) と同じです。
FileTest.file?(self.to_s) と同じです。
@see FileTest.#file? -
File
:: Stat # symlink? -> false (9121.0) -
シンボリックリンクである時に真を返します。 ただし、File::Statは自動的にシンボリックリンクをたどっていくので 常にfalseを返します。
シンボリックリンクである時に真を返します。
ただし、File::Statは自動的にシンボリックリンクをたどっていくので
常にfalseを返します。
//emlist[][ruby]{
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.symlink?(outfile) #=> true
//}
... -
File
:: Stat (9055.0) -
ファイルの情報を格納したオブジェクトのクラス。
ファイルの情報を格納したオブジェクトのクラス。
FileTest に同名のモジュール関数がある場合はそれと同じ働きをします。ただ、
ファイル名を引数に取るかわりに Stat 自身について判定する点が違います。
//emlist[][ruby]{
p File::Stat.new($0).directory? #=> false
p FileTest.directory?($0) #=> false
//}
1.8 以降では、属性メソッドがシステムでサポートされていない場合 nil が返ります。
なお、1.7 以前では 0 が返っていました。
dev デバイス番号(フ... -
File
:: Stat # size? -> Integer | nil (9055.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
//} -
File
:: Stat # directory? -> bool (9037.0) -
ディレクトリの時に真を返します。
ディレクトリの時に真を返します。
//emlist[][ruby]{
p File::Stat.new($0).directory? #=> false
//}
@see FileTest.#directory? -
Tempfile
# close! -> nil (9019.0) -
テンポラリファイルをクローズし、すぐに削除します。
テンポラリファイルをクローズし、すぐに削除します。
require "tempfile"
tf = Tempfile.open("bar")
path = tf.path
tf.close!
p FileTest.exist?(path) # => false -
Tempfile
# close(real = false) -> nil (9019.0) -
テンポラリファイルをクローズします。 real が偽ならば、テンポラリファイルはGCによって削除されます。 そうでなければ、すぐに削除されます。
テンポラリファイルをクローズします。
real が偽ならば、テンポラリファイルはGCによって削除されます。
そうでなければ、すぐに削除されます。
@param real false もしくはそれ以外を指定します。
require "tempfile"
tf = Tempfile.open("bar")
tf.close
p FileTest.exist?(tf.path) # => true -
ruby 1
. 8 . 4 feature (883.0) -
ruby 1.8.4 feature ruby 1.8.4 での ruby 1.8.3 からの変更点です。
ruby 1.8.4 feature
ruby 1.8.4 での ruby 1.8.3 からの変更点です。
掲載方針
*バグ修正の影響も含めて動作が変わるものを収録する。
*単にバグを直しただけのものは収録しない。
*ライブラリへの単なる定数の追加は収録しない。
以下は各変更点に付けるべきタグです。
記号について(特に重要なものは大文字(主観))
# * カテゴリ
# * [ruby]: ruby インタプリタの変更
# * [api]: 拡張ライブラリ API
# * [lib]: ライブラリ
* レベル
* [bug]: バグ修正
* [new]: 追加され... -
Shell
# [](command , file1 , file2 = nil) -> bool | Time | Integer | nil (733.0) -
Kernel.#test や FileTest のメソッドに処理を委譲します。
Kernel.#test や FileTest のメソッドに処理を委譲します。
@param command 数値、またはサイズが 1 の文字列の場合は Kernel.#test に処理委譲します。
2 文字以上の文字列の場合は FileTest のメソッドとして実行します。
@param file1 文字列でファイルへのパスを指定します。
@param file2 文字列でファイルへのパスを指定します。
require 'shell'
Shell.verbose = false
sh = Shell.new
begin
sh.m... -
Shell
# test(command , file1 , file2 = nil) -> bool | Time | Integer | nil (733.0) -
Kernel.#test や FileTest のメソッドに処理を委譲します。
Kernel.#test や FileTest のメソッドに処理を委譲します。
@param command 数値、またはサイズが 1 の文字列の場合は Kernel.#test に処理委譲します。
2 文字以上の文字列の場合は FileTest のメソッドとして実行します。
@param file1 文字列でファイルへのパスを指定します。
@param file2 文字列でファイルへのパスを指定します。
require 'shell'
Shell.verbose = false
sh = Shell.new
begin
sh.m... -
Shell
:: CommandProcessor # [](command , file1 , file2 = nil) -> bool | Time | Integer | nil (733.0) -
Kernel.#test や FileTest のメソッドに処理を委譲します。
Kernel.#test や FileTest のメソッドに処理を委譲します。
@param command 数値、またはサイズが 1 の文字列の場合は Kernel.#test に処理委譲します。
2 文字以上の文字列の場合は FileTest のメソッドとして実行します。
@param file1 文字列でファイルへのパスを指定します。
@param file2 文字列でファイルへのパスを指定します。
require 'shell'
Shell.verbose = false
sh = Shell.new
begin
sh.m... -
Shell
:: CommandProcessor # test(command , file1 , file2 = nil) -> bool | Time | Integer | nil (733.0) -
Kernel.#test や FileTest のメソッドに処理を委譲します。
Kernel.#test や FileTest のメソッドに処理を委譲します。
@param command 数値、またはサイズが 1 の文字列の場合は Kernel.#test に処理委譲します。
2 文字以上の文字列の場合は FileTest のメソッドとして実行します。
@param file1 文字列でファイルへのパスを指定します。
@param file2 文字列でファイルへのパスを指定します。
require 'shell'
Shell.verbose = false
sh = Shell.new
begin
sh.m... -
Shell
:: Filter # [](command , file1 , file2 = nil) -> bool | Time | Integer | nil (733.0) -
Kernel.#test や FileTest のメソッドに処理を委譲します。
Kernel.#test や FileTest のメソッドに処理を委譲します。
@param command 数値、またはサイズが 1 の文字列の場合は Kernel.#test に処理委譲します。
2 文字以上の文字列の場合は FileTest のメソッドとして実行します。
@param file1 文字列でファイルへのパスを指定します。
@param file2 文字列でファイルへのパスを指定します。
require 'shell'
Shell.verbose = false
sh = Shell.new
begin
sh.m... -
Shell
:: Filter # test(command , file1 , file2 = nil) -> bool | Time | Integer | nil (733.0) -
Kernel.#test や FileTest のメソッドに処理を委譲します。
Kernel.#test や FileTest のメソッドに処理を委譲します。
@param command 数値、またはサイズが 1 の文字列の場合は Kernel.#test に処理委譲します。
2 文字以上の文字列の場合は FileTest のメソッドとして実行します。
@param file1 文字列でファイルへのパスを指定します。
@param file2 文字列でファイルへのパスを指定します。
require 'shell'
Shell.verbose = false
sh = Shell.new
begin
sh.m... -
Shell
# exist?(file) -> bool (409.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@see FileTest.#exist? FileTest.#exists? -
Shell
# exists?(file) -> bool (409.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@see FileTest.#exist? FileTest.#exists? -
Shell
# size(file) -> Integer (409.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列を指定します。
@see FileTest.#size FileTest.#size? -
Shell
# size?(file) -> Integer | nil (409.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列を指定します。
@see FileTest.#size FileTest.#size? -
Shell
:: CommandProcessor # exist?(file) -> bool (409.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@see FileTest.#exist? FileTest.#exists? -
Shell
:: CommandProcessor # exists?(file) -> bool (409.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@see FileTest.#exist? FileTest.#exists? -
Shell
:: CommandProcessor # size(file) -> Integer (409.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列を指定します。
@see FileTest.#size FileTest.#size? -
Shell
:: CommandProcessor # size?(file) -> Integer | nil (409.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列を指定します。
@see FileTest.#size FileTest.#size? -
Shell
:: Filter # exist?(file) -> bool (409.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@see FileTest.#exist? FileTest.#exists? -
Shell
:: Filter # exists?(file) -> bool (409.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@see FileTest.#exist? FileTest.#exists? -
Shell
:: Filter # size(file) -> Integer (409.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列を指定します。
@see FileTest.#size FileTest.#size? -
Shell
:: Filter # size?(file) -> Integer | nil (409.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列を指定します。
@see FileTest.#size FileTest.#size? -
Shell
# blockdev?(file) -> bool (388.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@see FileTest.#blockdev? -
Shell
# chardev?(file) -> bool (388.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@see FileTest.#chardev? -
Shell
# directory?(file) -> bool (388.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@see FileTest.#directory? -
Shell
# executable?(file) -> bool (388.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列を指定します。
@see FileTest.#executable? -
Shell
# executable _ real?(file) -> bool (388.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列を指定します。
@see FileTest.#executable_real? -
Shell
# grpowned?(file) -> bool (388.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@see FileTest.#grpowned? -
Shell
# owned?(file) -> bool (388.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@see FileTest.#owned? -
Shell
# pipe?(file) -> bool (388.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@see FileTest.#pipe? -
Shell
# readable?(file) -> bool (388.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列を指定します。
@see FileTest.#readable? -
Shell
# readable _ real?(file) -> bool (388.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列を指定します。
@see FileTest.#readable_real? -
Shell
# setgid?(file) -> bool (388.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列を指定します。
@see FileTest.#setgid? -
Shell
# setuid?(file) -> bool (388.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列を指定します。
@see FileTest.#setuid? -
Shell
# socket?(file) -> bool (388.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列を指定します。
@see FileTest.#socket? -
Shell
# sticky?(file) -> bool (388.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列を指定します。
@see FileTest.#sticky? -
Shell
# symlink?(file) -> bool (388.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列を指定します。
@see FileTest.#symlink? -
Shell
# writable?(file) -> bool (388.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列を指定します。
@see FileTest.#writable? -
Shell
# writable _ real?(file) -> bool (388.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列を指定します。
@see FileTest.#writable_real? -
Shell
# zero?(file) -> bool (388.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列を指定します。
@see FileTest.#zero? -
Shell
:: CommandProcessor # blockdev?(file) -> bool (388.0) -
FileTest モジュールにある同名のクラスメソッドと同じです.
FileTest モジュールにある同名のクラスメソッドと同じです.
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@see FileTest.#blockdev?