fixed mod property names and added unit test for xm

This commit is contained in:
Mathias Panzenböck
2011-06-18 03:31:49 +02:00
parent fe356c31b4
commit 5ad69f6f2a
18 changed files with 257 additions and 146 deletions

View File

@ -9,7 +9,9 @@
#include <sys/fcntl.h>
#endif
#include <stdio.h>
#include <string.h>
#include <string>
#include <fstream>
using namespace std;
@ -45,6 +47,35 @@ inline void deleteFile(const string &filename)
remove(filename.c_str());
}
inline bool fileEqual(const string &filename1, const string &filename2)
{
char buf1[BUFSIZ];
char buf2[BUFSIZ];
ifstream stream1(filename1.c_str(), ios_base::in | ios_base::binary);
ifstream stream2(filename2.c_str(), ios_base::in | ios_base::binary);
if(!stream1 && !stream2) return true;
if(!stream1 || !stream2) return false;
for(;;)
{
stream1.read(buf1, BUFSIZ);
stream2.read(buf2, BUFSIZ);
streamsize n1 = stream1.gcount();
streamsize n2 = stream2.gcount();
if(n1 != n2) return false;
if(n1 == 0) break;
if(memcmp(buf1, buf2, n1) != 0) return false;
}
return stream1.good() == stream2.good();
}
class ScopedFileCopy
{
public: