Artifacts Associated With Ticket bc7925fc50
Ticket change [a7301d5b4f] (rid 249643) by apnadkarni on 2025-12-18 11:10:06:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-markdown"
- comment initialized 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 initialized to: "0"
- login: "apnadkarni"
- priority initialized to: "5 Medium"
- private_contact initialized to: "9546e9877f1a8899e25a89082561ee694e7fb402"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "apnadkarni"
- subsystem initialized to: "- New Builtin Commands"
- title initialized to:
Inconsistencies in long path handling in Tcl 8.6 and 9
- type initialized to: "Bug"
Ticket change [1f019c83f2] (rid 249644) by apnadkarni on 2025-12-18 11:15:49:
- icomment:
As a point of clarification, the `apn-win-longpaths` branch adds support for paths longer than `MAX_PATH` *on systems that are configured to allow longer paths via Group Policy or registry settings*. On such systems, relevant Win32 API's natively support longer file paths and the branch merely ensures Tcl itself does not limit path lengths through the use of static arrays. In particular, it will not help on systems where long path support has not been enabled. On these systems the issues listed in the ticket will continue to exist.
- login: "apnadkarni"
- mimetype: "text/x-markdown"
- icomment: