るりまサーチ

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

別のキーワード

  1. _builtin file?
  2. _builtin file
  3. file truncate
  4. file umask
  5. file ctime

ライブラリ

キーワード

検索結果

<< 1 2 3 > >>

IO#close -> nil (18151.0)

入出力ポートをクローズします。

...例外 IOError が発生しま
す。ガーベージコレクトの際にはクローズされていない IO ポートはクロー
ズされます。
self がパイプでプロセスにつながっていれば、そのプロセスの終
了を待ち合わせます。


@raise Errno::EXXX close...
...aise IOError 既に close されていた場合に発生します。

//emlist[例][ruby]{
IO
.write("testfile", "test")
f = File.open("testfile")
f.read # => "test"
f.close
# f.read # => IOError (すでに close しているので read できない)
//}

@see IO#closed?, IO#close_read, IO#close_wr...
...うと例外 IOError が発生しま
す。ガーベージコレクトの際にはクローズされていない IO ポートはクロー
ズされます。
self がパイプでプロセスにつながっていれば、そのプロセスの終
了を待ち合わせます。

既に close されて...
...se Errno::EXXX close に失敗した場合に発生します。

//emlist[例][ruby]{
IO
.write("testfile", "test")
f = File.open("testfile")
f.read # => "test"
f.close
# f.read # => IOError (すでに close しているので read できない)
//}

@see IO#closed?, IO#close_read, IO#close_write...

IO#closed? -> bool (6150.0)

self が完全に(読み込み用と書き込み用の両方が)クローズされている場合に true を返します。 そうでない場合は false を返します。

...t[例][ruby]{
IO
.write("testfile", "test")
f = File.new("testfile")
f.close # => nil
f.closed? # => true
f = IO.popen("/bin/sh","r+")
f.close_write # => nil
f.closed? # => false
f.close_read # => nil
f.closed? # => true
//}

@see IO#close, IO#close_read, IO#close_write...

IO#fileno -> Integer (6114.0)

ファイル記述子を表す整数を返します。

...ファイル記述子を表す整数を返します。

@raise IOError 既に close されている場合に発生します。


//emlist[例][ruby]{
$stdin.fileno # => 0
$stdout.fileno # => 1
//}...
...ファイル記述子を表す整数を返します。

@raise IOError 既に close されている場合に発生します。


//emlist[例][ruby]{
$stdin.fileno # => 0
$stdout.fileno # => 1
//}

@see Dir#fileno...

IO#to_i -> Integer (3014.0)

ファイル記述子を表す整数を返します。

...ファイル記述子を表す整数を返します。

@raise IOError 既に close されている場合に発生します。


//emlist[例][ruby]{
$stdin.fileno # => 0
$stdout.fileno # => 1
//}...
...ファイル記述子を表す整数を返します。

@raise IOError 既に close されている場合に発生します。


//emlist[例][ruby]{
$stdin.fileno # => 0
$stdout.fileno # => 1
//}

@see Dir#fileno...

IO#stat -> File::Stat (155.0)

ファイルのステータスを含む File::Stat オブジェクトを生成して 返します。

...タスを含む File::Stat オブジェクトを生成して
返します。

@raise Errno::EXXX ステータスの読み込みに失敗した場合に発生します。

@raise IOError 既に close されていた場合に発生します。

//emlist[例][ruby]{
IO
.write("testfile", "This is line...
...one\nThis is line two\n")
File
.open("testfile") do |f|
s = f.stat
"%o" % s.mode # => "100644"
s.blksize # => 4096
s.atime # => 2018-03-01 23:19:59 +0900
end
//}

@see File#lstat, File.stat, File.lstat...

絞り込み条件を変える

IO#reopen(path) -> self (39.0)

path で指定されたファイルにストリームを繋ぎ換えます。

...
IO
#pos, IO#lineno などはリセットされます。

@param path パスを表す文字列を指定します。

@param mode パスを開く際のモードを文字列で指定します。

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

//emlist[例][ruby]{
IO
.write("testfile", "T...
...is line one\nThis is line two\n")
f1 = File.new("testfile", "a+")
f2 = File.new("testfile")
f1.print("This is line three\n")
f2.readlines # => ["This is line one\n", "This is line two\n"]
f1.close
f2.reopen("testfile", "r") # => #<File:testfile>
f2.readlines # => ["Th...
...is is line one\n", "This is line two\n", "This is line three\n"]
f2.close
//}

@see Kernel.#open...

IO#reopen(path, mode) -> self (39.0)

path で指定されたファイルにストリームを繋ぎ換えます。

...
IO
#pos, IO#lineno などはリセットされます。

@param path パスを表す文字列を指定します。

@param mode パスを開く際のモードを文字列で指定します。

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

//emlist[例][ruby]{
IO
.write("testfile", "T...
...is line one\nThis is line two\n")
f1 = File.new("testfile", "a+")
f2 = File.new("testfile")
f1.print("This is line three\n")
f2.readlines # => ["This is line one\n", "This is line two\n"]
f1.close
f2.reopen("testfile", "r") # => #<File:testfile>
f2.readlines # => ["Th...
...is is line one\n", "This is line two\n", "This is line three\n"]
f2.close
//}

@see Kernel.#open...

IO#clone -> IO (26.0)

レシーバと同じ IO を参照する新しい IO オブジェクトを返します。 参照しているファイル記述子は dup(2) されます。

...シーバと同じ IO を参照する新しい IO オブジェクトを返します。
参照しているファイル記述子は dup(2) されます。

clone の際に self は一旦 IO#flush されます。
フリーズした IO の clone は同様にフリーズされた IO を返しますが、...
...しいフリーズされていない IO を返します。

@raise IOError 既に close されていた場合に発生します。

//emlist[例][ruby]{
clone_io = nil
IO
.write("testfile", "test")
File
.open("testfile") do |io|
clone_io = io.clone
end
clone_io.read # => "test"
clone_io.close
//}...

IO#dup -> IO (26.0)

レシーバと同じ IO を参照する新しい IO オブジェクトを返します。 参照しているファイル記述子は dup(2) されます。

...シーバと同じ IO を参照する新しい IO オブジェクトを返します。
参照しているファイル記述子は dup(2) されます。

clone の際に self は一旦 IO#flush されます。
フリーズした IO の clone は同様にフリーズされた IO を返しますが、...
...しいフリーズされていない IO を返します。

@raise IOError 既に close されていた場合に発生します。

//emlist[例][ruby]{
clone_io = nil
IO
.write("testfile", "test")
File
.open("testfile") do |io|
clone_io = io.clone
end
clone_io.read # => "test"
clone_io.close
//}...
<< 1 2 3 > >>