#include <ui.h>
Public Member Functions | |
UI (std::ostream &MessageOut) | |
bool | WriteDuplicatesToFile (Dedupe::Core::Duplicates Dups, Dedupe::FilePath PathToFile) |
Dedupe::Core::FilesToProcess | ReadDecidedDuplicatesFromFile (Dedupe::FilePath PathToFile) |
void | SetTitle (std::string FileHeader) |
UI asks the user what to do with founded duplicates
Definition at line 26 of file ui.h.
Dedupe::CLI::UI::UI | ( | std::ostream & | MessageOut | ) |
Dedupe::Core::FilesToProcess Dedupe::CLI::UI::ReadDecidedDuplicatesFromFile | ( | Dedupe::FilePath | PathToFile | ) |
Function reads the duplicates file outputed from the WriteDuplicatesToFile() function and stores the userdecisions into the duplicates object
Definition at line 47 of file ui.cpp.
References Dedupe::Core::HandleDuplicates::Delete, Dedupe::Core::HandleDuplicates::Error, Dedupe::Core::HandleDuplicates::Keep, Dedupe::Core::HandleDuplicates::LinkTo, Dedupe::Core::HandleDuplicates::MarkAsKeep, and Dedupe::Core::HandleDuplicates::SetLinkPath().
Referenced by Dedupe::CLI::Cli::Run().
{ boost::filesystem::ifstream Inputfile; Dedupe::Core::FilesToProcess Dups; std::string Line, Decision, LinkPath; Inputfile.open( PathToFile, ifstream::in ); if( !Inputfile ) { Message << "ERROR: Could not open Inputfile\n" ; Inputfile.close(); Dups.clear(); return Dups; } while( !Inputfile.eof() ) { std::getline( Inputfile, Line ); EraseComments( Line ); EraseWhitespaces( Line ); if( Line == "" )continue; if( !SplitPathFromDecision( Line, Decision, LinkPath )) { Message << "ERROR: Could not parse current Line: " << Line << std::endl; }; if( Decision == "k" || Decision == "" || Decision == "keep" ) { Dups.push_back( std::make_pair( Line, Dedupe::Core::HandleDuplicates(Dedupe::Core::HandleDuplicates::Keep ))); } else if( Decision == "m" || Decision == "mark") { Dups.push_back( std::make_pair( Line, Dedupe::Core::HandleDuplicates(Dedupe::Core::HandleDuplicates::MarkAsKeep ))); } else if( Decision == "d" || Decision == "delete") { Dups.push_back( std::make_pair( Line, Dedupe::Core::HandleDuplicates(Dedupe::Core::HandleDuplicates::Delete ))); } else if( Decision == "l" || Decision == "link" ) { Dedupe::Core::HandleDuplicates SpezialHandle( Dedupe::Core::HandleDuplicates::LinkTo ); SpezialHandle.SetLinkPath( LinkPath ); Dups.push_back( std::make_pair( Line, SpezialHandle )); } else { Dups.push_back( std::make_pair( Line, Dedupe::Core::HandleDuplicates(Dedupe::Core::HandleDuplicates::Error ))); } } return Dups; }
void Dedupe::CLI::UI::SetTitle | ( | std::string | FileHeader | ) |
Adds a fileheader as comment into the outputfile
Definition at line 100 of file ui.cpp.
Referenced by Dedupe::CLI::Cli::Run().
{ Header = Fileheader; }
bool Dedupe::CLI::UI::WriteDuplicatesToFile | ( | Dedupe::Core::Duplicates | Dups, | |
Dedupe::FilePath | PathToFile | |||
) |
Function writes the founded files from the kernel to an outputfile, where the user can decide what to do with them
Definition at line 16 of file ui.cpp.
Referenced by Dedupe::CLI::Cli::Run().
{ boost::filesystem::ofstream Outputfile; Outputfile.open( PathToFile, ofstream::out ); if( !Outputfile ) { Message << "ERROR: Could not open Outputfile\n" ; Outputfile.close(); return false; } Outputfile << "# " << Header << std::endl; for( auto it = Dups.begin(); it != Dups.end(); ++it ) { Outputfile << "GroupBegin:\n"; for( auto InIt= it->begin(); InIt != it->end(); ++InIt ) { Outputfile << InIt->GetPath() << std::endl; } Outputfile <<"GroupEnd\n"; } Outputfile.close(); return true; }