1. Re: Error: file name for OPEN is too long
- Posted by Matt Lewis <matthewwalkerlewis at gma?l?com> Dec 19, 2007
- 520 views
Juergen Luethje wrote: > > Hello all, > > using exw.exe 3.1.1 on Windows XP, a program crashed with the error message: > file name for open() is too long > > According to my tests, complete file names (including path and extension) > up to a length of 254 characters are working fine. With names longer than > 254 characters I get this error. Can someone confirm this? > > What are the maximum possible lengths of complete file names on modern > Windows systems, and on Linux/FreeBSD? Is it possible to change the Eu > interpreters/translators, so that file names with the maximum length on > the concerning OS can be used with Eu programs? As Derek mentioned, these are Windows limitations (but the interpreter also limits the length--probably because of this). Below is some info from msdn (copied/pasted, because who knows how long it will be before MS reorganizes). I think you could probably get around this by changing the current directory (possibly several times) and using relative paths. The alternative is to possibly use unicode, which would be a lot more work, and would require significant changes to the interpreter. http://msdn2.microsoft.com/en-us/library/aa365247.aspx Naming a File Maximum Path Length In the Windows API, the maximum length for a path is MAX_PATH, which is defined as 260 characters. A path is structured in the following order: drive letter, colon, backslash, components separated by backslashes, and a null-terminating character, for example, the maximum path on the D drive is "D:\<256 chars>NUL". Note Functions in the Windows API convert "/" to "\" as part of converting the name to an NT style name. The Unicode versions of several functions permit a maximum path length of approximately 32,000 characters composed of components up to 255 characters in length. To specify that kind of path, use the "\\?\" prefix. Note The maximum path of 32,000 characters is approximate, because the "\\?\" prefix can be expanded to a longer string, and the expansion applies to the total length. For example, "\\?\D:\<path>". To specify such a UNC path, use the "\\?\UNC\" prefix. For example, "\\?\UNC\<server>\<share>". These prefixes are not used as part of the path itself. They indicate that the path should be passed to the system with minimal modification, which means that you cannot use forward slashes to represent path separators, or a period to represent the current directory. Also, you cannot use the "\\?\" prefix with a relative path. Relative paths are limited to MAX_PATH characters. When using the API to create a directory, the specified path cannot be so long that you cannot not append an 8.3 file name. The shell and the file system have different requirements. It is possible to create a path with the API that the shell UI cannot handle. Relative Paths For functions that manipulate files, the file names can be relative to the current directory. A file name is relative to the current directory if it does not begin with one of the following: * A disk designator, which is either a drive letter followed by a colon, or a server name and share name (\\servername\sharename). * A directory name separator, such as a backslash, for example, \subdir). If the file name begins with a disk designator and a backslash (\), it is a full path (for example, c:\tmp). If a file name begins with only a disk designator, it is a relative path to the current directory on the drive with the specified letter (for example, c:tmp.txt refers to a file in the current directory on the C drive).