Answer the question
In order to leave comments, you need to log in
How to work with windows from under nix to ruby?
I'm actually a bit in a stupor.
From under nix (ubuntu) the script works with different paths, the paths can be both nix and windows.
No problems with nicks
nix_path = Pathname.new '/nix/path/ok/file.txt'
nix_path.basename # => <Pathname:file.txt>
nix_path.parent # => <Pathname:/nix/path/ok>
win_path = Pathname.new 'C:\win\path\file.txt'
win_path.basename # => <Pathname:C:\win\path\file.txt>
win_path.parent # => <Pathname:.>
File.basename 'C:\win\path\file.txt' # => "C:\\win\\path\\file.txt"
Answer the question
In order to leave comments, you need to log in
win_path = Pathname.new 'C:\win\path\file.txt'.tr('\\', '/')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question