Page 1 of 1
Path length in function file() ?
Posted: Tue Apr 23, 2019 1:34 pm
by dominique_devuyst
Hello everybody,
It seems that the file() function does not accept a path longer than 56 characters?
example:
x := file ("c:\folder\subfolder\subfolder\somefile")
result --> x = .F. if length of c:\folder\subfolder\subfolder\ > 56
Windows 7 supports 260 characters, but I can not find any specification in the Harbour doc.
Somebody knows what?
Re: Path length in function file() ?
Posted: Tue Apr 23, 2019 2:49 pm
by serge_girard
Hi Dominque,
On w7 if tested a file of +100 len
Code: Select all
cFILE := 'P:\CDS\Allan Holdsworth-Alan Pasqua-Jimmy Haslip-Chad Wackerman\Blues for Tony Disc 1\01 Blues for Tony.WMA'
IF FILE(cFILE)
MSGINFO('OK')
ELSE
MSGINFO('NOK')
ENDIF
And it gave OK!
I'll try on my w10 later.
Serge
Re: Path length in function file() ?
Posted: Tue Apr 23, 2019 3:10 pm
by serge_girard
On w10 also OK!
Are you sure to check for the right filename?
Serge
Re: Path length in function file() ?
Posted: Tue Apr 23, 2019 4:31 pm
by SALINETAS24
En xp es correcto
Re: Path length in function file() ?
Posted: Tue Apr 23, 2019 5:18 pm
by dominique_devuyst
serge_girard wrote: ↑Tue Apr 23, 2019 3:10 pm
On w10 also OK!
Are you sure to check for the right filename?
Serge
Hello Serge,
Yes, I am sure. I have tested with a path of variable length by adding one character at a time and with always de same filename, len 15 characters.
file() return .T. but arrived at 56 characters the function returns .F.
I am on W7.
So, I will continue to search.
Dominique
Re: Path length in function file() ?
Posted: Tue Apr 23, 2019 6:36 pm
by edk
Please, do a simple test:
Code: Select all
#include "hmg.ch"
PROCEDURE Main
Local cPath := hb_CWD() + "folder 1234567890\ABCDEFGH ijklmn\123 456\__________\+_+_+_+_+_+_+_+_+_+_+_+_+_+\(^)(^)(^)(^)(^)(^)(^)(^)(^)(^)\!@!@!@!@!@!@!@!@!\"
Local cFile := "test 1234567890 abc DEF.txt"
IF ! hb_DirBuild ( cPath )
MsgStop ( "Error creating the folders." )
ENDIF
IF StrFile ( cPath + cFile, cPath + cFile ) < Len ( cPath + cFile )
MsgStop ( "Error creating the file." )
ELSE
MsgInfo ( "Your file: " + cPath + cFile )
ENDIF
MsgDebug ( "File():", File ( cPath + cFile ), "Len ():", Len ( cPath + cFile ) )
MsgDebug ( "hb_FileExists():", hb_FileExists ( cPath + cFile ), "Len ():", Len ( cPath + cFile ) )
Return
Re: Path length in function file() ?
Posted: Wed Apr 24, 2019 2:05 pm
by dominique_devuyst
edk wrote: ↑Tue Apr 23, 2019 6:36 pm
Please, do a simple test:
Code: Select all
#include "hmg.ch"
PROCEDURE Main
Local cPath := hb_CWD() + "folder 1234567890\ABCDEFGH ijklmn\123 456\__________\+_+_+_+_+_+_+_+_+_+_+_+_+_+\(^)(^)(^)(^)(^)(^)(^)(^)(^)(^)\!@!@!@!@!@!@!@!@!\"
Local cFile := "test 1234567890 abc DEF.txt"
IF ! hb_DirBuild ( cPath )
MsgStop ( "Error creating the folders." )
ENDIF
IF StrFile ( cPath + cFile, cPath + cFile ) < Len ( cPath + cFile )
MsgStop ( "Error creating the file." )
ELSE
MsgInfo ( "Your file: " + cPath + cFile )
ENDIF
MsgDebug ( "File():", File ( cPath + cFile ), "Len ():", Len ( cPath + cFile ) )
MsgDebug ( "hb_FileExists():", hb_FileExists ( cPath + cFile ), "Len ():", Len ( cPath + cFile ) )
Return
Your example works fine, thank you.
Now I found the problem :
The pathname was not the problem but . . .
filename was not trimmed and with trailing blanks len (pathname + filename) > 260
It's better just to laugh . . .
Dominique
Re: Path length in function file() ?
Posted: Wed Apr 24, 2019 3:00 pm
by edk
Sometimes it happens that an obvious mistake is difficult to notice.