Page 1 of 1
Directory() problem with 7.05
Posted: Mon Jun 11, 2007 3:47 pm
by Taavi
Hi,
in our tests with FWH 7.05 Directory( cDirName, "D" ) returns not only directory names but all filenames in this dir. Therefore
function lIsDir( cDirName )
return Len( Directory( cDirName, "D" ) ) == 1
Returns always .f. with 7.05
Somebody with the same problem here?
Thanks,
Taavi
Re: Directory() problem with 7.05
Posted: Mon Jun 11, 2007 3:54 pm
by Enrico Maria Giordano
That's the normal DIRECTORY() behavior. If you want to filter out the files you have _ the array for "D" attribute (F_ATTR).
Please consult Clipper/Harbour/xHarbour docs.
EMG
Posted: Tue Jun 12, 2007 7:36 am
by Taavi
IF so, then FWH function lIsdir() is not working any more (worked ok with xHarbour/FWH January builds. Had to replace it with Harbour IsDirectory() in our code
Taavi
Posted: Tue Jun 12, 2007 8:36 am
by Enrico Maria Giordano
Yes, I confirm the problem with lIsDir().
EMG
Posted: Tue Jun 12, 2007 8:49 am
by Enrico Maria Giordano
It has been changed in the last FWH version. This is from the previous one:
Code: Select all
function lIsDir( cNewDir ) // Checks an existing directory
local cDir := CurDrive() + ":\" + CurDir()
local lIsDir := lChDir( cNewDir )
if lIsDir
lChDir( cDir )
endif
return lIsDir
EMG
Posted: Tue Jun 12, 2007 9:14 am
by Antonio Linares
Here it is working fine:
MsgInfo( lIsDir( "c:\windows" ) )
Posted: Tue Jun 12, 2007 9:21 am
by Enrico Maria Giordano
Yes, but it returns .T. even if a file is specified:
Code: Select all
#include "Fivewin.ch"
FUNCTION MAIN()
? LISDIR( "c:\windows\regedit.exe" )
RETURN NIL
EMG
Posted: Tue Jun 12, 2007 9:27 am
by Antonio Linares
This seems to be the right code:
Code: Select all
function lIsDir( cDirName )
local aResult := Directory( cDirName, "D" )
return Len( aResult ) == 1 .and. aResult[ 1 ][ 5 ] == "D"
Posted: Tue Jun 12, 2007 9:40 am
by Enrico Maria Giordano
Maybe it's better
Code: Select all
return Len( aResult ) == 1 .and. "D" $ aResult[ 1 ][ 5 ]
?
EMG
Posted: Tue Jun 12, 2007 9:43 am
by Antonio Linares
Enrico,
aResult[ 1 ][ 5 ] may contain some other values besides the "D", at the same time ?
Posted: Tue Jun 12, 2007 9:49 am
by Enrico Maria Giordano
Yes, a directory can have attributes other than "D".
EMG
Posted: Tue Jun 12, 2007 9:50 am
by Antonio Linares
ok, thanks!