I have a list of files for a Ruby script to process. The script always run on an Windows PC. How can the script find the actual name?
Example:
File List -> Actual file on disk
TEST.TXT -> test.txt
TeSt.TxT -> test.txt
After more testing I found that :
puts File.absolute_path("./TEST.RB")
puts Dir["./TEST.RB*"].first
#Path as on disk
puts File.absolute_path("./../Vdd/TEST.RB")
puts Dir["./../Vdd/TEST.RB*"].first
#Path case not as on disk
puts File.absolute_path("./../vdd/TEST.RB")
puts Dir["./../vdd/TEST.RB*"].first
Outputs
C:/Projects/xcms/software-HEAD/build/tools/Vdd/test.rb
./test.rb
C:/Projects/xcms/software-HEAD/build/tools/Vdd/test.rb
./../Vdd/test.rb
C:/Projects/xcms/software-HEAD/build/tools/vdd/test.rb
./../vdd/test.rb
So both realpath
does nothing while absolute_path
and Dir["#{file}*"].first
gets the file name correct but not the path name.
Aucun commentaire:
Enregistrer un commentaire