Writing files with long paths on Windows fails even after enabling long paths

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Writing files with long paths on Windows fails even after enabling long paths

Kenny Bell-2
Hello all,

We now can have long file paths on Windows by setting the LongPathsEnabled
key to 1 at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
in the Registry Editor. I can successfully rename files to have long paths
in File Explorer.

R still isn't able to take advantage of the change, however:

write(1, paste0(paste(sample(letters, 265, TRUE), collapse = ''), '.txt'))
#> Warning in file(file, ifelse(append, "a", "w")): cannot open file
#>
'mbpbzpgivtyhuugkkbcfxlvdzhsujaivaissyhivwqdxixmbnzctxlplazgtewpiioyxielkbohmvejcdkhcjmqtjyieymccrfquiwepngrseroiolayuucevztmqemnlnvfsshyhhggakxfemzzovwikusqtfeslwevxqmvufuyyvgvwwubmmpzvlcwaiwhipumrzphyeziwibisxszqrouekuonzjlaztdtonuupniqmxsaifpvkcldftkgnkozntgndwfu.txt':
#> No such file or directory
#> Error in file(file, ifelse(append, "a", "w")): cannot open the connection

I have read that long paths will be enabled by default in some future
release of Windows.

Hope this helps,
Kenny

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Writing files with long paths on Windows fails even after enabling long paths

Tomas Kalibera
Thanks for the note. R uses MAX_PATH internally at a number of places
(both directly in Windows specific code and indirectly via PATH_MAX to
reflect POSIX) and sometimes uses POSIX functions to access files and
directories, so it would be a non-trivial change and would require more
Windows-specific code in the code base. I expect external libraries to
also depend on MAX_PATH and sometimes use POSIX functions (when
supported on Windows) to access files and directories. Mingw which we
use on Windows also has PATH_MAX derived from MAX_PATH to reflect POSIX
behavior and allow use of POSIX-like functions.  It is hence even
unclear how big effect this change if done in R could have on R end
users, the limit would just remain in many situations. So I am afraid
the path length limit on Windows in R cannot be removed/increased in the
near future. Please feel free to submit a wishlist report to bugzilla,
where this could be revisited in the future.

Best
Tomas

On 7/24/19 8:43 AM, Kenny Bell wrote:

> Hello all,
>
> We now can have long file paths on Windows by setting the LongPathsEnabled
> key to 1 at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
> in the Registry Editor. I can successfully rename files to have long paths
> in File Explorer.
>
> R still isn't able to take advantage of the change, however:
>
> write(1, paste0(paste(sample(letters, 265, TRUE), collapse = ''), '.txt'))
> #> Warning in file(file, ifelse(append, "a", "w")): cannot open file
> #>
> 'mbpbzpgivtyhuugkkbcfxlvdzhsujaivaissyhivwqdxixmbnzctxlplazgtewpiioyxielkbohmvejcdkhcjmqtjyieymccrfquiwepngrseroiolayuucevztmqemnlnvfsshyhhggakxfemzzovwikusqtfeslwevxqmvufuyyvgvwwubmmpzvlcwaiwhipumrzphyeziwibisxszqrouekuonzjlaztdtonuupniqmxsaifpvkcldftkgnkozntgndwfu.txt':
> #> No such file or directory
> #> Error in file(file, ifelse(append, "a", "w")): cannot open the connection
>
> I have read that long paths will be enabled by default in some future
> release of Windows.
>
> Hope this helps,
> Kenny
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel