るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

File (46036.0)

ファイルアクセスのためのクラスです。

...ためのクラスです。

通常 Kernel.#open または File.open を使って生成します。
IO クラスがインクルードしている File::Constants は File クラスに関係する定数を
格納したモジュールです。
また File::Stat は stat 構造体( stat(2) 参照)を...

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

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

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

path が整数の場合はファイルディスクリプタとして扱い、それに対応する
File
オブジェクトを生成して返します。IO.open と同じです。
ブロックを指定して呼び出した場合は、File...
...Kernel.#open と同じです。

@param perm ファイルを生成する場合のファイルのパーミッションを整数で指定します。Kernel.#open と同じです。

@raise Errno::EXXX ファイルのオープンに失敗した場合に発生します。

//emlist[例: 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 による書き込みモードで...

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

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

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

path が整数の場合はファイルディスクリプタとして扱い、それに対応する
File
オブジェクトを生成して返します。IO.open と同じです。
ブロックを指定して呼び出した場合は、File...
...Kernel.#open と同じです。

@param perm ファイルを生成する場合のファイルのパーミッションを整数で指定します。Kernel.#open と同じです。

@raise Errno::EXXX ファイルのオープンに失敗した場合に発生します。

//emlist[例: 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 による書き込みモードで...

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

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

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

path が整数の場合はファイルディスクリプタとして扱い、それに対応する
File
オブジェクトを生成して返します。IO.open と同じです。
ブロックを指定して呼び出した場合は、File...
...Kernel.#open と同じです。

@param perm ファイルを生成する場合のファイルのパーミッションを整数で指定します。Kernel.#open と同じです。

@raise Errno::EXXX ファイルのオープンに失敗した場合に発生します。

//emlist[例: 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 による書き込みモードで...

File#lstat -> File::Stat (29153.0)

ファイルの状態を含む File::Stat オブジェクトを生成して返します。 シンボリックリンクに関してリンクそのものの情報を返します。 lstat(2) を実装していないシステムでは、IO#statと同じです。

...ファイルの状態を含む File::Stat オブジェクトを生成して返します。
シンボリックリンクに関してリンクそのものの情報を返します。
lstat(2) を実装していないシステムでは、IO#statと同じです。

@raise Errno::EXXX 失敗した場合...
...ose されている場合に発生します。

//emlist[例][ruby]{
# testlink は testfile のシンボリックリンク
File
.open("testlink") do |f|
p f.lstat == File.stat("testfile") # => false
p f.stat == File.stat("testfile") # => true
end
//}

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

絞り込み条件を変える

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

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

...をロックします。

ロックを取得するまでブロックされます。
ロックの取得に成功した場合は 0 を返します。
File
::LOCK_NB (ノンブロッキング) を指定すると、本来ならブロックされる場合に
ブロックされずに false を返すよう...
...eration に有効な定数は以下の通りです。定数は File::Constants で定義されていますが、
File
クラスの親クラスの IO が File::Constants をインクルードしているので、
これらの定数は File::LOCK_SH などとして参照可能です。

: LOCK_SH
...
...ブロックモード。
File
::LOCK_SH | File::LOCK_NB のように他の指定と or することで指
定します。この指定がない場合、ブロックされる条件での flock
の呼び出しはロックが解除されるまでブロックされます。

File
::LOCK_NB の指定が...

File#path -> String (29060.0)

オープン時に使用したパスを文字列で返します。

...or TMPFILE File::Constants::TMPFILEオプション付きで作成されている場合に発生します。

//emlist[例][ruby]{
File
.open("testfile") {|f| f.path } #=> "testfile"
File
.open("/tmp/../tmp/xxx", "w") {|f| f.path } #=> "/tmp/../tmp/xxx"
File
.open("/tmp...
...", File::RDWR | File::TMPFILE){|f| f.path } # IOError: File is unnamed (TMPFILE?)
//}...

File#to_path -> String (29060.0)

オープン時に使用したパスを文字列で返します。

...or TMPFILE File::Constants::TMPFILEオプション付きで作成されている場合に発生します。

//emlist[例][ruby]{
File
.open("testfile") {|f| f.path } #=> "testfile"
File
.open("/tmp/../tmp/xxx", "w") {|f| f.path } #=> "/tmp/../tmp/xxx"
File
.open("/tmp...
...", File::RDWR | File::TMPFILE){|f| f.path } # IOError: File is unnamed (TMPFILE?)
//}...

File#path -> String (29054.0)

オープン時に使用したパスを文字列で返します。

...
File
::Constants::TMPFILEオプション付きで作成されていたりする場合です。

//emlist[例][ruby]{
File
.open("testfile") {|f| f.path } #=> "testfile"
File
.open("/tmp/../tmp/xxx", "w") {|f| f.path } #=> "/tmp/../tmp/xxx"
File
.open("/tmp", File::R...
...DWR | File::TMPFILE){|f| f.path } #=> "/tmp"
//}...

File#to_path -> String (29054.0)

オープン時に使用したパスを文字列で返します。

...
File
::Constants::TMPFILEオプション付きで作成されていたりする場合です。

//emlist[例][ruby]{
File
.open("testfile") {|f| f.path } #=> "testfile"
File
.open("/tmp/../tmp/xxx", "w") {|f| f.path } #=> "/tmp/../tmp/xxx"
File
.open("/tmp", File::R...
...DWR | File::TMPFILE){|f| f.path } #=> "/tmp"
//}...

絞り込み条件を変える

File#atime -> Time (29036.0)

最終アクセス時刻を Time オブジェクトとして返します。

...に発生します。

@raise Errno::EXXX ファイルの時刻の取得に失敗した場合に発生します。

//emlist[例:][ruby]{
IO.write("testfile", "test")
File
.open("testfile") { |f| f.atime } # => 2017-12-21 22:58:17 +0900
//}

@see File#lstat, File#ctime, File#mtime, File#birthtime...

File#ctime -> Time (29036.0)

状態が最後に変更された時刻を Time オブジェクトとして返します。状態の変更とは chmod などによるものです。

...に発生します。

@raise Errno::EXXX ファイルの時刻の取得に失敗した場合に発生します。

//emlist[例:][ruby]{
IO.write("testfile", "test")
File
.open("testfile") { |f| f.ctime } # => 2017-12-21 22:58:17 +0900
//}

@see File#lstat, File#atime, File#mtime, File#birthtime...
<< 1 2 3 ... > >>