Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Limit on length of file name?

a_leonard
초보자
2,810 조회수
When I try to open a file with the following line I get an error (29) if the length of the filename + length of the current directory exceeds 260 characters. Is this a limitation of Windows? Is there a way to get around it?

open( unit=idev,file=name,status='replace', err=950, iostat=iost)

3 응답
jimdempseyatthecove
명예로운 기여자 III
2,810 조회수

A,

As a "hack" create a network share to the (presumably long) current directory and use that. You may also be able to map a drive letter to the directory in a similar manner as well (drive letters can map to network shares).

Other than that you could use Win32 API calls to open files with longer names (but then you won't have the programical nuances of Fortran OPEN).

Jim Dempsey

jparsly
새로운 기여자 I
2,810 조회수

For directories on your local disk you can use the SUBST command to create a drive mapping into a directory. For example:

subst f: c:docume~1japarslymydocu~1

creates an "f" drive that is actually my "My Documents" folder.

I put this in a batch file and run it in my Startup group.

0 포인트
Steven_L_Intel1
2,810 조회수
It is a Windows limitation. Quoting the MSDN documentation:

CreateFile:

In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "?" to the path. For more information, see 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.

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.

NoteThe 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:". To specify such a UNC path, use the "?UNC" prefix. For example, "?UNC". 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 may have different requirements. It is possible to create a path with the API that the shell UI cannot handle.


0 포인트
응답