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

Long Full Path

Ilie__Daniel
Beginner
1,181 Views
Hi!

I'm trying to retrieve a long full path, following a file search with FindFirstFile and FindNextFile, and FullPathQQ fails understandably as the buffer is limited to 260 chars.

I have tried to use aWIN API GetFullPathW to do the work, but somehow I cannot get it to work. The Intel interface defined in kernel32.f90 is pointing to the GetFullPathA, which cannot resolve paths longer than 260.

The length of the path, which I'm trying to retrieve is about 320chars. I am getting nothing in the output variable cFullPathW.

I have attached a part of the code below. What am I doing wrong?



integer(HANDLE) :: hFile
integer(BOOL) :: iResult
integer(DWORD) :: dwLenPathOut
integer(LPSTR) :: lpFilePart
integer :: ilen
integer(4) :: iLenPath
logical(4) :: lResult
logical :: first_instance
character(len=1024) :: cFullPath
character(len=4096) :: cFullPathW
type(T_WIN32_FIND_DATA) :: FileInfo

! Declare interfaces.
interface
function GetFullPathName( &
lpFileName, &
nBufferLength, &
lpBuffer, &
lpFilePart)
use ifwinty
integer(DWORD) :: GetFullPathName ! DWORD
!dec$ attributes default, stdcall, decorate, alias:'GetFullPathNameW' :: GetFullPathName
!dec$ attributes reference, ignore_loc, allow_null :: lpFileName
character*(*) lpFileName ! LPCSTR lpFileName
integer(DWORD) nBufferLength ! DWORD nBufferLength
!dec$ attributes reference, ignore_loc, allow_null :: lpBuffer
character*(*) lpBuffer ! LPSTR lpBuffer
!dec$ attributes reference, ignore_loc :: lpFilePart
integer(LPSTR) lpFilePart ! LPSTR* lpFilePart
end function
end interface


! Use the cFileName from the structure in UNICODE


dwLenPathOut = GetFullPathName("\\?" // trim(FileInfo%cFileName), &
4096, &
cFullPathW, lpFilePart)


Thank you for your help.
Daniel.
0 Kudos
8 Replies
Steven_L_Intel1
Employee
1,181 Views
Well, one thing that jumps out at me is that I don't see a NUL termination of the input string argument.
0 Kudos
GVautier
New Contributor II
1,181 Views
Hello

See : http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx

for a full explanation about maximum path length from Microsoft

Best regards
0 Kudos
Ilie__Daniel
Beginner
1,181 Views
Well, one thing that jumps out at me is that I don't see a NUL termination of the input string argument.

Steve,

Thank you. I modified my code to include the NUL termination butit fails when it calls GetFullPathNameW routine. Maybe I have the interface wrong. Everything seems to be working fine, until I call this function. I cannot find any interface for this function.

I have attached my project should you wish to take a look.
Thank you for your time.

Daniel.

0 Kudos
Ilie__Daniel
Beginner
1,181 Views
Quoting - gvautier
Hello

See : http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx

for a full explanation about maximum path length from Microsoft

Best regards

Thank you.
0 Kudos
Steven_L_Intel1
Employee
1,181 Views
We don't provide interfaces to the "W" functions at this time.
0 Kudos
Ilie__Daniel
Beginner
1,181 Views
We don't provide interfaces to the "W" functions at this time.

Steve,

Are there any plans to extend the functionality of routines that handle paths, such as FullPathQQ, to support more than MAXPATH characters?
If yes, in what version of the Compiler would you think they will be?

Thank you.
Daniel.
0 Kudos
Steven_L_Intel1
Employee
1,181 Views

That isn't on our list at this time. I don't think it's appropriate to try to extend GETFULLPATHQQ in this way because local paths are still subject to MAX_PATH.
0 Kudos
jimdempseyatthecove
Honored Contributor III
1,181 Views

Daniel,

Many years ago when I encountered this problem (on Win95) we used the current directory/change current directory as a work around. Instead of getting the full path just get the file name. The current path you maintain in your own data space. Your API calls are relative to the current directory on the drive in question (and you hold onto the full path name). You will then have no limit on the path name.

C:Program Filesblabla bla...more of the same...do dado dafoo.dat

You can save the current directory on C: first then use
dir = 'C:Program Files'
CHANGEDIRQQ(dir)
dir ='C:.bla'
CHANGEDIRQQ(dir)
dir ='C:.bla bla'
CHANGEDIRQQ(dir)
etc...

When you are traversing folders it will be your responsibility to maintain the full path of where the current directory is on the drive of interest.

dir ='C:..' ! pop-up a level
CHANGEDIRQQ(dir)


BTW, we had to do this in order to backup the temporay internet folders.

Jim Dempsey
0 Kudos
Reply