るりまサーチ

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

別のキーワード

  1. _builtin file?
  2. _builtin file
  3. file open
  4. file atime
  5. file path

ライブラリ

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

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

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

...文字列の場合はその先頭の文字だけをコマンドとみなします。
@param file1 テストするファイルのパスを表す文字列か IO オブジェクトを指定します。
@param file2 テストするファイルのパスを表す文字列か IO オブジェクトを指定...
...ァイル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
# => -: fals...

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

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

...るいは同じ文字を表す数値
です。文字列の場合はその先頭の文字だけをコマンドとみなします。
@param file テストするファイルのパスを表す文字列か IO オブジェクトを指定します。
@return 下表に特に明記していない...
...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.#file?(file) -> bool (12239.0)

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

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

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

例:
File
Test.file?('/bin/bash') # => true
File
Test.file?('/bin') # => false
File
Test.f...
...ile?('/no_such_file') # => false...

FileTest.#identical?(file1, file2) -> bool (6319.0)

file1 と file2 が同じファイルを指している時に真を返します。 そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。

...
file
1 と file2 が同じファイルを指している時に真を返します。
そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。

ruby 1.8.3 以前ではKernel.#test(?-, file1, file2)を使...
...p File.identical?("a", "a") #=> true
p File.identical?("a", "./a") #=> true
File
.link("a", "b")
p File.identical?("a", "b") #=> true
File
.symlink("a", "c")
p File.identical?("a", "c") #=> true
open("d", "w") {}
p File.identical?("a", "d") #=> false

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

@param file2 ファイル名を表す文字列か IO オブジェクトを指定します。

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

FileTest.#blockdev?(file) -> bool (6132.0)

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

...@param file ファイル名を表す文字列か IO オブジェクトを指定します。

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

例:
Dir.glob("/dev/*") { |file|
puts file if FileTest.blockdev?(file)
}
# /d...

絞り込み条件を変える

FileTest.#chardev?(file) -> bool (6132.0)

ファイルがキャラクタスペシャルファイルの時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。

...

@param file ファイル名を表す文字列か IO オブジェクトを指定します。

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

例:
Dir.glob("/dev/*") { |file|
puts file if FileTest.chardev?(file)
}
#...

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

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

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

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

//emlist[例][ruby]{
IO.write("testfile", "")
File
.chown(-1, Process.gid, "testfile")
File
Test...
....grpowned?("testfile") # => true
File
.chown(-1, Process.gid + 10, "testfile")
File
Test.grpowned?("testfile") # => false
//}...

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

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

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

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

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

FileTest.#size?(file) -> Integer | nil (6126.0)

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

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

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

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

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

FileTest.#writable?(file) -> bool (6126.0)

ファイルがカレントプロセスにより書き込み可能である時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。

...false を返します。

@param file ファイル名を表す文字列を指定します。

//emlist[例][ruby]{
IO.write("testfile", "test")
File
.chmod(0600, "testfile")
File
Test.writable?("testfile") # => true
File
.chmod(0400, "testfile")
File
Test.writable?("testfile") # => false
//}...

絞り込み条件を変える

<< 1 2 3 ... > >>