種類
- 特異メソッド (39)
- インスタンスメソッド (2)
- 定数 (1)
ライブラリ
- ビルトイン (42)
キーワード
-
PATH
_ SEPARATOR (1) -
absolute
_ path (1) - blockdev? (1)
- chardev? (1)
- directory? (1)
- executable? (1)
-
executable
_ real? (1) - exist? (1)
- exists? (1)
- file? (1)
- fnmatch (1)
- fnmatch? (1)
- grpowned? (1)
- join (1)
- new (1)
- open (2)
- owned? (1)
- path (2)
- pipe? (1)
- readable? (1)
-
readable
_ real? (1) - readlink (1)
- realdirpath (1)
- realpath (1)
- setgid? (1)
- setuid? (1)
- size (1)
- size? (1)
- socket? (1)
- split (1)
- sticky? (1)
- symlink? (1)
-
to
_ path (1) - truncate (1)
-
world
_ readable? (1) -
world
_ writable? (1) - writable? (1)
-
writable
_ real? (1) - zero? (1)
検索結果
先頭5件
-
File
. path(filename) -> String (117907.0) -
指定されたファイル名を文字列で返します。filename が文字列でない場合は、to_path メソッドを呼びます。
...指定されたファイル名を文字列で返します。filename が文字列でない場合は、to_path メソッドを呼びます。
@param filename ファイル名を表す文字列か to_path メソッドが定義されたオブジェクトを指定します。
//emlist[例][ruby]{
requ......ire 'pathname'
class MyPath
def initialize(path)
@path = path
end
def to_path
File.absolute_path(@path)
end
end
File.path("/dev/null") # => "/dev/null"
File.path(Pathname("/tmp")) # => "/tmp"
File.path(MyPath.new(".")) # => "/Users/user/projects/txt"
//}... -
File
# path -> String (117472.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
. absolute _ path(file _ name , dir _ string=nil) -> String (81892.0) -
file_name を絶対パスに変換した文字列を返します。
...
file_name を絶対パスに変換した文字列を返します。
相対パスの場合はカレントディレクトリを基準とします。
dir_string を渡した場合はそのディレクトリを基準とします。
File.expand_path と異なり、 file_name 先頭が "~" である場......ME"] #=> "/home/matz"
p File.absolute_path("..") #=> "/home/matz/work"
p File.absolute_path("..", "/tmp") #=> "/"
p File.absolute_path("~") #=> "/home/matz/work/bar/~"
p File.absolute_path("~foo") #=> "/home/matz/work/bar/~foo"
//}
@see File.expand_path... -
File
. expand _ path(path , default _ dir = & # 39; . & # 39;) -> String (81886.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
. file?(path) -> bool (81676.0) -
FileTest.#file? と同じです。
...
FileTest.#file? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。... -
File
. realpath(pathname , basedir = nil) -> String (81676.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
. realdirpath(pathname , basedir = nil) -> String (81604.0) -
与えられた pathname に対応する絶対パスを返します。
与えられた pathname に対応する絶対パスを返します。
pathname の最後のコンポーネントは存在していなくても例外は発生しません。
@param pathname ファイル名を指定します。
@param basedir ベースディレクトリを指定します。省略するとカレントディレクトリを使用します。
@raise Errno::ENOENT ファイルが存在しない場合に発生します。 -
File
# to _ path -> String (81472.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
:: PATH _ SEPARATOR -> ";" | ":" (81355.0) -
PATH 環境変数の要素のセパレータです。UNIX では ":" MS-DOS な どでは ";" です。
PATH 環境変数の要素のセパレータです。UNIX では ":" MS-DOS な
どでは ";" です。 -
File
. fnmatch(pattern , path , flags = 0) -> bool (63988.0) -
ファイル名のパターンマッチ fnmatch(3) を行います。 path が pattern にマッチすれば真を返します。そうでない場合には false を返します。
...イルドカードとして `*',
`**`, `?', `[]', `{}' が使用できます。
//emlist[例][ruby]{
%w(foo foobar bar).each {|f|
p File.fnmatch("foo*", f)
}
# => true
# true
# false
//}
@param path パスを表す文字列を指定します。
@param flags パターンマ......る定数は以下のとおりです。
これらの定数は File::Constants で定義されていますが、
File クラスの親クラスの IO が File::Constants をインクルードしているので、
これらの定数は File::FNM_NOESCAPE などとして参照可能です。
: FNM_NOES......ます。
//emlist[][ruby]{
p File.fnmatch('\a', 'a') # => true
p File.fnmatch('\a', '\a', File::FNM_NOESCAPE) # => true
//}
前者で * は、エスケープされているので "*" そのものにマッチ
します。
//emlist[][ruby]{
p File.fnmatch('\*', 'a')... -
File
. fnmatch?(pattern , path , flags = 0) -> bool (63988.0) -
ファイル名のパターンマッチ fnmatch(3) を行います。 path が pattern にマッチすれば真を返します。そうでない場合には false を返します。
...イルドカードとして `*',
`**`, `?', `[]', `{}' が使用できます。
//emlist[例][ruby]{
%w(foo foobar bar).each {|f|
p File.fnmatch("foo*", f)
}
# => true
# true
# false
//}
@param path パスを表す文字列を指定します。
@param flags パターンマ......る定数は以下のとおりです。
これらの定数は File::Constants で定義されていますが、
File クラスの親クラスの IO が File::Constants をインクルードしているので、
これらの定数は File::FNM_NOESCAPE などとして参照可能です。
: FNM_NOES......ます。
//emlist[][ruby]{
p File.fnmatch('\a', 'a') # => true
p File.fnmatch('\a', '\a', File::FNM_NOESCAPE) # => true
//}
前者で * は、エスケープされているので "*" そのものにマッチ
します。
//emlist[][ruby]{
p File.fnmatch('\*', 'a')... -
File
. new(path , mode = "r" , perm = 0666) -> File (63952.0) -
path で指定されるファイルをオープンし、File オブジェクトを生成して 返します。
...、File オブジェクトを生成して
返します。
path が整数の場合はファイルディスクリプタとして扱い、それに対応する
File オブジェクトを生成して返します。IO.open と同じです。
ブロックを指定して呼び出した場合は、File オ......mlist[例: 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 による書き込みモードでのファイルオープン][ruby]{
File.open("testfile", "w", 0755) { |f| f.print "test" }
File.read("testfile") # => "test"
//}... -
File
. open(path , mode = "r" , perm = 0666) -> File (63952.0) -
path で指定されるファイルをオープンし、File オブジェクトを生成して 返します。
...、File オブジェクトを生成して
返します。
path が整数の場合はファイルディスクリプタとして扱い、それに対応する
File オブジェクトを生成して返します。IO.open と同じです。
ブロックを指定して呼び出した場合は、File オ......mlist[例: 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 による書き込みモードでのファイルオープン][ruby]{
File.open("testfile", "w", 0755) { |f| f.print "test" }
File.read("testfile") # => "test"
//}... -
File
. open(path , mode = "r" , perm = 0666) {|file| . . . } -> object (63952.0) -
path で指定されるファイルをオープンし、File オブジェクトを生成して 返します。
...、File オブジェクトを生成して
返します。
path が整数の場合はファイルディスクリプタとして扱い、それに対応する
File オブジェクトを生成して返します。IO.open と同じです。
ブロックを指定して呼び出した場合は、File オ......mlist[例: 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 による書き込みモードでのファイルオープン][ruby]{
File.open("testfile", "w", 0755) { |f| f.print "test" }
File.read("testfile") # => "test"
//}... -
File
. truncate(path , length) -> 0 (63409.0) -
path で指定されたファイルのサイズを最大 length バイト にします。
...す文字列を指定します。
@param length 変更したいサイズを整数で与えます。
@raise Errno::EXXX 失敗した場合に発生します。
//emlist[例][ruby]{
IO.write("testfile", "1234567890")
File.truncate("testfile", 5) # => 0
File.size("testfile") # => 5
//}... -
File
. world _ readable?(path) -> Integer | nil (63391.0) -
path が全てのユーザから読めるならばそのファイルのパーミッションを表す 整数を返します。そうでない場合は nil を返します。
...場合は nil を返します。
整数の意味はプラットフォームに依存します。
@param path パスを表す文字列か IO オブジェクトを指定します。
//emlist[例][ruby]{
m = File.world_readable?("/etc/passwd")
"%o" % m # => "644"
//}... -
File
. world _ writable?(path) -> bool (63391.0) -
path が全てのユーザから書き込めるならば、そのファイルのパーミッションを表す 整数を返します。そうでない場合は nil を返します。
...ない場合は nil を返します。
整数の意味はプラットフォームに依存します。
@param path パスを表す文字列か IO オブジェクトを指定します。
//emlist[例][ruby]{
m = File.world_writable?("/tmp")
"%o" % m #=> "777"
//}... -
File
. readlink(path) -> String (63379.0) -
シンボリックリンクのリンク先のパスを文字列で返します。
...XX 指定された path がシンボリックリンクでない場合や、リンクの読み取りに失敗した場合に発生します。
//emlist[例:][ruby]{
IO.write("testfile", "test")
File.symlink("testfile", "testlink") # => 0
File.readlink("testlink") # => "testfile"
//}... -
File
. exists?(path) -> bool (63355.0) -
このメソッドは Ruby 2.1 から deprecated です。File.exist? を使用してください。
...このメソッドは Ruby 2.1 から deprecated です。File.exist? を使用してください。... -
File
. split(pathname) -> [String] (63340.0) -
pathname を dirname とbasename に分割して、2 要 素の配列を返します。
...pathname を dirname とbasename に分割して、2 要
素の配列を返します。
//emlist[][ruby]{
[File.dirname(pathname), File.basename(pathname)]
//}
と同じです。
@param pathname パス名を表す文字列を指定します。... -
File
. blockdev?(path) -> bool (63325.0) -
FileTest.#blockdev? と同じです。
...
FileTest.#blockdev? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。
@see FileTest.#blockdev?... -
File
. chardev?(path) -> bool (63325.0) -
FileTest.#chardev? と同じです。
...
FileTest.#chardev? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。... -
File
. directory?(path) -> bool (63325.0) -
FileTest.#directory? と同じです。
...
FileTest.#directory? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。... -
File
. executable?(path) -> bool (63325.0) -
FileTest.#executable? と同じです。
...
FileTest.#executable? と同じです。
@param path パスを表す文字列を指定します。... -
File
. executable _ real?(path) -> bool (63325.0) -
FileTest.#executable_real? と同じです。
...
FileTest.#executable_real? と同じです。
@param path パスを表す文字列を指定します。... -
File
. exist?(path) -> bool (63325.0) -
FileTest.#exist? と同じです。
...
FileTest.#exist? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。... -
File
. grpowned?(path) -> bool (63325.0) -
FileTest.#grpowned? と同じです。
...
FileTest.#grpowned? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。... -
File
. owned?(path) -> bool (63325.0) -
FileTest.#owned? と同じです。
...
FileTest.#owned? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。... -
File
. pipe?(path) -> bool (63325.0) -
FileTest.#pipe? と同じです。
...
FileTest.#pipe? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。... -
File
. readable?(path) -> bool (63325.0) -
FileTest.#readable? と同じです。
...
FileTest.#readable? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。... -
File
. readable _ real?(path) -> bool (63325.0) -
FileTest.#readable_real? と同じです。
...
FileTest.#readable_real? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。... -
File
. setgid?(path) -> bool (63325.0) -
FileTest.#setgid? と同じです。
...
FileTest.#setgid? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。... -
File
. setuid?(path) -> bool (63325.0) -
FileTest.#setuid? と同じです。
...
FileTest.#setuid? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。... -
File
. size(path) -> Integer (63325.0) -
FileTest.#size と同じです。
...
FileTest.#size と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。... -
File
. size?(path) -> Integer | nil (63325.0) -
FileTest.#size? と同じです。
...
FileTest.#size? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。... -
File
. socket?(path) -> bool (63325.0) -
FileTest.#socket? と同じです。
...
FileTest.#socket? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。... -
File
. sticky?(path) -> bool (63325.0) -
FileTest.#sticky? と同じです。
...
FileTest.#sticky? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。... -
File
. symlink?(path) -> bool (63325.0) -
FileTest.#symlink? と同じです。
...
FileTest.#symlink? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。... -
File
. writable?(path) -> bool (63325.0) -
FileTest.#writable? と同じです。
...
FileTest.#writable? と同じです。
@param path パスを表す文字列を指定します。... -
File
. writable _ real?(path) -> bool (63325.0) -
FileTest.#writable_real? と同じです。
...
FileTest.#writable_real? と同じです。
@param path パスを表す文字列を指定します。... -
File
. zero?(path) -> bool (63325.0) -
FileTest.#zero? と同じです。
...
FileTest.#zero? と同じです。
@param path パスを表す文字列か IO オブジェクトを指定します。... -
File
. join(*item) -> String (63250.0) -
File::SEPARATORを間に入れて文字列を連結します。platform/DOSISH-supportで環境依存になる予定です。
...
File::SEPARATORを間に入れて文字列を連結します。platform/DOSISH-supportで環境依存になる予定です。
@param item 連結したいディレクトリ名やファイル名を文字列(もしくは文字列を要素に持つ配列)で与えます。
文字列A......とBを連結する際に、Aの末尾の文字とBの先頭の文字がFile::SEPARATORであった場合には、
まずこれらを削除した上で改めてFile::SEPARATORを間に入れて連結します。
引数の中に配列がある場合は配列要素を再帰的......t[例][ruby]{
File.join("a","b") # => "a/b"
File.join("a/","b") # => "a/b"
File.join("a/","/b") # => "a/b"
File.join("a","/b") # => "a/b"
File.join("a", ["b", ["c", ["d"]]]) # => "a/b/c/d"
File.join("", "a"...