From: Luis Lavena Date: 2011-12-19T21:53:14+09:00 Subject: [ruby-core:41719] Re: Feature : optional argument in File.join On Mon, Dec 19, 2011 at 6:09 AM, Michel Demazure wrote: > In Windows, when using File.join, one often ends with a path containing > a mixture of / (File::SEPARATOR) and \ (File:ALT_SEPARATOR), which some > libraries do not like (eg. gtk2's FileDialog wrongly guesses the > directory). > > I my case, I have to redefine the constant, File::SEPARATOR = '\\', > which raise a warning and may be harmful elsewhere. > > It would be useful for such cases to have an optional argument giving > File.join the wanted separator. > Hello Michel, I think will be better if you normalize the paths that you're using with File.join prior it. Only use the platform-specific version (File::ALT_SEPARATOR) when shelling out or doing something with a library/tool that do not support Unix-like paths. For example, in my scripts, paths that are taken from configuration files or environment variables are expanded (File.expand_path) prior to be used. Then, when I need to perform File.join on them, path normalization is not required as everything is using File::SEPARATOR. Rarely I change from File::SEPARATOR to File::ALT_SEPARATOR (only when generating batch files or altering existing environment variables) Saying all this because File.join already supports multiple arguments (you can splat an array) and adding checks for hash as last argument might not be as good as we think. Regards, -- Luis Lavena AREA 17 - Perfection in design is achieved not when there is nothing more to add, but rather when there is nothing more to take away. Antoine de Saint-Exup�ry