Directory() problem with 7.05

Post Reply
Taavi
Posts: 77
Joined: Mon Nov 21, 2005 10:29 am

Directory() problem with 7.05

Post 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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Directory() problem with 7.05

Post 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
Taavi
Posts: 77
Joined: Mon Nov 21, 2005 10:29 am

Post 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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Here it is working fine:

MsgInfo( lIsDir( "c:\windows" ) )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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"
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Maybe it's better

Code: Select all

return Len( aResult ) == 1 .and. "D" $ aResult[ 1 ][ 5 ]
?

EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Enrico,

aResult[ 1 ][ 5 ] may contain some other values besides the "D", at the same time ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

ok, thanks! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply