Overview
| Artifact ID: | a7301d5b4fae7769f1c64a44138ce029f26fd0730fd53c83825494fde076fffd |
|---|---|
| Ticket: | bc7925fc5038e49d114fb6bc0d6d8366f9be2f67
Inconsistencies in long path handling in Tcl 8.6 and 9 |
| User & Date: | apnadkarni on 2025-12-18 11:10:06 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-markdown"
- comment changed to:
(I'm working on adding support for long paths as available in newer Windows versions. The bugs below are only tangentially related as the new support does not use the `\\?\` prefix.) Tcl 9 (and 8.6) support for long file paths (> MAX_PATH characters) on Windows is inconsistent and unusable from applications. Consider ``` % set longPath [file join [pwd] {*}[lrepeat 4 [string repeat X 254]]]; string length $longPath 1044 % file mkdir $longPath % file isdirectory $longPath 1 ``` All that works, but leads to inconsistent behaviour like you can create the directory but not change to it ``` % cd $longPath couldn't change working directory to "C:/src/tcltk/wip/tcl/win/XXX.....XX": file name too long ``` Or the directory exists but not its parent! ``` % file isdirectory [file join $longPath ..] 0 % file exists [file join $longPath ..] 0 ``` Or discrepancies with commands like `glob` ``` % glob $longPath/* couldn't read directory "C:/src/tcltk/wip/tcl/win/XXXX...XX/*": no such file or directory % glob $longPath/../* ``` The first case should not be returning an error. The second case should be returning the leaf component. The basic issue is that Tcl tries to handle Windows `MAX_PATH` limitations by prefixing `\\?\` to file paths whose lengths exceed `MAX_PATH`. That causes the Win32 API's to bypass their normal processing of paths and pass it directly to the NT Object manager which accepts paths up to 32K (or thereabouts). The problem is that - semantics of the NT Object manager are different from the Win32 "normal" or portable path syntax (leading to the bugs with the parent directories like above) - Tcl does not do this "helpful" preprocessing for all code paths. - Not all Win32 API's that Tcl calls may support this "pass-through" syntax The result is the inconsistent and confusing behavior as logged in the [c.l.t. thread](https://newsgrouper.org/comp.lang.tcl/1764173759) and Tk [ticket](https://core.tcl-lang.org/tk/tktview/e3e3283178). My opinion is that Tcl should not try to fix up deficiencies in a system API (Win32 in this case) unless it can do a reasonably thorough job. It is better to raise an error than present a logically inconsistent interface to the user as illustrated in the above commands. - is_private changed to: "0"
- login: "apnadkarni"
- priority changed to: "5 Medium"
- private_contact changed to: "9546e9877f1a8899e25a89082561ee694e7fb402"
- resolution changed to: "None"
- severity changed to: "Minor"
- status changed to: "Open"
- submitter changed to: "apnadkarni"
- subsystem changed to: "- New Builtin Commands"
- title changed to:
Inconsistencies in long path handling in Tcl 8.6 and 9
- type changed to: "Bug"