On Mar 9 11:03, Brian Dessent wrote: > Christopher Faylor wrote: > > > I guess I misunderstood. I thought that the current working directory > > could be derived through some complicated combination of Nt*() calls. > > I could be wrong here but the way I understood it, there is no concept > of a working directory at the NT level, that is something that is > maintained by the Win32 layer.
That's right. NT doesn't have a notion what a cwd is. It only has the OBJECT_ATTRIBUTES structure which defines an object by an absolute path, or by a path relative to a directory handle. The cwd is maintained by kernel32.dll in a per-process structure called RTL_USER_PROCESS_PARAMETERS. The cwd is stored as path (always with trailing backslash) and as handle. Sometimes the Win32 functions use the cwd's path to create an absolute path from a relative path, sometimes they use the cwd's handle and the relative path in calls to NT functions. > My question is, what does GetCurrentDirectoryW() return if the current > directory is greater than the 260 limit? Does it choke or does it > switch to the \.\c:\foo syntax? It can't do that. See the MSDN man page for SetCurrentDirectory: http://msdn2.microsoft.com/en-us/library/aa365530(VS.85).aspx "The string must not exceed MAX_PATH characters including the terminating null character." The problem is that the cwd is stored as UNICODE_STRING with a statically allocated buffer in the user parameter block. The MaximumLength is set to 520. SetCurrentDirectory refuses to take paths longer than that. In theory it would be possible to define a longer cwd by defining a new buffer in the cwd's UNICODE_STRING. But I never tried that. I don't really know if that's possible and what happens if you call CreateProcess or, FWIW, any Win32 file access function after doing that. Nobody keeps us from trying, but I have this gut feeling that different NT versions will show different behaviour... Corinna (*) See cygwin/ntdll.h, struct _RTL_USER_PROCESS_PARAMETERS. -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat
