void BackupAndGzip(char* Filename) { Dprintf("BAZ is called\n"); char * Source = AbsoluteSourceName(Filename); char * Destination = AbsoluteDestinationName(Filename); static int BufferSize = 200; static char * CommandBuffer = (char*)malloc(sizeof(char)*BufferSize); if(BufferSize < (25 + 2 * (strlen(Source) + strlen(Destination)))) //double size - in case we'll have to fix 'em { free(CommandBuffer); BufferSize*= 2; CommandBuffer = (char*)malloc(sizeof(char)*BufferSize); } Vprintf("Copying & compressing '%s'\n", Source); if (InjectionCheck(Source) && InjectionCheck(Destination)) { sprintf(CommandBuffer, "cp -p -f '%s' '%s'", Source, Destination);//change this string carefully, buffer's not bottomless! Dprintf("BAZ:%s\n", CommandBuffer); system(CommandBuffer); //CATCH_ERROR("Copying file"); sprintf(CommandBuffer, "gzip -q -f '%s'", Destination); Dprintf("BAZ:%s\n", CommandBuffer); system(CommandBuffer); //CATCH_ERROR("Compressing file"); } else if (FixFlag) { Source = FixFilename(Source); Destination = FixFilename(Destination); sprintf(CommandBuffer, "cp -p -f \"%s\" \"%s\"", Source, Destination);//change this string carefully, buffer's not bottomless! Dprintf("BAZ:%s\n", CommandBuffer); system(CommandBuffer); //CATCH_ERROR("Copying file"); sprintf(CommandBuffer, "gzip -q -f \"%s\"", Destination); Dprintf("BAZ:%s\n", CommandBuffer); system(CommandBuffer); //CATCH_ERROR("Compressing file"); } else { Vprintf("Filename too suspicious. Sorry.\n"); return; } }
void CShaderEditorDlg::OnCbnSelchangeCombo1() { int i = m_labels.GetCurSel(); CString label; if (i < 0) { m_labels.GetWindowText(label); //label.Trim(); FixFilename(label); if (label.IsEmpty()) { return; } for (int k = 0; k < m_labels.GetCount(); k++) { if (label.CompareNoCase(((CAppSettings::Shader*)m_labels.GetItemDataPtr(k))->label) == 0) { m_labels.SetCurSel(k); i = k; break; } } } if (i < 0) { CStringA srcdata; if (!LoadResource(IDF_SHADER_EMPTY, srcdata, _T("FILE"))) { return; } CAppSettings::Shader s; s.label = label; s.target = _T("ps_2_0"); s.srcdata = CString(srcdata); POSITION pos = AfxGetAppSettings().m_shaders.AddTail(s); i = m_labels.AddString(s.label); m_labels.SetCurSel(i); m_labels.SetItemDataPtr(i, (void*)&AfxGetAppSettings().m_shaders.GetAt(pos)); } m_pShader = (CAppSettings::Shader*)m_labels.GetItemDataPtr(i); m_targets.SetWindowText(m_pShader->target); CString srcdata = m_pShader->srcdata; srcdata.Replace(_T("\n"), _T("\r\n")); m_srcdata.SetWindowText(srcdata); ((CMainFrame*)AfxGetMainWnd())->UpdateShaders(m_pShader->label); }