るりまサーチ

最速Rubyリファレンスマニュアル検索!
88件ヒット [1-88件を表示] (0.057秒)
トップページ > クエリ:-[x] > クエリ:dir[x] > クエリ:expand_path[x]

別のキーワード

  1. dir open
  2. dir foreach
  3. dir chdir
  4. dir each_child
  5. rake original_dir

ライブラリ

クラス

検索結果

File.expand_path(path, default_dir = '.') -> String (18360.0)

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

...th が相対パスであれば default_dir を基準にします。

先頭の ~ はホームディレクトリ(環境変数 HOME が使われます)に、
~USER はそのユーザのホームディレクトリに展開されます。

//emlist[例][ruby]{
p Dir.getwd #=> "/home...
...e/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 パスを表す文字列を指定します。

@param default_dir path が相対...
...パスであれば default_dir を基準に展開されます。...

Pathname#expand_path(default_dir = '.') -> Pathname (18348.0)

Pathname.new(File.expand_path(self.to_s, *args)) と同じです。

...w(File.expand_path(self.to_s, *args)) と同じです。

@param default_dir self が相対パスであれば default_dir を基準に展開されます。

//emlist[例][ruby]{
require "pathname"

path = Pathname("testfile")
Pathname.pwd # => #<Pathname:/path/to>
path.expand_path...
...# => #<Pathname:/path/to/testfile>
path.expand_path("../") # => #<Pathname:/path/testfile>
//}

@see File.expand_path...

Dir.home -> String | nil (9142.0)

現在のユーザまたは指定されたユーザのホームディレクトリを返します。

...れたユーザのホームディレクトリを返します。

Dir
.home や Dir.home("root") は
File.expand_path("~") や File.expand_path("~root") と
ほぼ同じです。

//emlist[例][ruby]{
Dir
.home # => "/home/vagrant"
Dir
.home("root") # => "/root"
//}

@see File.expand_path...
...されたユーザのホームディレクトリを返します。

Dir
.home や Dir.home("root") は
File.expand_path("~") や File.expand_path("~root") と
ほぼ同じです。

//emlist[例][ruby]{
Dir
.home # => "/home/vagrant"
Dir
.home("root") # => "/root"
//}

@see File.expand_path...

Dir.home(user) -> String | nil (9142.0)

現在のユーザまたは指定されたユーザのホームディレクトリを返します。

...れたユーザのホームディレクトリを返します。

Dir
.home や Dir.home("root") は
File.expand_path("~") や File.expand_path("~root") と
ほぼ同じです。

//emlist[例][ruby]{
Dir
.home # => "/home/vagrant"
Dir
.home("root") # => "/root"
//}

@see File.expand_path...
...されたユーザのホームディレクトリを返します。

Dir
.home や Dir.home("root") は
File.expand_path("~") や File.expand_path("~root") と
ほぼ同じです。

//emlist[例][ruby]{
Dir
.home # => "/home/vagrant"
Dir
.home("root") # => "/root"
//}

@see File.expand_path...

ruby 1.6 feature (5388.0)

ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。

...グ修正がメイン
になります。

((<stable-snapshot|URL:ftp://ftp.netlab.co.jp/pub/lang/ruby/stable-snapshot.tar.gz>)) は、日々更新される安定版の最新ソースです。

== 1.6.8 (2002-12-24) -> stable-snapshot

: 2003-01-22: errno

EAGAIN と EWOULDBLOCK が同じ値の...
...) ((<ruby-dev:18145>))

: 2002-08-20 File.expand_path

Cygwin 1.3.x ((<ruby-bugs-ja:PR#299>))

p File.expand_path('file', 'c:/')

=> ruby 1.6.7 (2002-03-01) [i586-linux]
/tmp/c:/file
=> ruby 1.6.7 (2002-08-21) [i586-linux]
c:/file

: 2002-08-19 Thread...
...it(nil)
=> -:2:in `split': bad separator (ArgumentError)
from -:2
ruby 1.6.7 (2002-03-01) [i586-linux]

=> ruby 1.6.7 (2002-07-30) [i586-linux]
["a", "b", "c"]

: 2002-06-15 Dir.glob

リンクの切れたシンボリックリンクに対して、Dir.glob がマ...

絞り込み条件を変える

DOSISH 対応 (3264.0)

DOSISH 対応 ruby version 1.7 では、DOSISH対応(DOS/Windows のパス名の扱いに対する変 更)が含まれています。(現在の)変更点を以下に示します。

...ては現在もruby-listなどで議論が継続されています。
現時点では、Fileの各メソッドに対する\対応, マルチバイトパス名対応, UNC 対応が実装されています。13817, 14097

以下、各メソッドの挙動について...

: File.dirname

パスセパ...
...p File.dirname("C:\\foo\\bar")

=> ruby 1.6.4 (2001-06-04) [i586-mswin32]
"."

=> ruby 1.7.1 (2001-08-16) [i586-mswin32]
"C:\\foo"

p File.dirname("C:/foo")
p File.dirname("C:\\foo")
p File.dirname("C:foo")

=> ruby 1.6.4 (2001-06-04) [i586-mswin32]...
...> ruby 1.6.4 (2001-06-04) [i586-mswin32]
"C:\\foo\\bar"

=> ruby 1.7.1 (2001-08-16) [i586-mswin32]
"bar"

: File.split

File.dirname と File.basename が変更されているので、File.split もそれに準じた
結果を返します。

: File.expand_path

ドライブ...

1.6.8から1.8.0への変更点(まとめ) (2616.0)

1.6.8から1.8.0への変更点(まとめ) * ((<1.6.8から1.8.0への変更点(まとめ)/インタプリタの変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたクラス/モジュール>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加されたメソッド>)) * ((<1.6.8から1.8.0への変更点(まとめ)/追加された定数>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張されたクラス/メソッド(互換性のある変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/変更されたクラス/メソッド(互換性のない変更)>)) * ((<1.6.8から1.8.0への変更点(まとめ)/文法の変更>)) * ((<1.6.8から1.8.0への変更点(まとめ)/正規表現>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Marshal>)) * ((<1.6.8から1.8.0への変更点(まとめ)/Windows 対応>)) * ((<1.6.8から1.8.0への変更点(まとめ)/廃止された(される予定の)機能>)) * ((<1.6.8から1.8.0への変更点(まとめ)/ライブラリ>)) * ((<1.6.8から1.8.0への変更点(まとめ)/拡張ライブラリAPI>)) * ((<1.6.8から1.8.0への変更点(まとめ)/バグ修正>)) * ((<1.6.8から1.8.0への変更点(まとめ)/サポートプラットフォームの追加>))

...作はなくなりました)

$defout や $deferr に代入を行うと警告がでます。
(注:1.6 に $deferr はありません)
((<ruby-dev:20961>))

$stdin にオブジェクトを代入すると標準入力からの入力メソッド(gets 等)
はそのオブジェクトにメソ...
...initialize の二つのメソッドでオブジェクトを
生成するようになりました。((<ruby-dev:14847>))
rb_define_alloc_func() も参照。

=== Dir

: ((<Dir#path|Dir/path>)) [new]

追加

=== ENV

: ((<ENV/ENV.clear>)) [new]
: ((<ENV/ENV.shift>)) [new]
: ((<ENV/ENV...
...・・・2002-08-28 その後 "KILL" で指定できるようになっ
たようです)

: win32: map OS error to errno. [change]

: cygwin

cygwinでは常にバイナリモードになりました(((<ruby-dev:19583>)))

: ((<File/File.dirname>)) [CHANGE]
: ((<File/File.expand_path>)) [CHANGE]...

File.absolute_path(file_name, dir_string=nil) -> String (225.0)

file_name を絶対パスに変換した文字列を返します。

...します。
dir
_string を渡した場合はそのディレクトリを基準とします。

File.expand_path と異なり、 file_name 先頭が "~" である場合
それは展開されません。普通のディレクトリ名として処理されます。

//emlist[例][ruby]{
p Dir.getwd...
...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...
...OME"] #=> "/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...