147件ヒット
[1-100件を表示]
(0.013秒)
種類
- 特異メソッド (72)
- インスタンスメソッド (40)
- 文書 (35)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) -
NEWS for Ruby 2
. 2 . 0 (11) -
NEWS for Ruby 2
. 5 . 0 (8) -
NEWS for Ruby 3
. 1 . 0 (4) - binread (12)
- binwrite (24)
-
copy
_ stream (24) - pread (8)
- pwrite (8)
検索結果
先頭5件
-
IO
. write(path , string , offset=nil , **opts) -> Integer (18239.0) -
path で指定されるファイルを開き、string を書き込み、 閉じます。
...ならば、"|" に続くコマンドを実行し、コマンドの出力を標準出力に書き込みます。
offset を指定するとその位置までシークします。
offset を指定しないと、書き込みの末尾でファイルを
切り捨てます。
キーワード引数は......込む文字列
@param offset 書き込み開始位置
@param opts ファイルを開くときのキーワード引数
//emlist[例][ruby]{
text = "This is line one\nThis is line two\nThis is line three\nAnd so on...\n"
IO.write("testfile", text) # => 66
IO.write("testfile", "012345678......9", 20) #=> 10
IO.read("testfile")
# => "This is line one\nThi0123456789two\nThis is line three\nAnd so on...\n"
IO.write("testfile", "0123456789") #=> 10
IO.read("testfile") # => "0123456789"
//}
@see IO.binwrite... -
Pathname
# write(string , offset=nil , **opts) -> Integer (18220.0) -
...IO.write(self.to_s, string, offset, **opts)と同じです。
@see IO.write... -
IO
. write(path , string , **opts) -> Integer (18139.0) -
path で指定されるファイルを開き、string を書き込み、 閉じます。
...ならば、"|" に続くコマンドを実行し、コマンドの出力を標準出力に書き込みます。
offset を指定するとその位置までシークします。
offset を指定しないと、書き込みの末尾でファイルを
切り捨てます。
キーワード引数は......込む文字列
@param offset 書き込み開始位置
@param opts ファイルを開くときのキーワード引数
//emlist[例][ruby]{
text = "This is line one\nThis is line two\nThis is line three\nAnd so on...\n"
IO.write("testfile", text) # => 66
IO.write("testfile", "012345678......9", 20) #=> 10
IO.read("testfile")
# => "This is line one\nThi0123456789two\nThis is line three\nAnd so on...\n"
IO.write("testfile", "0123456789") #=> 10
IO.read("testfile") # => "0123456789"
//}
@see IO.binwrite... -
IO
. binwrite(path , string , offset=nil) -> Integer (6237.0) -
path で指定されるファイルを開き、string を書き込み、 閉じます。
...ある点以外は IO.write と同じです。
Kernel.#open と同様 path の先頭が "|" ならば、"|" に続くコマンドを実行し、コマンドの出力を標準出力に書き込みます。
offset を指定するとその位置までシークします。
offset を指定しない......、書き込みの末尾でファイルを
切り捨てます。
@param path ファイル名文字列
@param string 書き込む文字列
@param offset 書き込み開始位置
//emlist[例][ruby]{
# 8x8の真っ白なPNG画像データ。
png = 'iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAAAAADhZOFXAAAADkl......49 48 44 52
# binwriteを使用した場合: どの環境でも正しく保存できる。
IO.binwrite('white.binmode.png', png)
puts IO.binread('white.binmode.png', 16).unpack('C*').map {|c| '%02x' % c }.join(' ')
# => 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52
# binwriteを使用しなか... -
IO
# pwrite(string , offset) -> Integer (6229.0) -
stringをoffsetの位置にpwrite()システムコールを使って書き込みます。
...stringをoffsetの位置にpwrite()システムコールを使って書き込みます。
IO#seekとIO#writeの組み合わせと比べて、アトミックな操作に
なるという点が優れていて、複数スレッド/プロセスから同じIOオブジェクトを
様々な位置から読......のユーザー空間のIO層のバッファリングもバイパスします。
@param string 書き込む文字列を指定します。
@param offset ファイルポインタを変えずに書き込む位置を指定します。
@return 書き込んだバイト数を返します。
@raise Errno......敗した場合に発生します。
@raise NotImplementedError システムコールがサポートされていない OS で発生します。
//emlist[例][ruby]{
File.open("testfile", "w") do |f|
f.pwrite("ABCDEF", 3) # => 6
end
File.read("testfile") # => "\u0000\u0000\u0000ABCDEF"
//}... -
Pathname
# binwrite(string , offset=nil) -> Integer (6201.0) -
IO.binwrite(self.to_s, *args)と同じです。
...IO.binwrite(self.to_s, *args)と同じです。
@see IO.binwrite... -
IO
. binread(path , length = nil , offset = 0) -> String | nil (123.0) -
path で指定したファイルを open し、offset の所まで seek し、 length バイト読み込みます。
...path で指定したファイルを open し、offset の所まで seek し、
length バイト読み込みます。
Kernel.#open と同様 path の先頭が "|" ならば、"|" に続くコマンドの出力を読み取ります。
length を省略するとファイルの末尾まで読み込み......ます。
ファイルを開くときの mode は "rb:ASCII-8BIT" です。
//emlist[例][ruby]{
IO.write("testfile", "This is line one\nThis is line two\nThis is line three\nAnd so on...\n")
IO.binread("testfile") # => "This is line one\nThis is line two\nThis is line three\nAnd so on..... -
IO
. copy _ stream(src , dst , copy _ length , src _ offset) -> Integer (119.0) -
指定された src から dst へコピーします。 コピーしたバイト数を返します。
...ルは作成されます。ファイルが存在する場合は長さ 0 に切り詰められます。
src が IO オブジェクトでかつ src_offset が指定されている場合、
src のオフセット(src.pos)は変更されません。
@param src コピー元となる IO オブジェク......nil を指定した場合、コピーする長さに制限はありません。
@param src_offset コピーを始めるオフセットを数値で指定します。
//emlist[例][ruby]{
IO.write("filetest", "abcdefghij")
IO.copy_stream("filetest", "filecopy", 2) # => 2
IO.read("filecopy... -
IO
# pread(maxlen , offset , outbuf = "") -> string (113.0) -
preadシステムコールを使ってファイルポインタを変更せずに、また現在のファイルポインタに 依存せずにmaxlenバイト読み込みます。
...ユーザー空間のIO層のバッファリングもバイパスします。
@param maxlen 読み込むバイト数を指定します。
@param offset 読み込み開始位置のファイルの先頭からのオフセットを指定します。
@param outbuf データを受け取る String を指......します。
@raise NotImplementedError システムコールがサポートされていない OS で発生します。
//emlist[例][ruby]{
File.write("testfile", "This is line one\nThis is line two\n")
File.open("testfile") do |f|
p f.read # => "This is line one\nThis is line two\n"...