Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Traversing directories deeper than Windows MAX_PATH

100 views
Skip to first unread message

Busirane

unread,
Jul 6, 2015, 10:06:49 AM7/6/15
to
I have an application that traverses a directory tree an puts it into a treectrl with some other data. It runs into problems when the directory is very deeply nested, i.e., deeper than the Windows MAX_PATH. It uses [glob] to find the children at each level, and [file is*] to tell the files from the directories.

I know about the //?/ prefix trick, and it does seem to work for the [file] commands. (In fact, I created a structure about 4000 levels deep, that took me quite a while to figure out how to delete!) But that prefix doesn't seem to work with [glob], so I can't figure out how to fully traverse deeply nested directories.

I tried [fileutil::find], but it didn't work. Windows native "dir" doesn't seem to be able to do it, either. Windows Explorer will let you view such a deep directory structure, but you can't manipulate it.

Does anyone know how to fully traverse a deeply nested directory under Windows?

Busirane

unread,
Jul 6, 2015, 2:38:30 PM7/6/15
to
Info on this is hard to Google, but here are some helpful links. Apparently this functionality was requested, specifically for [glob], way back in 2006:

https://groups.google.com/forum/#!topic/comp.lang.tcl/5awD6g40jrg

A bug report was submitted and fixed in 8.5, but it only mentions [file]:

https://core.tcl.tk/tcl/tktview/1479814fffffffffffff

I can report that [glob] still doesn't handle //?/ paths as of 8.5.17.

Olivier

unread,
Jul 7, 2015, 3:37:16 AM7/7/15
to

>
> Does anyone know how to fully traverse a deeply nested directory under Windows?

As far as I known there is a limit for explorer, but also a theorical limit at about 32 000 characters ( https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath ) , with 4000 levels you shouldn't be far of it ?

Olivier.

Harald Oehlmann

unread,
Jul 7, 2015, 4:14:53 AM7/7/15
to
Please file a bug.
AFAIK this depends on the used Windows API. Jan Nijtmans was working on that before.
A test case would be helpful too.

The limits and rules are really complicated:

https://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx

I suppose, glob is composing and decomposing the path and hits the limit, that a relative path may never exceed 256 characters in length. But this is speculation.

Thank you working,
Harald

Harald Oehlmann

unread,
Jul 7, 2015, 4:17:48 AM7/7/15
to

Busirane

unread,
Jul 10, 2015, 9:47:24 AM7/10/15
to

Harald Oehlmann

unread,
Jul 10, 2015, 10:02:00 AM7/10/15
to
Am Freitag, 10. Juli 2015 15:47:24 UTC+2 schrieb Busirane:
> Bug report submitted.
>
> https://core.tcl.tk/tcl/tktview/3eace1b21f66da738cd1769e4ec69cb0f50e6029

Great, thank you, very detailed...
0 new messages