Oxygen Basic
Programming => Problems & Solutions => Topic started by: José Roca 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
-
Is that path length limitation based on a root reference or from where you are?
-
Fixed. Thanks!
It's the string buffer length for specifying a path
this structure is uses it:
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
-
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
[!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?
-
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).
-
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