1. Verify01.exw Al
- Posted by don cole <doncole at p?cbel?.net> Jul 19, 2007
- 691 views
Hello Al, Your code in verify01 compares a path and file with a drive letter. I am attempting to use your code in my windows format Compare.exw. How can I replaced the drive letter with a path and file? I tried and I get: Comparing root paths: F:\euphoria\clean\clean.exw F:\euphoria\clean\clean.exw problem file: F:\euphoria\clean\clean.exwclean.exw Just like that. No typo here. I should get no errors as they are the same file. Don Cole
2. Re: Verify01.exw Al
- Posted by Al Getz <Xaxo at aol.c??> Jul 19, 2007
- 693 views
don cole wrote: > > > Hello Al, > > Your code in verify01 compares a path and file with a drive letter. > I am attempting to use your code in my windows format Compare.exw. > > How can I replaced the drive letter with a path and file? I tried and I get: > > Comparing root paths: > F:\euphoria\clean\clean.exw > F:\euphoria\clean\clean.exw > > problem file: F:\euphoria\clean\clean.exwclean.exw > > Just like that. No typo here. > > I should get no errors as they are the same file. > > > Don Cole Hi Don, Here is a new Verify01.exw file. I'm going to call it Verify02.exw now. You already have all the required include files. I'll try posting it here but you'll have to watch out for line wraps so you might have to fix a few lines. If this doesnt work i'll either send you the file or upload to the archive. Take care, Al E boa sorte com sua programacao Euphoria! My bumper sticker: "I brake for LED's" From "Black Knight": "I can live with losing the good fight, but i can not live without fighting it". "Well on second thought, maybe not." [eucode] --Written by Al Getz 04/2007, updated 07/2007. --Use this when the two root directory names are different, such --as: --"C:\\download\\" and --"C:\\Euphoria\\" --The second path above can have a different drive letter too. --This compares directories and file bytes of two directories --on the same drive or different drives. --Note this reports missing files and directories in the 'B' dir --but will not report files that appear in the B dir that do not --appear in the A dir. This is mainly to compare hard drive --directories with CD drive directories after a CD write of --those directories as in a backup, or to compare two directories --on the hard drive when the second directory is a backup. --This algorithm compares bytes counts before comparing each byte --to save time when lots of files are different. It will not go --through an entire 100MB file to find out the other file has 101MB, --but will immediately report that the files are different. --To use, enter (below) RootDirNameA and the CD drive letter in DriveLetterB --and make RootPathB="", or simply enter the new entire path in RootPathB. -- Note paths on CD drive must have the same names as those -- on the hard drive, except for the drive letter, if the drive letter -- method is used. If RootPathB is used, the root directories can -- have any names. --If you are using a program launcher of any kind be sure to specify the -- working directory as well as the program path. The working directory -- will be the same directory as this exw file is located in. --Possible Report.txt error messages: -- (note the A dir is the main directory, the B dir is the backup or copy, and -- the A file resides under the A dir while the B file resides under the B dir) -- 1. "Could not find file" (the file in the A dir could not be found in the B dir) -- 2. "Bytes different in file" (A and B files have same number of bytes, but at least -- one byte is different) -- 3. "Bytes count different in file" (one file has more or less bytes than the other) -- 4. "Could not find dir" (one complete directory could not be found in the B dir) -- The following error messages can only occur if one or more files have been -- modified *AFTER* this program has been started. Of course this practice is -- not recommended. -- 5. "Could not open" (could not find the file in the directory) -- 6. "More bytes in file" (more bytes in file B than in file A) -- 7. "Not enough bytes to read in" (less bytes in file B than in file A) -- Note that a totally blank Report.txt file (after program finishes) means -- no changed files or directories have been found. --Basic program operation: --Make a list of all the directories in both root paths, then go through the A dir --directories (and files) one by one looking for directories in the B dir. Once each --dir is found, go through each file one by one comparing bytes count and if necessary --comparing each and every byte for equality. Files in the root directories are --compared also. --If any inconsistancies are found they are printed to the file "Report.txt" --that resides in the same directory as this exw file. The types of problems --that can come up are listed above (1 through 7). include misc.e include sort.e include GetDirsB.e object AllDirNamesA,AllDirNamesB integer ndirs sequence RootDirNameA,RootDirNameB,RootPathB integer DriveLetterB atom fnReport constant ReportFileName="Report.txt" --program makes a report about missing or changed files constant BackupFileListName="BackupList.txt" --program makes a backup file path list procedure printf_report(sequence formatstring, sequence info) --prints the report file and the backup list file atom fn integer n sequence name1,name2,dirnameA n=info[1] if n=1 then name1=info[2] name2=info[3] else name1=info[3] name2=info[2] end if printf(1,"\nproblem file: %s\n",{name1}) fn=open(ReportFileName,"a") printf(fn,formatstring,{name1}) close(fn) fn=open(BackupFileListName,"a") name1=info[2] name2=info[3] if length(name2)=0 then dirnameA=name1[length(RootDirNameA)+1..length(name1)] name2=RootPathB&dirnameA end if printf(fn,"%s\n",{name1}) printf(fn,"%s\n\n",{name2}) close(fn) return end procedure --//////////////////////////////////////////////////////////////////// -- USER ENTERS DATA HERE --enter root dir on drive C, and drive letter for the CD drive, --or use alternate method by entering both root dir names... --the root directory typically on the hard drive: RootDirNameA="C:\\Euphoria\\Projects\\VerifyCD\\CD1\\" --the root directory drive letter to compare (typically the CD drive letter): -- (note dirs must have same names, different drive letter when using this method) DriveLetterB='i' --make this next sequence null "" to use drive letter above alone, --or else specify the entire root path and ignore drive letter above. --This path is typically on the CD or in the backup directory... RootPathB="C:\\Euphoria\\Projects\\VerifyCD\\CD2\\" --The above example would compare RootDirNameA to RootPathB, going through all the --sub directories as well as the root directory. -- END OF USER ENTERED DATA SECTION --//////////////////////////////////////////////////////////////////// --makes sure both root paths end with a backslash: if RootDirNameA[length(RootDirNameA)]!='\\' then RootDirNameA=RootDirNameA&'\\' end if if RootPathB[length(RootPathB)]!='\\' then RootPathB=RootPathB&'\\' end if --compute the CD drive root dir: (only used with drive letter method) RootDirNameB=RootDirNameA RootDirNameB[1]=DriveLetterB --use the second path if it is not null: if length(RootPathB)>0 then RootDirNameB=RootPathB end if printf(1,"RootDirNameA: %s\n",{RootDirNameA}) printf(1,"RootDirNameB: %s\n",{RootDirNameB}) atom uDriveLetterB uDriveLetterB=upper(RootDirNameB[1]) printf(1,"Starting... %s\n",{""}) printf(1,"Comparing root paths: %s\n",{""}) printf(1," %s\n",{RootDirNameA}) printf(1," %s\n\n",{RootDirNameB}) AllDirNamesA=GetDirs(RootDirNameA) AllDirNamesB=GetDirs(RootDirNameB) ndirs=length(AllDirNamesA) printf(1,"Total number of Dirs to verify: %d\n",{ndirs}) printf(1,"See 'Report.txt' for any problem files. %s\n\n",{""}) sleep(1) fnReport=open(ReportFileName,"w") close(fnReport) fnReport=open(BackupFileListName,"w") printf(fnReport,"%s\n\n",{" Backup File List (no files here means no files"& " have changed,\n while a terminating backslash means the entire directory"& "has to be backed up):"}) close(fnReport) --look through all the dirs to see if any files are different --in bytes... sequence dirnameA,dirnameB,udirnameA,filenameA,ufilenameA,filenameB sequence FileListA,FileListB,attribs sequence uRootPathA,uRootPathB,udirnameB atom fnA,fnB,binA,binB, BytesA,BytesB integer founddir,problems,foundfile,nFiles atom t,fps,minfps uRootPathA=upper(RootDirNameA) uRootPathB=upper(RootDirNameB) problems=0 for k=1 to ndirs do printf(1,"Doing Dir Number: %d of %d\n",{k,ndirs}) founddir=0 dirnameA=AllDirNamesA[k] printf(1,"dirnameA: %s\n",{dirnameA}) udirnameA=upper(dirnameA) udirnameA=udirnameA[length(uRootPathA)+1..length(udirnameA)] for j=1 to length(AllDirNamesB) do dirnameB=AllDirNamesB[j] udirnameB=upper(dirnameB) udirnameB=udirnameB[length(uRootPathB)+1..length(udirnameB)] if equal(udirnameA,udirnameB) then --found dirname, now do files founddir=1 FileListA=dir(dirnameA) FileListB=dir(dirnameB) FileListA=sort(FileListA) FileListB=sort(FileListB) nFiles=0 t=time() minfps=1e10 for h=1 to length(FileListA) do if h/5=floor(h/5) then t=time()-t if t=0 then fps=1000 else fps=5/t end if if fps<minfps then minfps=fps end if --print: #of files done, files per second, and min files per second printf(1,"File: %d files/second: %3.2f minfps=%3.2f ",{h,fps,minfps}) puts(1,13) t=time() if h=5 then minfps=1e10 end if end if attribs=FileListA[h][2] if find('d',attribs) then --skip dir names else nFiles+=1 filenameA=FileListA[h][1] ufilenameA=upper(filenameA) foundfile=0 for i=1 to length(FileListB) do attribs=FileListB[i][2] if find('d',attribs) then --skip dir names else filenameB=FileListB[i][1] if equal(ufilenameA,upper(filenameB)) then foundfile=1 --compare bytes counts before checking all individual bytes: BytesA=FileListA[h][D_SIZE] BytesB=FileListB[i][D_SIZE] if BytesA!=BytesB then --the files are different simply because they have a different number of bytes fnA=0 fnB=0 printf_report("Bytes count different in: %s\n",{2,dirnameA&filenameA,dirnameB&filenameB}) problems+=1 exit end if --if byte count is the same then compare all byte values... fnA=open(dirnameA&filenameA,"rb") fnB=open(dirnameB&filenameB,"rb") if fnA<1 then printf_report("Could not open: %s\n",{1,dirnameA&filenameA,""}) problems+=1 exit end if if fnB<1 then printf_report("Could not open: %s\n",{2,"",dirnameB&filenameB}) problems+=1 exit end if if fnA>1 and fnB>1 then --compare file bytes while 1 do binA=getc(fnA) if binA<0 then --done comparing this file with the backup binB=getc(fnB) if binB>0 then printf_report("More bytes in file: %s\n",{2,dirnameA&filenameA,dirnameB&filenameB}) problems+=1 end if exit else binB=getc(fnB) if binB<0 then printf_report("Not enough bytes to read in: %s\n",{2,dirnameA&filenameA,dirnameB&filenameB}) problems+=1 exit else if binA=binB then --both bytes the same so continue else printf_report("Bytes different in file: %s\n",{2,dirnameA&filenameA,dirnameB&filenameB}) problems+=1 exit end if end if end if end while --1 end if --fnA and fnB if fnA>0 then close(fnA) end if if fnB>0 then close(fnB) end if end if end if end for if not foundfile then printf_report("Could not find file: %s\n",{1,dirnameA&filenameA,""}) problems+=1 end if end if end for --h printf(1,"\nFiles checked: %d\n",nFiles) exit end if end for if not founddir then printf_report("Could not find dir: %s\n",{1,dirnameA,""}) problems+=1 end if end for printf(1,"\nProblem files or directories found: %d\n",{problems}) -- print time in minutes: printf(1,"Time to complete: %8.1f minutes.\n", time()/60) printf(1,"\n%s\n",{"Close console to exit..."}) sleep(500000) --user will close out console to exit program [/eucode]
3. Re: Verify01.exw Al
- Posted by Al Getz <Xaxo at aol?c?m> Jul 19, 2007
- 677 views
- Last edited Jul 20, 2007
Don, Sorry i didnt understand your question quite right as i read it too fast. I thought you were asking about how to enter two paths that were different. My program was made to compare whole *directories*, not individual files. You enter two paths but the paths are directory names such as: c:\download\files\ At present, you cant point to an individual file unless you use a trick. If you dont feel like updating it to do that, if you really want to compare two files, then one thing you can do is to copy the two files into two temp directories. You can then point to those directories. See, when i made this program i wanted it to be able to dig down into sub directories to compare all the files, given only the root directory names. Take care, Al E boa sorte com sua programacao Euphoria! My bumper sticker: "I brake for LED's" From "Black Knight": "I can live with losing the good fight, but i can not live without fighting it". "Well on second thought, maybe not."
4. Re: Verify01.exw Al
- Posted by don cole <doncole at pacbel?.n?t> Jul 20, 2007
- 681 views
Al Getz wrote: > > Don, > > Sorry i didnt understand your question quite right as i read it > too fast. I thought you were asking about how to enter two paths > that were different. > > My program was made to compare whole *directories*, not individual > files. You enter two paths but the paths are directory names > such as: > c:\download\files\ > > At present, you cant point to an individual file unless you use a trick. > > If you dont feel like updating it to do that, if > you really want to compare two files, then one thing > you can do is to copy the two files into two temp directories. > You can then point to those directories. > > See, when i made this program i wanted it to be able to dig down > into sub directories to compare all the files, given only the > root directory names. > > > Al > > E boa sorte com sua programacao Euphoria! > > > My bumper sticker: "I brake for LED's" > Hello Al, I got that verify02 working with my program. It compares 2 directories and reports the files that are different. It does not however tell you which line numbers in the files are different. I think that's what you just said. I read too fast sometimes also. I could send you what I have but I should email it. It has several includes. Don Cole
5. Re: Verify01.exw Al
- Posted by Al Getz <Xaxo at aol?c?m> Jul 20, 2007
- 722 views
don cole wrote: > > Al Getz wrote: > > > > Don, > > > > Sorry i didnt understand your question quite right as i read it > > too fast. I thought you were asking about how to enter two paths > > that were different. > > > > My program was made to compare whole *directories*, not individual > > files. You enter two paths but the paths are directory names > > such as: > > c:\download\files\ > > > > At present, you cant point to an individual file unless you use a trick. > > > > If you dont feel like updating it to do that, if > > you really want to compare two files, then one thing > > you can do is to copy the two files into two temp directories. > > You can then point to those directories. > > > > See, when i made this program i wanted it to be able to dig down > > into sub directories to compare all the files, given only the > > root directory names. > > > > > > Al > > > > E boa sorte com sua programacao Euphoria! > > > > > > My bumper sticker: "I brake for LED's" > > > > Hello Al, > > I got that verify02 working with my program. It compares 2 directories and > reports the files that are different. It does not however tell you which line > numbers in the files are different. I think that's what you just said. I read > too fast sometimes also. I could send you what I have but I should email it. > It has several includes. > > > Don Cole Hi Don, Im glad you had some luck with it finally. The report does not include any files line numbers because it does a binary compare, not a 'text' or 'line by line' compare. I had it do a binary compare because many of the files are not text files (or euphoria source files) but are instead .exe files, .dll files, etc., with some text files too. I guess what you would want to see is the compare action taken commensurate with the type of file? I guess that's not a bad idea really. We'd have to also supply a list of file extensions and how those files should be handled, but i guess that's not too much work to do. On the other hand, the program would then also have to work with different formats, like .doc and .rtf and be able to handle unicode. Im not sure if i want to get into that myself even though it could be done. Maybe you want to be able to compare Euphoria source files too? For now though it looks like it will compare in binary mode only, however it would not take much to get it to report exactly which byte was different, and then you could go back and open the files and provide a dump of part of the two files. Even so, only the first difference found would be reported as (at least currently) the algo exits at the first difference found just after writing to the report file. Another thing i should mention (and this is written in the file itself in a comment section) is that for two directories, call them A and B (and the variable names reflect this convention with their last letter being A and B respectively), the file names (and directory names) not found in B are reported (B is the backup) but the file names and dir names in B (if there are any) that are not in A are *not* reported. This is because if for some reason you feel like including an extra file in the backup for some reason and you dont really need it on the hard drive, you dont have to skip reading it in the report file. If this is a problem however, it doesnt take much to have the 'missing' A files (and dir names) reported in the report too. BackupList.txt: The other convention used is that file names end with no backslash, while directory names *always* end with a backslash. This is so another program can go through the list in the BackupList.txt file and detect when it has to write an entire directory to disk rather than a single file. Writing an entire directory means writing the root files and every sub directory and all those files too, whereas writing a single missing file is a simple 'copy file'. Take care, Al E boa sorte com sua programacao Euphoria! My bumper sticker: "I brake for LED's" From "Black Knight": "I can live with losing the good fight, but i can not live without fighting it". "Well on second thought, maybe not."
6. Re: Verify01.exw Al
- Posted by don cole <doncole at p?c?ell.net> Jul 21, 2007
- 700 views
Al Getz wrote: > > don cole wrote: > > > > Al Getz wrote: > > > > > > Don, > > > > > > Sorry i didnt understand your question quite right as i read it > > > too fast. I thought you were asking about how to enter two paths > > > that were different. > > > > > > My program was made to compare whole *directories*, not individual > > > files. You enter two paths but the paths are directory names > > > such as: > > > c:\download\files\ > > > > > > At present, you cant point to an individual file unless you use a trick. > > > > > > If you dont feel like updating it to do that, if > > > you really want to compare two files, then one thing > > > you can do is to copy the two files into two temp directories. > > > You can then point to those directories. > > > > > > See, when i made this program i wanted it to be able to dig down > > > into sub directories to compare all the files, given only the > > > root directory names. > > > > > > > > > Al > > > > > > E boa sorte com sua programacao Euphoria! > > > > > > > > > My bumper sticker: "I brake for LED's" > > > > > > > Hello Al, > > > > I got that verify02 working with my program. It compares 2 directories > > and > > reports the files that are different. It does not however tell you which > > line > > numbers in the files are different. I think that's what you just said. I > > read > > too fast sometimes also. I could send you what I have but I should email it. > > It has several includes. > > > > > > Don Cole > > Hi Don, > > > Im glad you had some luck with it finally. > > The report does not include any files line numbers because it does > a binary compare, not a 'text' or 'line by line' compare. I had > it do a binary compare because many of the files are not text files > (or euphoria source files) but are instead .exe files, .dll files, > etc., with some text files too. > I guess what you would want to see is the compare action taken > commensurate with the type of file? I guess that's not a bad idea > really. We'd have to also supply a list of file extensions and > how those files should be handled, but i guess that's not too much > work to do. On the other hand, the program would then also have to > work with different formats, like .doc and .rtf and be able to > handle unicode. Im not sure if i want to get into that myself > even though it could be done. > Maybe you want to be able to compare Euphoria source files too? > > For now though it looks like it will compare in binary mode only, > however it would not take much to get it to report exactly which > byte was different, and then you could go back and open the files > and provide a dump of part of the two files. Even so, only the > first difference found would be reported as (at least currently) > the algo exits at the first difference found just after writing > to the report file. > > Another thing i should mention (and this is written in the file > itself in a comment section) is that for two directories, call > them A and B (and the variable names reflect this convention with > their last letter being A and B respectively), the file names > (and directory names) not found in B are reported (B is the backup) > but the file names and dir names in B (if there are any) that are > not in A are *not* reported. This is because if for some reason > you feel like including an extra file in the backup for some reason > and you dont really need it on the hard drive, you dont have to > skip reading it in the report file. If this is a problem however, > it doesnt take much to have the 'missing' A files (and dir names) > reported in the report too. > > BackupList.txt: > The other convention used is that file names end with no backslash, > while directory names *always* end with a backslash. This is so > another program can go through the list in the BackupList.txt file > and detect when it has to write an entire directory to disk rather > than a single file. Writing an entire directory means writing > the root files and every sub directory and all those files too, > whereas writing a single missing file is a simple 'copy file'. > > > Al > > E boa sorte com sua programacao Euphoria! > > > My bumper sticker: "I brake for LED's" > Thanks Al, Don Cole