mikev
13 years agoContributor
File, Directories and Comparisons
New to TC, migrating from QTP. We have the following functions that we used quite heavily in QTP:
CompareFiles - Compares two files for differences. Doesn't matter if the file is binary or not. If the file is ASCII, and there is a mismatch, and difference file (HTML report) is generated. If it's Binary, we just want to know that it was different.
FileIsBinary - Returns True or False. Used in CompareFiles above.
CompareDirectoryContents - Compares the contents (not the files) of a directory. File names, directories, etc.
CompareDirectoryFiles - Compares all files in a single directory.
CompareDirectoryFilesRecursive - Compares all files in all directories, given the parent.
In the research that I've done so far, TC makes it pretty easy (I think) to do these kinds of things as long as the file(s) themselves are in the Store. I can't do that, as some of the directories that I need to compare have over 10,000 (not a typo) files in them. In addition, one of the things that I do in the above functions is to check the hashmap. I didn't/don't see how to do that in TC. Actually, we used MD5 for that, but I don't think I can create a TC CreateObject, as it's only for an OCR Object. I already have some 3rd party applications to actually compare the files and create a nice difference file, and I'll certainly make use of them.
I'm more than willing to take on these functions (and certainly post them here for others to use) as I get them done, but I'm curious to see if others have already dones something similar (and are willing to share), and if there's a way that I can do the same kinds of things that are already provided by TC. I'm aware of the aqFiles object.
Anyone have any pointers or code to share?
CompareFiles - Compares two files for differences. Doesn't matter if the file is binary or not. If the file is ASCII, and there is a mismatch, and difference file (HTML report) is generated. If it's Binary, we just want to know that it was different.
FileIsBinary - Returns True or False. Used in CompareFiles above.
CompareDirectoryContents - Compares the contents (not the files) of a directory. File names, directories, etc.
CompareDirectoryFiles - Compares all files in a single directory.
CompareDirectoryFilesRecursive - Compares all files in all directories, given the parent.
In the research that I've done so far, TC makes it pretty easy (I think) to do these kinds of things as long as the file(s) themselves are in the Store. I can't do that, as some of the directories that I need to compare have over 10,000 (not a typo) files in them. In addition, one of the things that I do in the above functions is to check the hashmap. I didn't/don't see how to do that in TC. Actually, we used MD5 for that, but I don't think I can create a TC CreateObject, as it's only for an OCR Object. I already have some 3rd party applications to actually compare the files and create a nice difference file, and I'll certainly make use of them.
I'm more than willing to take on these functions (and certainly post them here for others to use) as I get them done, but I'm curious to see if others have already dones something similar (and are willing to share), and if there's a way that I can do the same kinds of things that are already provided by TC. I'm aware of the aqFiles object.
Anyone have any pointers or code to share?