るりまサーチ (Ruby 2.6.0)

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

別のキーワード

  1. _builtin path
  2. pathname to_path
  3. _builtin absolute_path
  4. _builtin to_path
  5. csv path

検索結果

File.path(filename) -> String (54535.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 (54364.0)

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

...Error 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.expand_path(path, default_dir = '.') -> String (18814.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.realdirpath(pathname, basedir = nil) -> String (18604.0)

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

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

pathname の最後のコンポーネントは存在していなくても例外は発生しません。

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

@param basedir ベースディレクトリを指定します。省略するとカレントディレクトリを使用します。

@raise Errno::ENOENT ファイルが存在しない場合に発生します。

File.realpath(pathname, basedir = nil) -> String (18604.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.absolute_path(file_name, dir_string=nil) -> String (18415.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#to_path -> String (18364.0)

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

...Error 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_SEPARATOR -> ";" | ":" (18355.0)

PATH 環境変数の要素のセパレータです。UNIX では ":" MS-DOS な どでは ";" です。

PATH 環境変数の要素のセパレータです。UNIX では ":" MS-DOS な
どでは ";" です。

File.new(path, mode = "r", perm = 0666) -> File (397.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 (397.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 (397.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.fnmatch(pattern, path, flags = 0) -> bool (376.0)

ファイル名のパターンマッチ fnmatch(3) を行います。 path が pattern にマッチすれば真を返します。そうでない場合には false を返します。

...用できます。
Dir.glob とは違って `**/' は使用できません。
//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 (376.0)

ファイル名のパターンマッチ fnmatch(3) を行います。 path が pattern にマッチすれば真を返します。そうでない場合には false を返します。

...用できます。
Dir.glob とは違って `**/' は使用できません。
//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.truncate(path, length) -> 0 (373.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 (373.0)

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

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

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

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

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

絞り込み条件を変える

File.world_writable?(path) -> bool (373.0)

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

...でない場合は nil を返します。

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

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

//emlist[例][ruby]{
m = File.world_writable?("/tmp")
"%o" % m #=> "777"
//}...

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

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

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

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

File.empty?(path) -> bool (328.0)

FileTest.#zero? と同じです。

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

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

File.zero?(path) -> bool (328.0)

FileTest.#zero? と同じです。

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

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

File.blockdev?(path) -> bool (325.0)

FileTest.#blockdev? と同じです。

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

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


@see FileTest.#blockdev?...

絞り込み条件を変える

File.chardev?(path) -> bool (325.0)

FileTest.#chardev? と同じです。

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

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

File.directory?(path) -> bool (325.0)

FileTest.#directory? と同じです。

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

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

File.executable?(path) -> bool (325.0)

FileTest.#executable? と同じです。

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

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

File.executable_real?(path) -> bool (325.0)

FileTest.#executable_real? と同じです。

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

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

File.exist?(path) -> bool (325.0)

FileTest.#exist? と同じです。

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

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

絞り込み条件を変える

File.file?(path) -> bool (325.0)

FileTest.#file? と同じです。

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

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

File.grpowned?(path) -> bool (325.0)

FileTest.#grpowned? と同じです。

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

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

File.owned?(path) -> bool (325.0)

FileTest.#owned? と同じです。

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

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

File.pipe?(path) -> bool (325.0)

FileTest.#pipe? と同じです。

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

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

File.readable?(path) -> bool (325.0)

FileTest.#readable? と同じです。

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

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

絞り込み条件を変える

File.readable_real?(path) -> bool (325.0)

FileTest.#readable_real? と同じです。

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

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

File.setgid?(path) -> bool (325.0)

FileTest.#setgid? と同じです。

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

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

File.setuid?(path) -> bool (325.0)

FileTest.#setuid? と同じです。

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

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

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

FileTest.#size と同じです。

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

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

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

FileTest.#size? と同じです。

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

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

絞り込み条件を変える

File.socket?(path) -> bool (325.0)

FileTest.#socket? と同じです。

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

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

File.sticky?(path) -> bool (325.0)

FileTest.#sticky? と同じです。

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

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

File.symlink?(path) -> bool (325.0)

FileTest.#symlink? と同じです。

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

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

File.writable?(path) -> bool (325.0)

FileTest.#writable? と同じです。

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

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

File.writable_real?(path) -> bool (325.0)

FileTest.#writable_real? と同じです。

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

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

絞り込み条件を変える

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

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

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

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

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

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

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

と同じです。

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

File.join(*item) -> String (22.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"...