Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DBF of Volumes/Directory/Files

Usefull Functions & Procedures

DBF of Volumes/Directory/Files

by  dgrewe  Posted    (Edited  )
*/*********************************************************
*# Directory to DataBaseFile
*/Program : Function Dir2Dbf
*/System : Fox Library
*/Purpose : Places All Default Directory Files into a database called FILES.DBF
*/ : Places All Directories off the default directory in a database called DIRECTRY.DBF
*/ : Places All Computers Drives (Hard, Logical and Network) in a database called DRIVES.DBF
*/Syntax : Integer = dir2dbf(Files, Directorys, Drives, Local, TestMode)
*/Returns : Integer - The number of files in the directory
*/Parameter : File - Logical - Create FILES.DBF
*/ : Dire - Logical - Create DIRECTRY.DBF
*/ : Driv - Logical - Create DRIVES.DBF
*/ : Loca - Location to place Files
*/ : Test - Logical - Run in Debug mode
*/Defaults : Local = "C:\temp\"
*/ : All other Parameters Not Passed Are Set to False
*/Requires : Nothing
*/Changes : the contents of Files.dbf, Directry.dbf and Drives.dbf
*/Calls : Nothing
*/Version : 1.0
*/Dated : 10 July 1989
*/Written By: David W. Grewe
*/**********************************************************
*& Utility - Program
*/**********************************************************
*/ Record Of Change
*/
*/**********************************************************
PARAMETERS plFile, plDire, plDriv, pcLocal, plTest
*
* Check Parameters passed to function
*
IF plTest
SET STEP ON
ENDIF
IF EMPTY(pcLocal) OR PARAMETERS() < 4
pcLocal = "C:\Temp\"
ENDIF
*
* Set Local Memvars
*
LOCAL lcDefaultDir,lnDir2Dbf,lnSelect,lcOnError
lcDefaultDir = ""
lnDir2Dbf = 0
lnSelect = SELECT(0)
lcOnError=ON("ERROR")
DIMENSION laFiles(1,5)
*
* Create the directory to place the files in
*
IF !DIRECTORY(pcLocal)
lcDefaultDir = SYS(5) + SYS(2003)
ON ERROR *
MKDIR &pcLocal
ON ERROR &lcOnError
ENDIF
*
* Create Table of File is Directory
*
IF plFile = .t.
=deltables("FILES")
lnDir2Dbf = adir(laFiles , "*.*")
=ASORT(laFiles,1)
SELECT 0
CREATE TABLE (pcLocal+"FILESDBF.DBF") (NAME c(50), SIZE n(10,0), DATE d, TIME c(8), ATTRIB c(4), DIRECTORY c(50))
APPEND FROM ARRAY laFiles
SORT TO (pcLocal+"FILES.DBF") ON NAME FOR FILESDBF.SIZE > 1
USE IN FILESDBF
DELETE FILE(pcLocal+"FILESDBF.DBF")
ENDIF
*
* Create Table of Directories
*
IF plDire = .t.
=deltables("DIRECTORY")
SELECT 0
CREATE TABLE (pcLocal+"FILESDBF.DBF") (NAME c(50), SIZE n(10,0), DATE d, TIME c(8), ATTRIB c(4), DIRECTORY c(50))
lnDir2Dbf= ADIR(laFiles , "*" , "D")
=ASORT(laFiles,1)
APPEND FROM array laFiles
DELETE ALL FOR SIZE > 1
DELETE ALL FOR NAME = "."
SET DELETED ON
SORT TO (pcLocal+"DIRECTRY.DBF") ON NAME FOR NOT DELETED()
USE (pcLocal+"DIRECTRY.DBF")
lnDir2Dbf= reccount()
USE
DELETE FILE(pcLocal+"FILESDBF.DBF")
ENDIF
*
* Create table of Drive letters
*
IF plDriv = .t.
DelTables("DRIVES")
SELECT 0
CREATE TABLE (pcLocal+"DRIVES.DBF") (LETTER c(1), LABEL c(15))
FOR I = 65 TO 90
lnType = DRIVETYPE(CHR(i)+":")
IF lnType<>1
=ADIR(laFiles , chr(i)+":" , "DV")
APPEND BLANK
replace LETTER WITH CHR(i)
replace LABEL WITH laFiles(1)
ENDIF
ENDFOR
lnDir2Dbf= RECCOUNT()
USE IN DRIVES
ENDIF
*
* Clean up
*
SELECT (lnSelect)
RELEASE laFiles
RELEASE lnSelect,lcDefaultDir
RELEASE plFile, plDire, plDriv, pcLocal, plTest
RETURN lnDir2Dbf
*
*
*
PROCEDURE DELTABLES
LPARAMETERS pcTable
IF USED(pcTable)
SELECT (pcTable)
USE IN (pcTable)
ENDIF
DELETE FILE (pcLocal + pcTable+".DBF")
IF USED("FILESDBF")
SELECT FILESDBF
USE IN FILESDBF
ENDIF
DELETE FILE(pcLocal +"FILESDBF.DBF")
RETURN


Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top