るりまサーチ (Ruby 2.1.0)

最速Rubyリファレンスマニュアル検索!
13件ヒット [1-13件を表示] (0.043秒)
トップページ > バージョン:2.1.0[x] > クエリ:Integer[x] > クラス:File[x]

別のキーワード

  1. openssl integer
  2. asn1 integer
  3. _builtin integer
  4. integer chr
  5. integer new

ライブラリ

キーワード

検索結果

File.delete(*filename) -> Integer (310.0)

ファイルを削除します。削除したファイルの数を返します。 削除に失敗した場合は例外 Errno::EXXX が発生します。

...m filename ファイル名を表す文字列を指定します。

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

//emlist[例][ruby]{
IO.write("test.txt", "test")
p File.exist?("test.txt") # => true
p File.delete("test.txt") # => 1
p File.exist?("test.txt") # => false
begin
File
....
...delete("test.txt")
rescue
p $! # => #<Errno::ENOENT: No such file or directory @ unlink_internal - test.txt>
end
//}...

File.umask -> Integer (310.0)

現在の umask の値を返します。

現在の umask の値を返します。

@see umask(2)

File.umask(umask) -> Integer (310.0)

umask を変更します。変更前の umask の値を返します。

...umask を変更します。変更前の umask の値を返します。

@param umask 設定したい umask の値を整数で指定します。

//emlist[例][ruby]{
File
.umask(0006) # => 18
File
.umask # => 6
//}

@see umask(2)...

File.unlink(*filename) -> Integer (310.0)

ファイルを削除します。削除したファイルの数を返します。 削除に失敗した場合は例外 Errno::EXXX が発生します。

...m filename ファイル名を表す文字列を指定します。

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

//emlist[例][ruby]{
IO.write("test.txt", "test")
p File.exist?("test.txt") # => true
p File.delete("test.txt") # => 1
p File.exist?("test.txt") # => false
begin
File
....
...delete("test.txt")
rescue
p $! # => #<Errno::ENOENT: No such file or directory @ unlink_internal - test.txt>
end
//}...

File#size -> Integer (307.0)

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

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

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

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

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

@see File#lstat...

絞り込み条件を変える

File.chmod(mode, *filename) -> Integer (307.0)

ファイルのモードを mode に変更します。モードを変更したファイ ルの数を返します。

...ファイルのモードを mode に変更します。モードを変更したファイ
ルの数を返します。

@param filename ファイル名を表す文字列を指定します。

@param mode chmod(2) と同様に整数で指定します。

@raise Errno::EXXX モードの変更に失敗...

File.chown(owner, group, *filename) -> Integer (307.0)

ファイルのオーナーとグループを変更します。スーパーユーザだけがファ イルのオーナーとグループを変更できます。変更を行ったファイルの数を 返します。

...ユーザだけがファ
イルのオーナーとグループを変更できます。変更を行ったファイルの数を
返します。

@param filename ファイル名を表す文字列を指定します。

@param owner chown(2) と同様に数値で指定します。nil または -1 を指...
...を指定することで、グループを現在のままにすることができます。

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

//emlist[例][ruby]{
IO.write("test.txt", "test")
File
.chown(502, 12, "test.txt")
File
.stat("test.txt").uid # => 502
//}

@see File#chown...

File.lchmod(mode, *filename) -> Integer (307.0)

File.chmod と同様ですが、シンボリックリンクに関してリンクそのものの モードを変更します。

...
File
.chmod と同様ですが、シンボリックリンクに関してリンクそのものの
モードを変更します。

@param filename ファイル名を表す文字列を指定します。

@param mode chmod(2) と同様に整数で指定します。

@raise NotImplementedError lchmod(2)...
...生します。

//emlist[例][ruby]{
IO.write("testfile", "test")
File
.symlink("testfile", "testlink")
File
.lstat("testlink").ftype # => "link"
File
.lchmod(0744, "testlink")
File
.stat("testlink").mode.to_s(8) # => "100644"
File
.lstat("testlink").mode.to_s(8) # => "120744"
//}...

File.lchown(owner, group, *filename) -> Integer (307.0)

File#chown と同様ですが、 シンボリックリンクに関してリンクそのもののオーナー、 グループを変更します。

...
File
#chown と同様ですが、
シンボリックリンクに関してリンクそのもののオーナー、
グループを変更します。

@param filename ファイル名を表す文字列を指定します。

@param owner chown(2) と同様に数値で指定します。nil または -1...
...発生します。

//emlist[例][ruby]{
IO.write("testfile", "test")
File
.symlink("testfile", "testlink")
File
.chown(501, -1, "testfile")
File
.lstat("testlink").ftype # => "link"
File
.lchown(0, -1, "testlink")
File
.stat("testlink").uid # => 501
File
.lstat("testlink").uid # => 0
//}...

File.size(path) -> Integer (307.0)

FileTest.#size と同じです。

...
File
Test.#size と同じです。

@param path パスを表す文字列か IO オブジェクトを指定します。...

絞り込み条件を変える

File.size?(path) -> Integer | nil (307.0)

FileTest.#size? と同じです。

...
File
Test.#size? と同じです。

@param path パスを表す文字列か IO オブジェクトを指定します。...

File.utime(atime, mtime, *filename) -> Integer (307.0)

ファイルの最終アクセス時刻と更新時刻を変更します。

...秒数を数値で指定します。

@param mtime 更新時刻を Time か、起算時からの経過秒数を数値で指定します。

@param filename ファイル名を表す文字列を指定します。複数指定できます。

@return 変更したファイルの数を返します。

@ra...
...5, 6)
File
.utime(atime, mtime, "testfile") # => 1
File
.atime("testfile") # => 2018-01-02 03:04:05 +0900
File
.mtime("testfile") # => 2018-02-03 04:05:06 +0900
//}

//emlist[例: 経過秒数で指定][ruby]{
File
.utime(1, 2, "testfile") # => 1
File
.atime("testfile")...
...# => 1970-01-01 09:00:01 +0900
File
.mtime("testfile") # => 1970-01-01 09:00:02 +0900
//}...

File.world_readable?(path) -> Integer | nil (307.0)

path が全てのユーザから読めるならばそのファイルのパーミッションを表す 整数を返します。そうでない場合は nil を返します。

...場合は nil を返します。

整数の意味はプラットフォームに依存します。

@param path パスを表す文字列か IO オブジェクトを指定します。

//emlist[例][ruby]{
m = File.world_readable?("/etc/passwd")
"%o" % m # => "644"
//}...