るりまサーチ

最速Rubyリファレンスマニュアル検索!
94件ヒット [1-94件を表示] (0.036秒)
トップページ > クエリ:File[x] > クエリ:IO[x] > クエリ:truncate[x]

別のキーワード

  1. _builtin file?
  2. _builtin file
  3. file truncate
  4. file lstat
  5. file atime

ライブラリ

クラス

検索結果

File.truncate(path, length) -> 0 (39125.0)

path で指定されたファイルのサイズを最大 length バイト にします。

...す文字列を指定します。

@param length 変更したいサイズを整数で与えます。

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

//emlist[例][ruby]{
IO
.write("testfile", "1234567890")
File
.truncate("testfile", 5) # => 0
File
.size("testfile") # => 5
//}...

File#truncate(length) -> 0 (39119.0)

ファイルのサイズを最大 length バイトにします。

...

@raise IOError 自身が書き込み用にオープンされていなければ発生します。

@raise Errno::EXXX サイズの変更に失敗した場合に発生します。

//emlist[例][ruby]{
IO
.write("testfile", "1234567890")
File
.open("testfile", "a") do |f|
f.truncate(5) # => 0
f...

File#flock(operation) -> 0 | false (21232.0)

ファイルをロックします。

...クの取得に成功した場合は 0 を返します。
File
::LOCK_NB (ノンブロッキング) を指定すると、本来ならブロックされる場合に
ブロックされずに false を返すようになります。

@param operation ロックに対する操作の種類を示す定数を...
...@raise IOError 自身が close されている場合に発生します。

@raise Errno::EXXX operation に不正な整数を与えた場合などに発生します。

引数 operation に有効な定数は以下の通りです。定数は File::Constants で定義されていますが、
File
...
...いけません。
File
.open("counter", File::RDWR|File::CREAT, 0644) {|f|
f.flock(File::LOCK_EX)
value = f.read.to_i + 1
f.rewind
f.write("#{value}\n")
f.flush
f.truncate(f.pos)
}

# 読み込みロック(read lock)を使用してカウンタを読み込み。
File
.open("counter", "r")...

CSV.open(filename, mode = "rb", options = Hash.new) -> CSV (462.0)

このメソッドは IO オブジェクトをオープンして CSV でラップします。 これは CSV ファイルを書くための主要なインターフェイスとして使うことを意図しています。

...このメソッドは IO オブジェクトをオープンして CSV でラップします。
これは CSV ファイルを書くための主要なインターフェイスとして使うことを意図しています。

このメソッドは IO.open と同じように動きます。ブロックが...
... IO File に委譲します。

* IO#binmode
* IO#binmode?
* IO#close
* IO#close_read
* IO#close_write
* IO#closed?
* IO#eof
* IO#eof?
* IO#external_encoding
* IO#fcntl
* IO#fileno
* File#flock
* IO#flush
* IO#fsync
* IO#internal_encoding
* IO#ioctl
* IO#isat...
...ty
* File#path
* IO#pid
* IO#pos
* IO#pos=
* IO#reopen
* IO#seek
* IO#stat
* StringIO#string
* IO#sync
* IO#sync=
* IO#tell
* IO#to_i
* IO#to_io
* File#truncate
* IO#tty?

@param filename ファイル名を指定します。

@param mode IO.open に指定できるもの...

CSV.open(filename, mode = "rb", options = Hash.new) {|csv| ... } -> nil (462.0)

このメソッドは IO オブジェクトをオープンして CSV でラップします。 これは CSV ファイルを書くための主要なインターフェイスとして使うことを意図しています。

...このメソッドは IO オブジェクトをオープンして CSV でラップします。
これは CSV ファイルを書くための主要なインターフェイスとして使うことを意図しています。

このメソッドは IO.open と同じように動きます。ブロックが...
... IO File に委譲します。

* IO#binmode
* IO#binmode?
* IO#close
* IO#close_read
* IO#close_write
* IO#closed?
* IO#eof
* IO#eof?
* IO#external_encoding
* IO#fcntl
* IO#fileno
* File#flock
* IO#flush
* IO#fsync
* IO#internal_encoding
* IO#ioctl
* IO#isat...
...ty
* File#path
* IO#pid
* IO#pos
* IO#pos=
* IO#reopen
* IO#seek
* IO#stat
* StringIO#string
* IO#sync
* IO#sync=
* IO#tell
* IO#to_i
* IO#to_io
* File#truncate
* IO#tty?

@param filename ファイル名を指定します。

@param mode IO.open に指定できるもの...

絞り込み条件を変える

CSV.open(filename, options = Hash.new) -> CSV (462.0)

このメソッドは IO オブジェクトをオープンして CSV でラップします。 これは CSV ファイルを書くための主要なインターフェイスとして使うことを意図しています。

...このメソッドは IO オブジェクトをオープンして CSV でラップします。
これは CSV ファイルを書くための主要なインターフェイスとして使うことを意図しています。

このメソッドは IO.open と同じように動きます。ブロックが...
... IO File に委譲します。

* IO#binmode
* IO#binmode?
* IO#close
* IO#close_read
* IO#close_write
* IO#closed?
* IO#eof
* IO#eof?
* IO#external_encoding
* IO#fcntl
* IO#fileno
* File#flock
* IO#flush
* IO#fsync
* IO#internal_encoding
* IO#ioctl
* IO#isat...
...ty
* File#path
* IO#pid
* IO#pos
* IO#pos=
* IO#reopen
* IO#seek
* IO#stat
* StringIO#string
* IO#sync
* IO#sync=
* IO#tell
* IO#to_i
* IO#to_io
* File#truncate
* IO#tty?

@param filename ファイル名を指定します。

@param mode IO.open に指定できるもの...

CSV.open(filename, options = Hash.new) {|csv| ... } -> nil (462.0)

このメソッドは IO オブジェクトをオープンして CSV でラップします。 これは CSV ファイルを書くための主要なインターフェイスとして使うことを意図しています。

...このメソッドは IO オブジェクトをオープンして CSV でラップします。
これは CSV ファイルを書くための主要なインターフェイスとして使うことを意図しています。

このメソッドは IO.open と同じように動きます。ブロックが...
... IO File に委譲します。

* IO#binmode
* IO#binmode?
* IO#close
* IO#close_read
* IO#close_write
* IO#closed?
* IO#eof
* IO#eof?
* IO#external_encoding
* IO#fcntl
* IO#fileno
* File#flock
* IO#flush
* IO#fsync
* IO#internal_encoding
* IO#ioctl
* IO#isat...
...ty
* File#path
* IO#pid
* IO#pos
* IO#pos=
* IO#reopen
* IO#seek
* IO#stat
* StringIO#string
* IO#sync
* IO#sync=
* IO#tell
* IO#to_i
* IO#to_io
* File#truncate
* IO#tty?

@param filename ファイル名を指定します。

@param mode IO.open に指定できるもの...

NEWS for Ruby 2.5.0 (252.0)

NEWS for Ruby 2.5.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...非推奨になりました。C拡張のベースクラスでしたが、Rubyレベルに公開するのをやめました。3072

* Exception
* Exception#full_message を追加 14141 [実験的]
例外の文字列表現を取得します。その文字列は捕捉されない例外をRu...
...ました 11286

* File
* File.open :newline オプションを指定するとテキストモードになります 13350
* File#path はFile::Constants::TMPFILE付きで開いたファイルに対して IOError を発生させます
13568
* File.stat, File.exist? など rb_stat()...
...* File::Stat#ino, File.identical?
Windows 8.1 以降で、ReFSの128bitのinoをサポートしました 13731
* File.readable?, File.readable_real?, File.writable?, File.writable_real?,
File
.executable?, File.executable_real?, File.mkfifo, File.readlink,
File
.truncate, File#t...

セキュリティモデル (108.0)

セキュリティモデル RubyにはCGI等のプログラミングを安全に行うことを助ける為に、セキュリティ 機構が備わっています。

...はレベル2でも行えません。

==== レベル 0

デフォルトのセーフレベルです。

===== 汚染されるオブジェクト

* IOや環境変数、コマンドライン引数(ARGV)から得られた文字列

$ ruby -e 'p ARGV[0].tainted?' hoge
true

環境変数...
...汚染された文字列を引数とした以下の操作

* Dir, IO, File, FileTest のメソッド呼び出し
//emlist{
$ ruby -e '$SAFE = 1; open(ARGV[0])' hoge
-e:1:in `initialize': Insecure operation - initialize (SecurityError)
from -e:1
//}
*...
...* File.chown File.chmod File.umask File.truncate
File
#lstat File#chmod File#chown File.delete File.unlink
File
#truncate File#flock
および FileTest モジュールのメソッド
* IO#ioctl, IO#fcntl
* Process.fork Process.#setpgid Process.#setsid
Process.#setpriority...

NEWS for Ruby 2.4.0 (60.0)

NEWS for Ruby 2.4.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...while を追加 https://github.com/ruby/ruby/pull/1186
* Enumerator::Lazy#uniq を追加 11090

* File
* File.empty? を追加 9969

* Float
* Float#ceil, Float#floor, Float#truncate
Float#roundと同じように省略可能な桁を指定する引数を受け付けるよ...
...alues! を追加 12512

* Integer
* Fixnum と Bignum は Integer に統合されました 12005
* Integer#ceil, Integer#floor, Integer#truncate
Integer#round と同じように省略可能な桁を指定する引数を受け付けるようになりました 12245
* Integer#d...
...けるようになりました。
half には :even, :up, :down が指定可能です。 12548 12958 12953

* IO
* IO#gets, IO#readline, IO#each_line, IO#readlines, IO.foreach は
chomp というキーワード引数を受け付けるようになりました。12553

* Kernel...

絞り込み条件を変える