Skip to content
Prev 58188 / 63424 Next

Inconsistant result for normalizePath on Windows

Hi Jiefei,

the change in handling trailing path separators is not on purpose, but 
is a byproduct of a new implementation of normalizePath, which now 
handles symbolic links and normalizes case in long path names. It is not 
documented what happens to trailing separators, and hence portable 
programs should not depend on it. I don't think it is a property that 
should be documented/specified. The behavior of normalizePath is way too 
complicated already and it's result is OS-specific anyway.

In R-devel as well as in 3.6, the trailing separator is preserved when 
the path does not exist - simply, the original path is returned. When 
the path does exist, R-devel removes the trailing separator but R 3.6 
does not, which is because the underlying Windows API call to implement 
it is now different. The new behavior reflects what 
GetFinalPathNameByHandle returns, which is a function now used for 
normalization also in other language runtimes on Windows. I think the 
new behavior is better: paths differing only in the trailing separator 
will be normalized to the same path.

Best
Tomas
On 3/23/20 4:39 PM, Wang Jiefei wrote: