597件ヒット
[101-200件を表示]
(0.045秒)
クラス
- Dir (23)
- File (120)
-
File
:: Stat (12) - IO (430)
モジュール
- Enumerable (12)
キーワード
- <=> (12)
- advise (12)
- atime (12)
- chown (12)
- chunk (12)
- clone (12)
- close (12)
-
close
_ on _ exec= (12) - ctime (12)
- dup (12)
-
each
_ byte (24) -
each
_ codepoint (24) -
external
_ encoding (12) - fcntl (12)
- fdatasync (12)
- fileno (11)
- flock (12)
- flush (12)
-
internal
_ encoding (12) - lstat (12)
- mtime (12)
- path (12)
- pos (12)
- pos= (12)
- pread (8)
- pwrite (8)
- read (24)
- readbyte (12)
- readlines (36)
- reopen (36)
-
set
_ encoding (36) -
set
_ encoding _ by _ bom (6) - size (12)
- stat (12)
- sync (12)
- sysread (12)
- sysseek (12)
- syswrite (12)
- tell (12)
-
to
_ path (12) - truncate (12)
- write (12)
検索結果
先頭5件
-
File
# size -> Integer (9021.0) -
ファイルのサイズを返します。
...ファイルのサイズを返します。
//emlist[例][ruby]{
File.open("/dev/null") do |f|
f.size #=> 0
end
//}
@raise IOError 自身が close されている場合に発生します。
@raise Errno::EXXX 失敗した場合に発生します。
@see File#lstat... -
File
# truncate(length) -> 0 (9015.0) -
ファイルのサイズを最大 length バイトにします。
...書き込み用にオープンされていなければ発生します。
@raise Errno::EXXX サイズの変更に失敗した場合に発生します。
//emlist[例][ruby]{
IO.write("testfile", "1234567890")
File.open("testfile", "a") do |f|
f.truncate(5) # => 0
f.size # => 5
end
//}... -
IO
# reopen(path) -> self (6127.0) -
path で指定されたファイルにストリームを繋ぎ換えます。
...IO.write("testfile", "This 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.readline......s # => ["This is line one\n", "This is line two\n", "This is line three\n"]
f2.close
//}
@see Kernel.#open... -
IO
# reopen(path , mode) -> self (6127.0) -
path で指定されたファイルにストリームを繋ぎ換えます。
...IO.write("testfile", "This 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.readline......s # => ["This is line one\n", "This is line two\n", "This is line three\n"]
f2.close
//}
@see Kernel.#open... -
Dir
# fileno -> Integer (6109.0) -
self に関連づけられたファイル記述子を表す整数を返します。
...self に関連づけられたファイル記述子を表す整数を返します。
//emlist[例][ruby]{
Dir.open("..") { |d| d.fileno } # => 8
//}
本メソッドでは POSIX 2008 で定義されている dirfd() 関数を使用します。
@raise NotImplementedError Windows などの dirfd()......関数が存在しないプラッ
トフォームで発生します。
@raise IOError 既に自身が close している場合に発生します。
@see IO#fileno... -
IO
# reopen(io) -> self (6107.0) -
自身を指定された io に繋ぎ換えます。
自身を指定された io に繋ぎ換えます。
クラスも io に等しくなることに注意してください。
IO#pos, IO#lineno などは指定された io と等しくなります。
@param io 自身を繋ぎ換えたい IO オブジェクトを指定します。
@raise IOError 指定された io が close されている場合に発生します。 -
File
:: Stat # <=>(o) -> Integer | nil (3051.0) -
ファイルの最終更新時刻を比較します。self が other よりも 新しければ正の数を、等しければ 0 を古ければ負の数を返します。 比較できない場合は nil を返します。
...o File::Stat のインスタンスを指定します。
//emlist[][ruby]{
require 'tempfile' # for Tempfile
fp1 = Tempfile.open("first")
fp1.print "古い方\n"
sleep(1)
fp2 = Tempfile.open("second")
fp2.print "新しい方\n"
p File::Stat.new(fp1.path) <=> File::Stat.new(fp2.path) #=> -1
p File:......:Stat.new(fp2.path) <=> File::Stat.new(fp1.path) #=> 1
p File::Stat.new(fp1.path) <=> fp2.path #=> nil
//}... -
IO
# stat -> File :: Stat (150.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
# readlines(limit , chomp: false) -> [String] (63.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...uby]{
IO.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("testfile") { |f| p f.readlines(3) } # => ["lin", "e1,", "\n", "lin", "e2,", "\n", "lin", "e3,", "\n"]
File.open("testfile") { |f| p f.readlin......//emlist[例: rsを取り除く(chomp = true)][ruby]{
IO.write("testfile", "line1,\rline2,\r\nline3,\n")
File.open("testfile") { |f| p f.readlines(chomp: true) } # => ["line1,\rline2,", "line3,"]
File.open("testfile") { |f| p f.readlines("\r", chomp: true) } # => ["line1,", "line2,", "\n...