るりまサーチ

最速Rubyリファレンスマニュアル検索!
173件ヒット [1-100件を表示] (0.041秒)
トップページ > クエリ:IO[x] > クエリ:write[x] > クエリ:test[x] > 種類:モジュール関数[x]

別のキーワード

  1. io popen
  2. io pipe
  3. io readlines
  4. io each
  5. io each_line

ライブラリ

モジュール

キーワード

検索結果

<< 1 2 > >>

Kernel.#test(cmd, file1, file2) -> bool (18164.0)

2ファイル間のファイルテストを行います。

...とみなします。
@param file1 テストするファイルのパスを表す文字列か IO オブジェクトを指定します。
@param file2 テストするファイルのパスを表す文字列か IO オブジェクトを指定します。
@return 真偽値を返します。

以下は cmd...
...ファイル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
//}

# => =: true
# => <: false
# => >: false
# =>...

Kernel.#test(cmd, file) -> bool | Time | Integer | nil (18154.0)

単体のファイルでファイルテストを行います。

...列の場合はその先頭の文字だけをコマンドとみなします。
@param file テストするファイルのパスを表す文字列か IO オブジェクトを指定します。
@return 下表に特に明記していないものは、真偽値を返します。

以下は cmd として...
...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.#empty?(file) -> bool (3037.0)

ファイルが存在して、そのサイズが 0 である時に真を返します。 そうでない場合、あるいはシステムコールに失敗した場合には false を返します。

...列か IO オブジェクトを指定します。

@raise IOError 指定された 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 (3037.0)

ファイルが存在して、そのサイズが 0 である時に真を返します。 そうでない場合、あるいはシステムコールに失敗した場合には false を返します。

...列か IO オブジェクトを指定します。

@raise IOError 指定された 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.#size?(file) -> Integer | nil (3031.0)

ファイルのサイズを返します。ファイルが存在しない時や ファイルのサイズが0の時には nil を返します。

... IO オブジェクトを指定します。

@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。

//emlist[例][ruby]{
IO
.write("testfile", "test")
FileTest.size?("testfile") # => 4
File.delete("testfile")
FileTest.size?("testfile...
...") # => nil
//}

@see FileTest.#size, FileTest.#zero?...

絞り込み条件を変える

FileTest.#socket?(file) -> bool (3031.0)

ファイルがソケットである時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。

...を表す文字列か IO オブジェクトを指定します。

@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。

//emlist[例][ruby]{
require "socket"

IO
.write("testfile", "test")
p FileTest.socket?("testfile")...
...# => false
Socket.unix_server_socket('testsock') { p FileTest.socket?('testsock') } # => true
//}...

FileTest.#grpowned?(file) -> bool (3025.0)

ファイルのグループ ID がカレントプロセスの実効グループ ID と等しい時に真を返 します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。

...文字列か IO オブジェクトを指定します。

@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")
FileTest.grpowned?("testfile") # => false
//}...

FileTest.#owned?(file) -> bool (3025.0)

ファイルのユーザがカレントプロセスの実効ユーザと等しい時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。

...す文字列か IO オブジェクトを指定します。

@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。

//emlist[例][ruby]{
IO
.write("testfile", "")
File.chown(Process.uid, -1, "testfile")
FileTest.owned?("testfile") # =...
...> true
File.chown(501, -1, "testfile")
FileTest.owned?("testfile") # => false
//}...

FileTest.#setuid?(file) -> bool (3025.0)

ファイルが setuid(2) されている時に真を返 します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。

...列か IO オブジェクトを指定します。

@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。

//emlist[例][ruby]{
require 'fileutils'
IO
.write("testfile", "")
FileUtils.chmod("u+s", "testfile")
FileTest.setuid?("testfile")...
...# => true
FileUtils.chmod("u-s", "testfile")
FileTest.setuid?("testfile") # => false
//}...

FileTest.#setgid?(file) -> bool (3019.0)

ファイルが setgid(2) されている時に真を返 します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。

...ル名を表す文字列か IO オブジェクトを指定します。

//emlist[例][ruby]{
require 'fileutils'
IO
.write("testfile", "")
FileUtils.chmod("g+s", "testfile")
FileTest.setgid?("testfile") # => true
FileUtils.chmod("g-s", "testfile")
FileTest.setgid?("testfile") # => false
//}...

絞り込み条件を変える

<< 1 2 > >>