home *** CD-ROM | disk | FTP | other *** search
Wrap
/* Program to use ADPro to check a whole directory of files, including subdirectories. A text file listing all dud files found is created. Each directory is tested twice: in the first pass, each file is simply read; in the second, it is loaded into ADPro to see if it is a valid bitmap. Files with endings such as .info or .pfb which are not used for bitmaps are not checked in this second pass. If ADPro jams up while trying to load in a binary file which it thinks (wrongly) is a Targa or PCX image, just click on Abort. */ /* Written by Don Cox, August 95. Copyright, not Public Domain. */ /* $VER:FileTester.adpro Aug 95 */ /* Be careful about tracing this as it can easily fill up Ram: */ /*call open("STDERR","ram:traceFT","W") trace r*/ options results address "ADPro" ADPRO_TO_FRONT getdir '"Select directory containing files to test"' if rc=10 then exit directory = ADPro_Result if upper(directory) = "RAM DISK:" then directory = "Ram:" getdir '"Select directory for temporary files"' '"ram:"' if rc=10 then exit tdirectory = ADPro_Result if upper(directory) = "RAM DISK:" then directory = "Ram:" if right(tdirectory,1) ~=":" then tdirectory = tdirectory||"/" getfile '"Select file for listing dud files..."' if rc~=0 then do okay1 "No file selected" exit end logfile = ADPro_result ILBMonly = 1 OKAYN '"Which files to check"' '"Check bitmaps..."' '"ILBM only|GIF only|All files"' retc = rc select when retc = 0 then ILBMonly = 0 when retc = 1 then ILBMonly = 1 when retc = 2 then ILBMonly = 2 end lformat "UNIVERSAL" load_type "REPLACE" filecount = 0 dudfilecount1 = 0 dudfilecount2 = 0 /* Check all files in one directory and its descendents */ message = "Listing Files ..." DISPLAYMESSAGE '"'message'"' call open('dudlogfile',logfile,'W') address command 'resident c:copy' 'resident c:delete' 'list >ram:dirlist 'directory' dirs all LFORMAT="%P%S"' call open("dirinput","ram:dirlist","r") /* First check pics in root diectory */ 'delete ram:filelist1' 'delete ram:filelist' 'list >ram:filelist1 'directory' files LFORMAT="%P%S"' call open(input,"ram:filelist1","r") /* test in case it's empty */ listtest = readln(input) call close input if listtest~="" then do 'sort from ram:filelist1 to ram:filelist' address "ADPro" call dircheck end /* Now do all the subdirectories */ do d = 1 to 700 directory = readln("dirinput") if directory = "" then break address command 'delete ram:filelist1' 'delete ram:filelist' 'list >ram:filelist1 'directory' files LFORMAT="%P%S"' call open(input,"ram:filelist1","r") /* test in case it's empty */ listtest = readln(input) call close input if listtest~="" then do 'sort from ram:filelist1 to ram:filelist' address "ADPro" call dircheck end end call close('dudlogfile') address "ADPro" ADPRO_TO_FRONT DISPLAYMESSAGE message = "Done: checked "filecount" files. "dudfilecount1" (pass 1) & "dudfilecount2" (pass2) dud files." OKAY1 "'"message"'" exit end /* ++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++ */ getpath: parse arg allname pos1 = lastpos("/",allname) if pos1 = 0 then pos1 = lastpos(":",allname) filepath = left(allname,pos1) return filepath getname: parse arg allname pos1 = lastpos("/",allname) if pos1 = 0 then pos1 = lastpos(":",allname) justname = substr(allname,pos1+1) return justname /* +++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++ */ /* Check all the pics in a directory */ dircheck: /* first just copy files to Ram: to see if OK */ call open(input,"ram:filelist","r") address command call writeln('dudlogfile'," ") logline = "First pass - copy all files in "directory" to temporary directory " call writeln('dudlogfile',logline) call writeln('dudlogfile',"++++++++++++++++++") do i = 1 to 7000 /* safety limit of 7000 files */ filename = readln(input) if filename = "" then break if filename==logfile then iterate address 'ADPro' message = "First Pass: "filename DISPLAYMESSAGE '"'message'"' address command if word(filename,2) = "files" then iterate /* This line not a file name */ if word(filename,1) = "TOTAL:" then break /* or this one */ filecount = filecount+1 'copy "'filename'" to 'tdirectory'testfile' success = rc if success~=0 then do call writeln('dudlogfile',"'"filename"'") dudfilecount1 = dudfilecount1+1 end 'delete 'tdirectory'testfile' end /* Now check if they are valid pictures, loadable by ADPro */ call seek(input,0,"B") address 'ADPro' load_type "REPLACE" lformat "UNIVERSAL" call writeln('dudlogfile'," ") call writeln('dudlogfile',"++++++++++++++++++") logline = "Second pass - load bitmap files in "directory" into ADPro " call writeln('dudlogfile',logline) call writeln('dudlogfile',"++++++++++++++++++") do i = 1 to 7000 /* safety limit of 7000 files */ filename = readln(input) if filename = "" then break if filename==logfile then iterate if upper(right(filename,5)) = ".INFO" then iterate if upper(right(filename,7)) = ".PSFONT" then iterate if upper(right(filename,5)) = ".FONt" then iterate if upper(right(filename,7)) = ".PDFONT" then iterate if upper(right(filename,4)) = ".PFB" then iterate if upper(right(filename,4)) = ".AFM" then iterate if upper(right(filename,7)) = ".METRIC" then iterate if upper(right(filename,4)) = ".LIB" then iterate if upper(right(filename,4)) = ".DEM" then iterate if upper(right(filename,4)) = ".DOC" then iterate if upper(right(filename,4)) = ".ZIP" then iterate if upper(right(filename,4)) = ".LHA" then iterate if upper(right(filename,4)) = ".ARC" then iterate if upper(right(filename,3)) = ".ME" then iterate if upper(right(filename,4)) = ".DAT" then iterate if upper(right(filename,3)) = "HLP" then iterate if upper(right(filename,4)) = ".ISH" then iterate if upper(right(filename,5)) = ".ICAT" then iterate if upper(right(filename,3)) = ".TF" then iterate if upper(right(filename,3)) = ".DB" then iterate if upper(right(filename,2)) = ".C" then iterate if upper(right(filename,2)) = ".H" then iterate if upper(right(filename,3)) = ".GF" then iterate if upper(right(filename,5)) = ".PPRX" then iterate if upper(right(filename,5)) = ".PDRX" then iterate if upper(right(filename,5)) = ".REXX" then iterate if upper(right(filename,6)) = ".ADPRO" then iterate if upper(right(filename,5)) = ".STEN" then iterate /* Brilliance Stencil file - crashes ADPro */ if word(filename,2) = "files" then iterate /* This line not a file name */ if word(filename,1) = "TOTAL:" then break /* or this one */ message = "Second Pass: "filename DISPLAYMESSAGE '"'message'"' call open("input",filename,"R") success = rc if success ~= 0 then iterate filetype = right(readch("input",12),4) call close("input") if (ILBMonly = 1 & filetype ~= "ILBM") then iterate if (ILBMonly = 2 & upper(right(filename,4)) ~= ".GIF") then iterate load '"'filename'"' /* Quotes allow file names with spaces */ if rc ~=0 then do /* if load fails, log it */ call writeln('dudlogfile',filename) dudfilecount2 = dudfilecount2+1 message = "Second Pass: "filename" - *** not a valid bitmap ***" DISPLAYMESSAGE '"'message'"' end end /* end of directory */ call close(input) ADPRO_UNDISPLAY return