mirror of https://github.com/odrling/Aegisub
Originally committed to SVN as r2450.
This commit is contained in:
parent
d8a85d0118
commit
7a9c85d577
|
@ -94,6 +94,7 @@ public:
|
||||||
controller->LoadFile(fileFolder+"out_test1.ass","UTF-8");
|
controller->LoadFile(fileFolder+"out_test1.ass","UTF-8");
|
||||||
CPPUNIT_ASSERT_NO_THROW(controller->SaveFile(fileFolder+"out_test2.ass","UTF-8"));
|
CPPUNIT_ASSERT_NO_THROW(controller->SaveFile(fileFolder+"out_test2.ass","UTF-8"));
|
||||||
CPPUNIT_ASSERT(AreFilesIdentical(fileFolder+"out_test1.ass",fileFolder+"out_test2.ass"));
|
CPPUNIT_ASSERT(AreFilesIdentical(fileFolder+"out_test1.ass",fileFolder+"out_test2.ass"));
|
||||||
|
CPPUNIT_ASSERT(AreFilesIdentical(fileFolder+"in_test1.ass",fileFolder+"out_test1.ass") == false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -33,14 +33,42 @@
|
||||||
// Contact: mailto:zeratul@cellosoft.com
|
// Contact: mailto:zeratul@cellosoft.com
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "../../aegisub/md5.h"
|
||||||
|
|
||||||
|
|
||||||
bool AreFilesIdentical(std::string file1, std::string file2)
|
bool AreFilesIdentical(std::string file1, std::string file2)
|
||||||
{
|
{
|
||||||
return GetFileMD5(file1) == GetFileMD5(file2);
|
std::string f1 = GetFileMD5(file1);
|
||||||
|
std::string f2 = GetFileMD5(file2);
|
||||||
|
return f1 == f2;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetFileMD5(std::string file) {
|
std::string GetFileMD5(std::string file) {
|
||||||
|
md5_state_s md5;
|
||||||
|
md5_byte_t digest[16];
|
||||||
|
const size_t toRead = 512;
|
||||||
|
md5_byte_t data[toRead];
|
||||||
|
|
||||||
|
std::ifstream fp(file.c_str());
|
||||||
|
if (fp.is_open()) {
|
||||||
|
md5_init(&md5);
|
||||||
|
|
||||||
|
while (!fp.eof()) {
|
||||||
|
fp.read((char*)data,toRead);
|
||||||
|
size_t n = fp.gcount();
|
||||||
|
md5_append(&md5,data,n);
|
||||||
|
}
|
||||||
|
|
||||||
|
md5_finish(&md5,digest);
|
||||||
|
unsigned int *res = (unsigned int*) digest;
|
||||||
|
return std::string(wxString::Format(_T("%08X%08X%08X%08X"),res[0],res[1],res[2],res[3]).mb_str(wxConvUTF8));
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -176,14 +176,6 @@
|
||||||
RelativePath=".\src\suites.h"
|
RelativePath=".\src\suites.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\src\utils.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\utils.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Athenasub"
|
Name="Athenasub"
|
||||||
|
@ -201,6 +193,26 @@
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Utils"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="..\aegisub\md5.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\aegisub\md5.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\utils.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\utils.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
</Globals>
|
</Globals>
|
||||||
|
|
Loading…
Reference in New Issue