Directory() problem with 7.05

Directory() problem with 7.05

Postby Taavi » Mon Jun 11, 2007 3:47 pm

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

Re: Directory() problem with 7.05

Postby Enrico Maria Giordano » Mon Jun 11, 2007 3:54 pm

That's the normal DIRECTORY() behavior. If you want to filter out the files you have to scan the array for "D" attribute (F_ATTR).

Please consult Clipper/Harbour/xHarbour docs.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Taavi » Tue Jun 12, 2007 7:36 am

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

Postby Enrico Maria Giordano » Tue Jun 12, 2007 8:36 am

Yes, I confirm the problem with lIsDir().

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Enrico Maria Giordano » Tue Jun 12, 2007 8:49 am

It has been changed in the last FWH version. This is from the previous one:

Code: Select all  Expand view
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
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Tue Jun 12, 2007 9:14 am

Here it is working fine:

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

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

Postby Enrico Maria Giordano » Tue Jun 12, 2007 9:21 am

Yes, but it returns .T. even if a file is specified:

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    ? LISDIR( "c:\windows\regedit.exe" )

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Tue Jun 12, 2007 9:27 am

This seems to be the right code:
Code: Select all  Expand view
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
Antonio Linares
Site Admin
 
Posts: 42078
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Enrico Maria Giordano » Tue Jun 12, 2007 9:40 am

Maybe it's better

Code: Select all  Expand view
return Len( aResult ) == 1 .and. "D" $ aResult[ 1 ][ 5 ]


?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Tue Jun 12, 2007 9:43 am

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: 42078
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Enrico Maria Giordano » Tue Jun 12, 2007 9:49 am

Yes, a directory can have attributes other than "D".

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Tue Jun 12, 2007 9:50 am

ok, thanks! :-)
regards, saludos

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 54 guests