virtual int main() { CStreamFile* pOutFile = NULL; CFilePath fcurdir; CFilePath fziparchive(__FILE__LINE__ m_sZipArchive); CFilePath foutf(__FILE__LINE__ m_sOutputFile); int result = 0; if ( m_help ) { CStringBuffer tmp; usage(tmp); CERR << tmp; return 0; } if ( !m_AnyZipOption ) { m_AnyZipOption = true; m_bAddFiles = true; } if (m_bInputDir) { CFilePath finputdir(__FILE__LINE__ m_sInputDir); if (CWinDirectoryIterator::FileExists(finputdir)) finputdir.set_Filename(NULL); finputdir.MakeDirectory(); if (CWinDirectoryIterator::DirectoryExists(finputdir) < 0) { CERR << finputdir.get_Path() << _T(" does not exist.") << endl; return -4; } CDirectoryIterator::GetCurrentDirectory(fcurdir); fziparchive.MakeAbsolute(); if (m_bOutputFile) foutf.MakeAbsolute(); CDirectoryIterator::SetCurrentDirectory(finputdir); } if (m_bOutputFile) { if (CDirectoryIterator::FileExists(foutf)) CDirectoryIterator::RemoveFile(foutf); else if (foutf.is_File()) { CFilePath tmp(foutf); tmp.set_Filename(NULL); CDirectoryIterator::MakeDirectory(tmp); } else { CDateTime now; CStringBuffer tmp; now.Now(); tmp.FormatString(__FILE__LINE__ _T("XZip%04hd%02hd%02hd%02hd%02hd%02hd.log"), now.GetYears(), now.GetMonths(), now.GetDays(), now.GetHours(), now.GetMinutes(), now.GetSeconds()); foutf.set_Filename(tmp); } pOutFile = OK_NEW_OPERATOR CStreamFile; pOutFile->ReOpen(foutf, stdout); } if ( m_bAddFiles ) { if (!m_bZipFileSpec) { CERR << _T("No FileSpec given. Do not know, what to do.") << endl; result = -4; } else XZipAddFiles(fziparchive, m_bRecurseFolders, m_sZipFileSpec, m_sExclude); } if ( m_bViewFiles ) { if ( !m_bZipFileSpec ) m_sZipFileSpec.Append(_T("*.*")); XZipViewFiles(fziparchive, m_sZipFileSpec, m_sExclude, m_sViewFiles); } if ( m_bFreshenFiles ) { if ( !m_bZipFileSpec ) m_sZipFileSpec.Append(_T("*.*")); XZipFreshenFiles(fziparchive, m_sZipFileSpec, m_sExclude); } if ( m_bUpdateFiles ) { if ( !m_bZipFileSpec ) { CERR << _T("No FileSpec given. Do not know, what to do.") << endl; result = -4; } else XZipUpdateFiles(fziparchive, m_bRecurseFolders, m_sZipFileSpec, m_sExclude); } if (pOutFile) { pOutFile->Close(); pOutFile->release(); } if (m_bInputDir) CDirectoryIterator::SetCurrentDirectory(fcurdir); return result; }
//-------------------------------------------------------------------------- // Save keyboard mapping to file //-------------------------------------------------------------------------- void CKeyMap::SaveCurrentConfig() { char codk[128]; char stag[8]; int i; CStreamFile sf; std::map<Tag,CKeySet*>::const_iterator it; std::map<Tag,CKeyDefinition*>::const_iterator kit; CKeySet * pset; CKeyDefinition * pkey; sf.OpenWrite("System/Keymap.txt"); // // file header and version // sf.WriteString("//================================================="); sf.WriteString("// Please note that Keyset are ordered by name "); sf.WriteString("// Menus should come first as they intercept keys "); sf.WriteString("// that may be dispatched to lower entity such as "); sf.WriteString("// Aircraft or ground vehicles "); sf.WriteString("//================================================="); sf.DebObject(); sf.WriteTag('vers', "---- configuration version ----"); sf.WriteInt(vers); for(it = kset.begin(); it != kset.end(); it++) { pset = it->second; sf.WriteTag('kset', "=== KeySet Definition File ==="); TagToString(stag, it->first); sf.WriteString(stag); sf.WriteTag('bgno', "========== BEGIN OBJECT =========="); sf.WriteTag('name', "---- key set name ----"); sf.WriteString(pset->GetName()); sf.WriteTag('user', "---- user can modify ----"); sf.WriteInt(pset->GetUserModifiableState()); sf.WriteTag('enab', "---- enabled ----"); sf.WriteInt(pset->GetEnabledState()); for(kit = pset->dkey.begin(); kit != pset->dkey.end(); kit++) { pkey = kit->second; sf.WriteTag('kkey', "---- key definition ----"); sf.DebObject(); sf.WriteTag('kyid', "---- key ID ----"); TagToString(stag, kit->first); sf.WriteString(stag); sf.WriteTag('name', "---- key name ----"); sf.WriteString(pkey->GetName()); sf.WriteTag('code', "---- key code & modifier ----"); i = pkey->GetCode(); formatKeyCode(codk,i,0); sf.WriteString(codk); sf.WriteTag('user', "---- user definable ----"); sf.WriteInt(pkey->IsUserMod()); sf.WriteTag('enab', "---- enabled ----"); sf.WriteInt(pkey->IsEnabled()); sf.EndObject(); } sf.EndObject(); } // File end // sf.EndObject(); sf.Close(); return; }