#include "StdAfx.h" #include "DiffEngine.h" #include "diff.h" //#include "filesys.h" p4dn::DiffEngine::DiffEngine() { _encoding = System::Text::Encoding::GetEncoding(1252); } array<System::String^>^ p4dn::DiffEngine::RunDiff (IO::FileInfo^ f1, IO::FileInfo^ f2) { List<String^> output = gcnew List<String^>(); ::Error* e = new ::Error(); // // Duck binary files. Much the same as ClientUser::Diff, we just // put the output into Ruby space rather than stdout. // // if( !f1->IsTextual() || !f2->IsTextual() ) // { //if ( f1->Compare( f2, e ) ) //{ // output.Add("(... files differ ...)"); // //OutputInfo( 0, "(... files differ ...)" ); //} //return; // } // Time to diff the two text files. Need to ensure that the // files are in binary mode, so we have to create new FileSys // objects to do this. ::FileSys *f1_bin = FileSys::Create( ::FST_BINARY ); ::FileSys *f2_bin = FileSys::Create( ::FST_BINARY ); StrBuf f1_name, f2_name; P4String::StringToStrBuf(&f1_name, f1->FullName, _encoding); P4String::StringToStrBuf(&f2_name, f2->FullName, _encoding); f1_bin->Set(f1_name); f2_bin->Set(f2_name); ::FileSys *t = FileSys::CreateGlobalTemp(::FST_TEXT ); StrBuf flags; P4String::StringToStrBuf(&flags, _flags, _encoding); { // // In its own block to make sure that the diff object is deleted // before we delete the FileSys objects. // ::Diff d; ::DiffFlags diffFlags(&flags); d.SetInput( f1_bin, f2_bin, diffFlags, e ); if ( ! e->Test() ) d.SetOutput( t->Name(), e ); if ( ! e->Test() ) d.DiffWithFlags( diffFlags ); d.CloseOutput( e ); // OK, now we have the diff output, read it in and add it to // the output. if ( ! e->Test() ) t->Open( FOM_READ, e ); if ( ! e->Test() ) { StrBuf b; //while( t->ReadLine( &b, e ) ) //OutputInfo(0, b.Text() ); } } delete t; delete f1_bin; delete f2_bin; delete e; //if ( e->Test() ) HandleError( e ); return output.ToArray(); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 7341 | Erik Purins |
p4.net --- pull p4.net#head |
||
//guest/shawn_hladky/P4.Net/main/src/p4dn/DiffEngine.cpp | |||||
#1 | 6506 | Shawn Hladky | P4.Net: forgot to add 2 files |