FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Scanning all Hard-Disk's for files ( with sample )
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Scanning all Hard-Disk's for files ( with sample )
Posted: Sat Jul 26, 2008 09:54 AM
Hello,
here is a tool, to scan all Hard-disks for defined files.

After a problem with Microsoft
( with a automatic-update of VISTA, i got a corrupt DVD-driver
for my SONY-RW ) with that, the function aDrives( 2 ) didn't work
and i had to test on a different computer.

#include "fivewin.ch"

PROCEDURE Main()

// aDrives( [<nType>] ) --> aDrives  
// This function Returns an array with all the units valid of our system.  
// Parameters: 
//  <nType> 0 = All drives (default), 1 = Floppy drives only, 2 = Hard drives only  

aResult1 := {}  // Borland
aResult2 := {}  // Harbour
aResult3 := {}  // FWH
lResult1 := .F.
lResult2 := .F.
lResult3 := .F.

aDrive := aDrives( 2 ) // scanning of harddisks

FOR i := 1 TO LEN ( aDrives( 2 ) )

      cDrive := aDrive[i]  // scanning drives

     msgalert( "Seek in Drive : " + CRLF + ;
	                 cDrive, "Drive" )

     aFindFile( "BCC32.exe", "&cDrive", aResult1 )
     // <cFileName> File to search.  
     // <cPath> Path of beginning of the search.  
     // <aResult> Array where the result of the search will be stored.  

     IF !empty( aResult1 )  .and. lResult1 = .F.
          lResult1 := .T.
          // Returns the complete Path of BORLAND
          msgalert( aResult1[1], "BORLAND found" )      
     ENDIF

     aFindFile( "HARBOUR.exe", "&cDrive", aResult2 )
     IF !empty( aResult2 )   .and. lResult2 = .F.  
          lResult2 := .T.
          msgalert( aResult2[1],"XHARBOUR found" )
     ENDIF

     aFindFile( "FIVEH.lib", "&cDrive", aResult3 )
     IF !empty( aResult3 )  .and. lResult3 = .F.   
          lResult3 := .T.
          msgalert( aResult3[1],"FWH found" )
     ENDIF

     IF lResult1 = .T. .and. lResult2 = .T. .and. lResult3 = .T.
          MsgAlert( "Scanning of : " + CRLF + ;
          "BORLAND, xHARBOUR and FWH finished !","Attention" ) 
          // all files found, finished scanning
          EXIT
    ENDIF

NEXT

Return( NIL )


maybe you can need it

Best Regardes
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 1286
Joined: Mon Feb 25, 2008 02:54 PM
Scanning all Hard-Disk's for files ( with sample )
Posted: Mon Jul 28, 2008 11:10 AM

thanks ukoenig... :D

ubiratanmga@gmail.com

FWH24.04
BCC7.3
HARBOUR3.2
xMate
Pelles´C
TDolphin
Posts: 16
Joined: Sun Nov 27, 2005 01:57 AM
Re: Scanning all Hard-Disk's for files ( with sample )
Posted: Sat Dec 13, 2008 01:12 AM
ukoenig wrote:Hello,
here is a tool, to scan all Hard-disks for defined files.

After a problem with Microsoft
( with a automatic-update of VISTA, i got a corrupt DVD-driver
for my SONY-RW ) with that, the function aDrives( 2 ) didn't work
and i had to test on a different computer.

#include "fivewin.ch"

PROCEDURE Main()

// aDrives( [<nType>] ) --> aDrives  
// This function Returns an array with all the units valid of our system.  
// Parameters: 
//  <nType> 0 = All drives (default), 1 = Floppy drives only, 2 = Hard drives only  

aResult1 := {}  // Borland
aResult2 := {}  // Harbour
aResult3 := {}  // FWH
lResult1 := .F.
lResult2 := .F.
lResult3 := .F.

aDrive := aDrives( 2 ) // scanning of harddisks

FOR i := 1 TO LEN ( aDrives( 2 ) )

      cDrive := aDrive[i]  // scanning drives

     msgalert( "Seek in Drive : " + CRLF + ;
	                 cDrive, "Drive" )

     aFindFile( "BCC32.exe", "&cDrive", aResult1 )
     // <cFileName> File to search.  
     // <cPath> Path of beginning of the search.  
     // <aResult> Array where the result of the search will be stored.  

     IF !empty( aResult1 )  .and. lResult1 = .F.
          lResult1 := .T.
          // Returns the complete Path of BORLAND
          msgalert( aResult1[1], "BORLAND found" )      
     ENDIF

     aFindFile( "HARBOUR.exe", "&cDrive", aResult2 )
     IF !empty( aResult2 )   .and. lResult2 = .F.  
          lResult2 := .T.
          msgalert( aResult2[1],"XHARBOUR found" )
     ENDIF

     aFindFile( "FIVEH.lib", "&cDrive", aResult3 )
     IF !empty( aResult3 )  .and. lResult3 = .F.   
          lResult3 := .T.
          msgalert( aResult3[1],"FWH found" )
     ENDIF

     IF lResult1 = .T. .and. lResult2 = .T. .and. lResult3 = .T.
          MsgAlert( "Scanning of : " + CRLF + ;
          "BORLAND, xHARBOUR and FWH finished !","Attention" ) 
          // all files found, finished scanning
          EXIT
    ENDIF

NEXT

Return( NIL )


maybe you can need it

Best Regardes
Uwe :-)

Nice example :-)
However I have a problem with it.
I have 2 physical HDs (C and D)
On both of them I have many instances of the file "path.ini" in different folders
When I run this sample and enter I need "path.ini" to be found, the program finds only the files (12) which reside on D in all folders!
No file was found on drive C.

I have 10 files on C and 12 on D, but only 12 files on D are found.
What can be the reason?
Any idea?

Regards
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Scanning Harddisk
Posted: Sat Dec 13, 2008 01:48 AM

Hello Boris,

I will check the situation, you have tested.

Regard
Uwe :lol:

Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
esting Harddisks
Posted: Sat Dec 13, 2008 02:01 PM
Hello Boris,

Today I tested the Harddisks.
( Tested with VISTA )

aDrive := aDrives( 2 ) // scanning of harddisks

It seems there is a problem with VISTA :
Translated Error : No Harddisks !

In all FWH-samples ( using aDrives ) like xBrwdisk.prg I get this error.

After closing the Error :


Regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Scanning all Hard-Disk's for files ( with sample )
Posted: Sat Dec 13, 2008 02:52 PM

Uwe,

There is no problem with Vista and aDrives()

If I run the FWH-sample testdrvs.prg I directly get the dialog 'Select a drive' without first getting the error.

Regards,

Marc

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Harddisk
Posted: Sat Dec 13, 2008 05:48 PM
hello Marc,

I think, I know where it comes from :
reading empty USB-drive-connections with < aDrives( 2 ) >

The Disks, shown with a File-manager :
K, L and N not exists. ( empty USB-drive-connections )


The Result ( physical drives without K, L and N ) :


I don't know, if it is possible for the function < aDrives( 2 ) >,
to ignore these disk-connections ?

Regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Scanning Harddisks
Posted: Mon Dec 15, 2008 01:37 PM
Hello,

here is a new working sample.
Because to solve the USB-error ( no connection ), I had to do some changes. You cannot use < ADrives( nType ) >
It works like expected now.



#define DRIVE_REMOVABLE  2

FUNCTION MAIN()
local oDlg, aDrives := {}, aDrives1 := {} 
aResult1 := {}  // Borland 
aResult2 := {}  // Harbour 
aResult3 := {}  // FWH 
aResult4 := {}  // Test

FOR i = ASC( "C" ) TO ASC( "Z" )
   // Select only non USB-drives
   // -------------------------------
   IF GetDriveType( CHR( i ) + ":\" ) <> DRIVE_REMOVABLE ;
      .and. FILE( CHR( i ) + ":\NUL" )
      AADD( aDrives, CHR( i ) + ":" )
   ENDIF
NEXT

CURSORWAIT()

FOR i := 1 TO LEN ( aDrives ) 
   cDrive := aDrives[i]  
   MsgWait( cDrive, "Working....", 2)
   aFindFile( "BCC32.exe", cDrive, aResult1 ) 
   // <cFileName> File to search.  
   // <cPath> Path of beginning of the search.  
   // <aResult> Array where the result of the search will be stored.  
   IF !empty( aResult1 )  
      // Returns the complete Path of BORLAND 
      n := 1
      FOR n := 1 to LEN( aResult1 )
         AAdd( aDrives1, aResult1[n] )
      NEXT
      aResult1 := {}  
   ENDIF 
   aFindFile( "HARBOUR.exe", cDrive, aResult2 ) 
   IF !empty( aResult2 )  
      n := 1
      FOR n := 1 to LEN( aResult2 )
         AAdd( aDrives1, aResult2[n] )
      NEXT
      aResult2 := {}  
   ENDIF 
   aFindFile( "FIVEH.lib", cDrive, aResult3 ) 
   IF !empty( aResult3 ) 
      n := 1
      FOR n := 1 to LEN( aResult3 )
         AAdd( aDrives1, aResult3[n] )
      NEXT
      aResult3 := {}  
   ENDIF 
   // < Test.txt > exists on different disks and sub-directorys
   // -----------------------------------------------------------------
   aFindFile( "TEST.txt", cDrive, aResult4 ) 
   IF !empty( aResult4 )
      n := 1
      FOR n := 1 to LEN( aResult4 )
         AAdd( aDrives1, aResult4[n] )
      NEXT
      aResult4 := {}  
   ENDIF 
NEXT 

DEFINE DIALOG oDlg FROM 2, 5 TO 40, 60 ; 
TITLE "Files found :" 

@ 0.5, 1.5 LISTBOX cDrive ITEMS aDrives1 ; 
SIZE 200, 250 ; 
OF oDlg ; 
ON DBLCLICK oDlg:End() 

@ 14.7, 16 BUTTON "&Ok" OF oDlg ; 
ACTION oDlg:End() 

ACTIVATE DIALOG oDlg CENTERED 

RETURN( NIL )


Regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Scanning all Hard-Disk's for files ( with sample )
Posted: Mon Dec 15, 2008 02:47 PM

Uwe,

I am curious as to how long it might take to find a file this way? My C drive alone has over 700,000 files on it. I would think that this would a very long time to search.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
File-search
Posted: Mon Dec 15, 2008 03:34 PM
Hello James,

I agree with You. To scan disks with many files, it takes some time.
I tested the time with a application < SPEEDCOMMANDER >.
Funny, this application needed much more time, to find my files.
The speed, testing other tools, wasn't better.

My scanned computer ( Dual Core ) :
6 harddisks
-------------
C: 152.000
D: 66.000
E: 190.000
F: 51.000
G: 338.000
H: 3.600
--------------
Total : round about : 800.600 Files

stopped scanning time 1 Minute :



Regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.

Continue the discussion