/* * changelist.cpp by Matthis Braun * * Copyright (C) 2002 Atomic Blue (info@planeshift.it, http://www.atomicblue.org) * * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation (version 2 of the License) * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ #include #include "updaterglobals.h" #include "changelist.h" namespace updater { ChangeList::ChangeList () { } ChangeList::~ChangeList () { } // Print our changelist csString ChangeList::CreateList (bool print) { size_t totalSize=0,files = 0; csString output; for (size_t i=0; iinZip) entry = "Merge "; else entry = "Create "; break; } case Change::REMOVEFILE: entry = "Remove "; break; case Change::MOVEFILEAWAY: entry = "Move "; break; case Change::UPDATEFILE: entry = "Update "; break; case Change::UPDATEZIP: entry = "Get Zip "; break; default: entry = "Unknown Change Type (This shouldn't happen)"; } if(change.type==Change::UPDATEZIP) entry += change.file->parentZip; else entry += change.file->file; if (change.file->inZip && change.type != Change::UPDATEZIP) { entry += " (ZIP)"; } if (change.file->size > 0) { files++; } if(change.type != Change::REMOVEFILE && change.type != Change::MOVEFILEAWAY) { // Increase the total size if(change.type != Change::UPDATEZIP) totalSize += change.file->size; else totalSize += change.file->parentSize; } output += entry + "\n"; if(print) psupdaterengine->OutToScreen(entry); } if (totalSize == 0) return csString(""); //Make it not so many numbers.. csString unit; float fsize; if (totalSize > 1024 && totalSize < (1024 * 1024)) { fsize = totalSize / 1024; unit = "KB"; } else if ( totalSize > (1024*1024) ) { fsize = float(totalSize / 1024) / 1024; unit = "MB"; } else { fsize = totalSize; unit = "B"; } csString total; total.Format("Total size %0.2f %s in %d files",fsize,unit.GetData(),files); if(print) psupdaterengine->OutToScreen(total); output += total; return output; } } // end of namespace updater