Page 1 of 1

Scanning all Hard-Disk's for files ( with sample )

Posted: Sat Jul 26, 2008 9:54 am
by ukoenig
Hello,
here is a tool, _ 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.

Code: Select all


#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 :lol:

Posted: Mon Jul 28, 2008 11:10 am
by MGA
thanks ukoenig... :D

Re: Scanning all Hard-Disk's for files ( with sample )

Posted: Sat Dec 13, 2008 1:12 am
by Boris
ukoenig wrote:Hello,
here is a tool, _ 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.

Code: Select all


#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 :lol:
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

Scanning Harddisk

Posted: Sat Dec 13, 2008 1:48 am
by ukoenig
Hello Boris,

I will check the situation, you have tested.

Regard
Uwe :lol:

esting Harddisks

Posted: Sat Dec 13, 2008 2:01 pm
by ukoenig
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 !
Image
In all FWH-samples ( using aDrives ) like xBrwdisk.prg I get this error.

After closing the Error :
Image

Regards
Uwe :o

Posted: Sat Dec 13, 2008 2:52 pm
by Marc Vanzegbroeck
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

Harddisk

Posted: Sat Dec 13, 2008 5:48 pm
by ukoenig
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 )
Image

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

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

Regards
Uwe :lol:

Scanning Harddisks

Posted: Mon Dec 15, 2008 1:37 pm
by ukoenig
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.

Image

Code: Select all


#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 :lol:

Posted: Mon Dec 15, 2008 2:47 pm
by James Bott
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

File-search

Posted: Mon Dec 15, 2008 3:34 pm
by ukoenig
Hello James,

I agree with You. _ 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 :

Image

Regards
Uwe :lol: