Author Topic: MAX_PATH  (Read 2279 times)

0 Members and 1 Guest are viewing this topic.

José Roca

  • Guest
MAX_PATH
« on: October 09, 2018, 11:51:21 AM »
I see MAX_PATH defined as 512 in WinData.inc. How is that? The value is 260.

  % MAX_PATH             512

JRS

  • Guest
Re: MAX_PATH
« Reply #1 on: October 09, 2018, 01:59:32 PM »
Is that path length limitation based on a root reference or from where you are?

Charles Pegge

  • Guest
Re: MAX_PATH
« Reply #2 on: October 09, 2018, 03:54:13 PM »
Fixed. Thanks!

It's the string buffer length for specifying a path

this structure is uses it:

Code: [Select]
  typedef struct _WIN32_FIND_DATA {
  DWORD    dwFileAttributes
  FILETIME ftCreationTime
  FILETIME ftLastAccessTime
  FILETIME ftLastWriteTime
  DWORD    nFileSizeHigh
  DWORD    nFileSizeLow
  DWORD    dwReserved0
  DWORD    dwReserved1
  TCHAR    cFileName[MAX_PATH]
  TCHAR    cAlternateFileName[14]
  } WIN32_FIND_DATA, *PWIN32_FIND_DATA, *LPWIN32_FIND_DATA

Arnold

  • Guest
Re: MAX_PATH
« Reply #3 on: October 09, 2018, 11:16:34 PM »
MAX_PATH is one of the constants that make me nervous, see e.g.:

Naming Files, Paths, and Namespaces
https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file

Quote
[!Tip]
Starting in Windows 10, version 1607, MAX_PATH limitations have been removed from common Win32 file and directory functions. However, you must opt-in to the new behavior.

How should I understand this statement?

José Roca

  • Guest
Re: MAX_PATH
« Reply #4 on: October 09, 2018, 11:36:45 PM »
Quote
It's possible for all FS functions to use path lengths >260 characters now if the required registry key is set on Windows 10:

HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled=1 (Type: REG_DWORD)

With this setting it's possible to create 32,767 long paths without using the specific Unicode Win32 API functions and the path prefix \\?\

Though still, each folder/file aka "component" name length cannot exceed 255 characters:

The Windows API has many functions that also have Unicode versions to permit an extended-length path for a maximum total path length of 32,767 characters. This type of path is composed of components separated by backslashes, each up to the value returned in the lpMaximumComponentLength parameter of the GetVolumeInformation function (this value is commonly 255 characters).

Arnold

  • Guest
Re: MAX_PATH
« Reply #5 on: October 10, 2018, 01:07:49 AM »
Thank you, José. I now found a corresponding link too:

MAX_PATH limitation on Windows
https://github.com/keplerproject/luafilesystem/issues/110

and it seems this is an explorer issue:

260 character Explorer path length limit
https://social.msdn.microsoft.com/Forums/en-US/fc85630e-5684-4df6-ad2f-5a128de3deef/260-character-explorer-path-length-limit?forum=windowsgeneraldevelopmentissues