るりまサーチ

最速Rubyリファレンスマニュアル検索!
580件ヒット [1-100件を表示] (0.060秒)

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Kernel.#test(cmd, file1, file2) -> bool (26340.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 (26240.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 (20238.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 (20006.0)

ファイルの検査関数を集めたモジュールです。

...を集めたモジュールです。

=== 注意

File
Test で定義された各メソッドは、システムコールに失敗しても例外を発生させません。
真を返した時のみ、返り値は意味をもちます。
例えば、
File
.exist?('/root/.bashrc')
が false を返して...

File.new(path, mode = "r", perm = 0666) -> File (17197.0)

path で指定されるファイルをオープンし、File オブジェクトを生成して 返します。

...File オブジェクトを生成して
返します。

path が整数の場合はファイルディスクリプタとして扱い、それに対応する
File
オブジェクトを生成して返します。IO.open と同じです。
ブロックを指定して呼び出した場合は、File...
...mlist[例: File.new による読み込みモードでのファイルオープン][ruby]{
f = File.new("testfile", "r")
f.class # => File
f.close
//}

//emlist[例: File.open による読み込みモードでのファイルオープン][ruby]{
f = File.open("testfile", "r")
f.class # => File
f.close...
...//}

//emlist[例: File.open による書き込みモードでのファイルオープン][ruby]{
File
.open("testfile", "w", 0755) { |f| f.print "test" }
File
.read("testfile") # => "test"
//}...

絞り込み条件を変える

File.open(path, mode = "r", perm = 0666) -> File (17197.0)

path で指定されるファイルをオープンし、File オブジェクトを生成して 返します。

...File オブジェクトを生成して
返します。

path が整数の場合はファイルディスクリプタとして扱い、それに対応する
File
オブジェクトを生成して返します。IO.open と同じです。
ブロックを指定して呼び出した場合は、File...
...mlist[例: File.new による読み込みモードでのファイルオープン][ruby]{
f = File.new("testfile", "r")
f.class # => File
f.close
//}

//emlist[例: File.open による読み込みモードでのファイルオープン][ruby]{
f = File.open("testfile", "r")
f.class # => File
f.close...
...//}

//emlist[例: File.open による書き込みモードでのファイルオープン][ruby]{
File
.open("testfile", "w", 0755) { |f| f.print "test" }
File
.read("testfile") # => "test"
//}...

File.open(path, mode = "r", perm = 0666) {|file| ... } -> object (17197.0)

path で指定されるファイルをオープンし、File オブジェクトを生成して 返します。

...File オブジェクトを生成して
返します。

path が整数の場合はファイルディスクリプタとして扱い、それに対応する
File
オブジェクトを生成して返します。IO.open と同じです。
ブロックを指定して呼び出した場合は、File...
...mlist[例: File.new による読み込みモードでのファイルオープン][ruby]{
f = File.new("testfile", "r")
f.class # => File
f.close
//}

//emlist[例: File.open による読み込みモードでのファイルオープン][ruby]{
f = File.open("testfile", "r")
f.class # => File
f.close...
...//}

//emlist[例: File.open による書き込みモードでのファイルオープン][ruby]{
File
.open("testfile", "w", 0755) { |f| f.print "test" }
File
.read("testfile") # => "test"
//}...

File.delete(*filename) -> Integer (17172.0)

ファイルを削除します。削除したファイルの数を返します。 削除に失敗した場合は例外 Errno::EXXX が発生します。

...m filename ファイル名を表す文字列を指定します。

@raise Errno::EXXX 失敗した場合に発生します。

//emlist[例][ruby]{
IO.write("test.txt", "test")
p File.exist?("test.txt") # => true
p File.delete("test.txt") # => 1
p File.exist?("test.txt") # => false
begin
File
....
...delete("test.txt")
rescue
p $! # => #<Errno::ENOENT: No such file or directory @ unlink_internal - test.txt>
end
//}...

File.unlink(*filename) -> Integer (17172.0)

ファイルを削除します。削除したファイルの数を返します。 削除に失敗した場合は例外 Errno::EXXX が発生します。

...m filename ファイル名を表す文字列を指定します。

@raise Errno::EXXX 失敗した場合に発生します。

//emlist[例][ruby]{
IO.write("test.txt", "test")
p File.exist?("test.txt") # => true
p File.delete("test.txt") # => 1
p File.exist?("test.txt") # => false
begin
File
....
...delete("test.txt")
rescue
p $! # => #<Errno::ENOENT: No such file or directory @ unlink_internal - test.txt>
end
//}...

File.lchown(owner, group, *filename) -> Integer (17158.0)

File#chown と同様ですが、 シンボリックリンクに関してリンクそのもののオーナー、 グループを変更します。

...
File
#chown と同様ですが、
シンボリックリンクに関してリンクそのもののオーナー、
グループを変更します。

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

@param owner chown(2) と同様に数値で指定します。nil または -1...
...発生します。

//emlist[例][ruby]{
IO.write("testfile", "test")
File
.symlink("testfile", "testlink")
File
.chown(501, -1, "testfile")
File
.lstat("testlink").ftype # => "link"
File
.lchown(0, -1, "testlink")
File
.stat("testlink").uid # => 501
File
.lstat("testlink").uid # => 0
//}...

絞り込み条件を変える

<< 1 2 3 ... > >>