Title: Message
A couple of comments and suggestions:
 
- Check the coding guidelines for the coding style:
      - use spaces
      - opening curly braces go on the same line with the if (), else, or while ()
- By using StreamReader, aren't you taking on on the cost of decoding the bytestream into a character stream ?
- How do you deal with binary files?
- What happens if comparefile is ANSI while difffile is UNICODE ? I'm guessing that your comparison of thisFileContents != thatFileContents StreamReader may say that they are the same, even though the files are physically different.
- What happens when you are comparing two 20 MB files? Will there be enough memory to hold these two strings?
- the variable named "isAMatch" seems to be a misnomer. As I read the code, it seems to say that the files are a match when the contents are not equal.
- the if statement clauses seem backwards based on "isAMatch". It says that the files are different if isAMatch is true.
- thatSR.Close() is outside the foreach loop. I think it should be inside.
- constructing a FileInfo to be used just in verbose logging seems like a waste.
 
[There's also the corner case of alternate streams on Win32. Do you need to compare those streams as well. I think most people just ignore this.]
 
- May I suggest using the Stream class and just computing the MD5 hash of each of the files you are comparing. A quick shortcut maybe inspecting the filesizes first before investing into actual computing the hash.
 
- Ants
 
 
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Reed
Sent: Friday, 05 September, 2003 15:16
To: [EMAIL PROTECTED]
Subject: [nant-dev] Who's the happy moderator who ate my <if /> task post? :)

I'll just paste the message below without the happy patch (since it violated some arbitrary post length limit) so that I can get your feedback on its utility for others.  If I'm not shouted down, somebody can suggest a good method for getting the patch out there, if the attachment vanishes.

 

 

-----Original Message-----
From: David Reed
Sent: Thursday, September 04, 2003 1:15 AM
To: NAnt Developers ([EMAIL PROTECTED])
Subject: IfTask for file contents comparison?

 

Maybe this isn't the right way to do this, but I needed to be able to compare file contents (not just timestamps), and I couldn't find another way to do this comparison with existing code.  School me if I'm just lost.  :)

 

I'm proposing the addition of an attribute called difffile to if/ifnot which will work with the attribute comparefile (or the element comparefiles, which is just collateral damage to me) to determine whether the contents of difffile matches the contents of comparefile.

 

I'm happy with the way it's working for me, but I'm open to suggestions that will make it more ubiquitous if somebody's got a better idea than this patcheroo.  My documentation sux, sorry; I'm learnin' better XML commentary and NDoc sometime next month.

 

Reply via email to