ライブラリ
- ビルトイン (249)
検索結果
先頭5件
-
Kernel
. # select(reads , writes = [] , excepts = [] , timeout = nil) -> [[IO]] | nil (8101.0) -
IO.select と同じです。
...IO.select と同じです。
@param reads IO.select 参照
@param writes IO.select 参照
@param excepts IO.select 参照
@param timeout IO.select 参照
@see IO.select... -
Kernel
. # spawn(env , program , *args , options={}) -> Integer (8037.0) -
引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
...) # read mode
pid = spawn(command, :out=>"/dev/null") # write mode
pid = spawn(command, :err=>"log") # write mode
pid = spawn(command, 3=>"/dev/null") # read mode
//}
stdout と stderr をリダイレクトした場合は、
ファイルは write mode で open されます。それ以外の場合は......read mode で open されます。
ファイルのフラグ(write/read mode)やパーミッションを明示したい
場合は、配列を用います。
//emlist[][ruby]{
# なにも指定がなければデフォルトで read mode が使われる。
pid = spawn(command, :in=>["file"])
# read m......レクトする。
pid = spawn(command, :in=>["file", "r"])
# write mode で file を open し、リダイレクトする。
# パーミッションはデフォルトで 644。
pid = spawn(command, :out=>["log", "w"]) # 0644 assumed
# write mode、パーミッション 0600 でファイルをオー... -
Kernel
. # spawn(program , *args) -> Integer (8037.0) -
引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
...) # read mode
pid = spawn(command, :out=>"/dev/null") # write mode
pid = spawn(command, :err=>"log") # write mode
pid = spawn(command, 3=>"/dev/null") # read mode
//}
stdout と stderr をリダイレクトした場合は、
ファイルは write mode で open されます。それ以外の場合は......read mode で open されます。
ファイルのフラグ(write/read mode)やパーミッションを明示したい
場合は、配列を用います。
//emlist[][ruby]{
# なにも指定がなければデフォルトで read mode が使われる。
pid = spawn(command, :in=>["file"])
# read m......レクトする。
pid = spawn(command, :in=>["file", "r"])
# write mode で file を open し、リダイレクトする。
# パーミッションはデフォルトで 644。
pid = spawn(command, :out=>["log", "w"]) # 0644 assumed
# write mode、パーミッション 0600 でファイルをオー... -
Kernel
. # test(cmd , file1 , file2) -> bool (8014.0) -
2ファイル間のファイルテストを行います。
...2より最終更新時刻が古い
: ?-
ファイル1とファイル2が同一のファイルである
//emlist[例][ruby]{
IO.write("testfile1", "test1")
IO.write("testfile2", "test2")
%w(= < > -).each do |e|
result = test(e, "testfile1", "testfile2")
puts "#{e}: #{result}"
end
//}
# => =... -
FileTest
. # empty?(file) -> bool (8013.0) -
ファイルが存在して、そのサイズが 0 である時に真を返します。 そうでない場合、あるいはシステムコールに失敗した場合には false を返します。
...された IO オブジェクト file が既に close されていた場合に発生します。
//emlist[例:][ruby]{
IO.write("zero.txt", "")
FileTest.zero?("zero.txt") # => true
IO.write("nonzero.txt", "1")
FileTest.zero?("nonzero.txt") # => false
//}
@see FileTest.#size, FileTest.#size?... -
FileTest
. # zero?(file) -> bool (8013.0) -
ファイルが存在して、そのサイズが 0 である時に真を返します。 そうでない場合、あるいはシステムコールに失敗した場合には false を返します。
...された IO オブジェクト file が既に close されていた場合に発生します。
//emlist[例:][ruby]{
IO.write("zero.txt", "")
FileTest.zero?("zero.txt") # => true
IO.write("nonzero.txt", "1")
FileTest.zero?("nonzero.txt") # => false
//}
@see FileTest.#size, FileTest.#size?... -
Kernel
. # test(cmd , file) -> bool | Time | Integer | nil (8009.0) -
単体のファイルでファイルテストを行います。
...me
: ?A
ファイルの最終アクセス時刻を返す -> Time
: ?C
ファイルの inode 変更時刻を返す -> Time
//emlist[例][ruby]{
IO.write("testfile", "test")
test("r", "testfile") # => true
test("s", "testfile") # => 4
test("M", "testfile") # => 2018-03-31 07:38:40 +0900
//}... -
FileTest
. # executable _ real?(file) -> bool (8007.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.executab... -
FileTest
. # grpowned?(file) -> bool (8007.0) -
ファイルのグループ ID がカレントプロセスの実効グループ ID と等しい時に真を返 します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
...。
@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。
//emlist[例][ruby]{
IO.write("testfile", "")
File.chown(-1, Process.gid, "testfile")
FileTest.grpowned?("testfile") # => true
File.chown(-1, Process.gid + 10, "testfile")...