Recursive Searching the Hard Disk for a file.

BlitzPlus Forums/BlitzPlus Beginners Area/Recursive Searching the Hard Disk for a file.

-=Darkheart=-(Posted 2006) [#1]
Is there a really neat way to recursively search all (every file and folder) the hard disks of a machine (and just the hard disks, no floppy drives, CD Drives, etc)?

I'm doing an app that checks a bunch and updates a bunch of mods if necessary. The app is aimed at a very low-tech audience who may well not even know where their main app is installed so I want my app to find the most likely place (based on the location of a main .exe and a few other files) and give the user a browse button to change it.

Is there a way in Blitz to distguish between a CDROM drive and a Hard Disk?

Has anyone done a nice hard disk search?

Thanks,

Darkheart


Andres(Posted 2006) [#2]
Here's a function that lists up all the folder's content (including subfolders):
Type file
	Field path$, file%, folderread%, size%, treeview%
End Type

Function ReadFolder(folder$)
	Delete Each file
	Local TFiles% = 0
	
	this.file = New file
		this\path$ = ""
		this\file% = 0
		this\folderread% = 0
		
	Repeat
		For this.file = Each file
			UnreadFolders =  0
			If this\file = 0 Then
				If this\folderread = 0 Then
					UnreadFolders =  1
					dir% = ReadDir(folder$ + this\path$)
					If dir%
						While True
							file$ = NextFile$(dir%)
							If file$ = "" Exit
							If Not file$ = "." Or file$ = ".."
								TFiles = TFiles + 1
								
								; New entry
								that.file = New file
									that\path$ = this\path$ + "\" + file$
									that\file = 2 - FileType(folder$ + "\" + this\path$ + "\" + file$)
									that\folderread = 0
									If that\file = 1 Then that\size = FileSize(folder$ + "\" + this\path$ + "\" + file$)
								; End of new entry
								
							EndIf
						Wend
						this\folderread = True
						CloseDir dir%
					EndIf
				EndIf
			EndIf
		Next
	Until UnreadFolders = 0
End Function



-=Darkheart=-(Posted 2006) [#3]
That's very handy Andres, thank you. If I could only find a way to distguish between a HD and a CDROM I'd be pretty well there.

Darkheart


Andres(Posted 2006) [#4]
For that you'll need to use an external library.


Zster(Posted 2006) [#5]
A quick way to tell the difference would be to try write a file to the disk. CDROMS should be read only. Of course this isn't fullproof.


Alaric(Posted 2006) [#6]
Hmm... I remember that the CD writing userlib had a way to tell if it was a CD drive or not... Hope I pointed you in the right direction


Pineapple(Posted 2006) [#7]
Me and Jim have a couple of ways that let you check what drives are on your system!

Both different, but achieve the same job!

check the archives, mines here:-

http://www.blitzbasic.com/codearcs/codearcs.php?code=1589

CD-Burning:-

http://www.blitzbasic.com/codearcs/codearcs.php?code=1599

Dabz