Path length in function file() ?

Issues and Discussions related to Harbour

Moderator: Rathinagiri

Post Reply
dominique_devuyst
Posts: 22
Joined: Wed Dec 20, 2017 8:29 am
DBs Used: DBF
Location: Belgium

Path length in function file() ?

Post 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?
User avatar
serge_girard
Posts: 3158
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Path length in function file() ?

Post 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
There's nothing you can do that can't be done...
User avatar
serge_girard
Posts: 3158
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Path length in function file() ?

Post by serge_girard »

On w10 also OK!
Are you sure to check for the right filename?

Serge
There's nothing you can do that can't be done...
User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: Path length in function file() ?

Post by SALINETAS24 »

En xp es correcto
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
dominique_devuyst
Posts: 22
Joined: Wed Dec 20, 2017 8:29 am
DBs Used: DBF
Location: Belgium

Re: Path length in function file() ?

Post 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
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Path length in function file() ?

Post 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
dominique_devuyst
Posts: 22
Joined: Wed Dec 20, 2017 8:29 am
DBs Used: DBF
Location: Belgium

Re: Path length in function file() ?

Post 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 :oops:
It's better just to laugh . . .

Dominique
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Path length in function file() ?

Post by edk »

Sometimes it happens that an obvious mistake is difficult to notice. ;)
Post Reply