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

Post Reply
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

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

Post 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:
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.
MGA
Posts: 1219
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá
Contact:

Post by MGA »

thanks ukoenig... :D
ubiratanmga@gmail.com

FWH17.04
FWPPC
Harbour/xHarbour
xMate
Pelles´C
TDolphin
User avatar
Boris
Posts: 16
Joined: Sun Nov 27, 2005 1:57 am

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

Post 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
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Scanning Harddisk

Post by ukoenig »

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.
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

esting Harddisks

Post 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
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.
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Post 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
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Harddisk

Post 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:
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.
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Scanning Harddisks

Post 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:
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.
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post 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
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

File-search

Post 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:
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.
Post Reply