るりまサーチ

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

別のキーワード

  1. _builtin file?
  2. _builtin file
  3. file open
  4. base file
  5. file size

ライブラリ

キーワード

検索結果

<< < ... 3 4 5 6 7 ... > >>

File#mtime -> Time (21031.0)

最終更新時刻を Time オブジェクトとして返します。

...に発生します。

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

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

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

File#atime -> Time (21025.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#chown(owner, group) -> 0 (21025.0)

ファイルのオーナーとグループを変更します。

...ます。

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

//emlist[例][ruby]{
File
.open("testfile") { |f| f.chown(502, 1000) } # => 0
File
.stat("testfile").uid # => 502
File
.stat("testfile").gid # => 1000
//}

@see File.chown...

File#ctime -> Time (21025.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#mtime -> Time (21025.0)

最終更新時刻を Time オブジェクトとして返します。

...ている場合に発生します。

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

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

@see File#lstat, File#atime, File#ctime...

絞り込み条件を変える

File.expand_path(path, default_dir = &#39;.&#39;) -> String (21025.0)

path を絶対パスに展開した文字列を返します。 path が相対パスであれば default_dir を基準にします。

...> "/home/matz/work/foo"
p ENV["HOME"] #=> "/home/matz"
p File.expand_path("..") #=> "/home/matz/work"
p File.expand_path("..", "/tmp") #=> "/"
p File.expand_path("~") #=> "/home/matz"
p File.expand_path("~foo") #=> "/home/foo"
//}

@param path パスを表...

File.realpath(pathname, basedir = nil) -> String (21025.0)

与えられた pathname に対応する絶対パスを返します。

...合に発生します。

//emlist[例][ruby]{
ENV["HOME"] # => "/home/matz"
File
.symlink("testfile", "testlink")
File
.realpath("testfile") # => "/home/matz/testfile"
File
.realpath("testlink") # => "/home/matz/testfile"
File
.realpath("..", "/tmp") # => "/"
//}...

File.rename(from, to) -> 0 (21025.0)

ファイルの名前を変更します。ディレクトリが異なる場合には移動も行い ます。rename(2) を参照してください。移動先のファ イルが存在する時には上書きされます。

...{
begin
File
.rename("testfile", "testfile.bak") # => 0
File
.rename("testfile", "testfile.bak")
rescue
# 2回目の rename 時にすでに testfile が存在しないため例外が発生する
$! # => #<Errno::ENOENT: No such file or directory @ rb_file_s_rename - (testfile, testfile.bak)>...

File.exists?(path) -> bool (21017.0)

このメソッドは Ruby 2.1 から deprecated です。File.exist? を使用してください。

...このメソッドは Ruby 2.1 から deprecated です。File.exist? を使用してください。...

File#size -> Integer (21013.0)

ファイルのサイズを返します。

...ファイルのサイズを返します。

//emlist[例][ruby]{
File
.open("/dev/null") do |f|
f.size #=> 0
end
//}

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

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

@see File#lstat...

絞り込み条件を変える

File.readlink(path) -> String (21013.0)

シンボリックリンクのリンク先のパスを文字列で返します。

...XX 指定された path がシンボリックリンクでない場合や、リンクの読み取りに失敗した場合に発生します。

//emlist[例:][ruby]{
IO.write("testfile", "test")
File
.symlink("testfile", "testlink") # => 0
File
.readlink("testlink") # => "testfile"
//}...

File.split(pathname) -> [String] (21013.0)

pathname を dirname とbasename に分割して、2 要 素の配列を返します。

...pathname を dirname とbasename に分割して、2 要
素の配列を返します。

//emlist[][ruby]{
[File.dirname(pathname), File.basename(pathname)]
//}

と同じです。

@param pathname パス名を表す文字列を指定します。...

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

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

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

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

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

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