我对以下方法的实用性感到困惑File Class
:
1. File::absolute_path
2. File::realdirpath
3. File::realpath
4. File::expand_path
我在下面尝试了什么:
irb(main):001:0> Dir.pwd
=> "C:/Users/Matt"
irb(main):002:0> Dir.chdir('D:\VB Script\excel_ie_wsh')
=> 0
irb(main):003:0> Dir.pwd
=> "D:/VB Script/excel_ie_wsh"
irb(main):005:0> File.realdirpath('\VB Script\excel_ie_wsh')
=> "/VB Script/excel_ie_wsh"
irb(main):006:0> File.realpath('\VB Script\excel_ie_wsh')
=> "/VB Script/excel_ie_wsh"
irb(main):007:0> File.absolute_path('\VB Script\excel_ie_wsh')
=> "D:/VB Script/excel_ie_wsh"
irb(main):008:0> File.realpath('readme.txt')
=> "D:/VB Script/excel_ie_wsh/readme.txt"
irb(main):009:0> File.realdirpath('readme.txt')
=> "D:/VB Script/excel_ie_wsh/readme.txt"
irb(main):012:0> File.absolute_path('readme.txt')
=> "D:/VB Script/excel_ie_wsh/readme.txt"
irb(main):013:0>
问题:
- 为什么
File.realdirpath
和File.realpath
产生相同的输出? - 有何
File.realpath
不同?File.absolute_path
- 与有何
absolute_path(file_nam)
不同?absolute_path(file_name[, dir_string] )
- 与有何
realdirpath(pathname)
不同?realdirpath(pathname [, dir_string])