Bob Showalter wrote: > Justin Johnson wrote: >> Using ruby 1.8.2 on Windows XP, the path separator used for things like >> File.join is always / instead of \. Is there a way to force ruby to use >> the correct path separator? > > "correct" is debatable, since the Windows API accepts / as a separator. > > Anyway, one approach you can use is: > > File.join('foo','bar').gsub(File::SEPARATOR, > File::ALT_SEPARATOR || File::SEPARATOR) > > On Win32 -> foo\bar > On *nix -> foo/bar Is there a reason File::SEPARATOR isn't set to \ to begin with for Windows? Even if the Windows API accepts a /, \ is standard for the Windows command line and executing commands with / in paths passed as args fails. Of course I can just do my own substitutions, but it seems like this could be improved. Thanks. -- Posted via http://www.ruby-forum.com/.