void ViewFilesDialog::OnFviewNext(void) { // handles "next" button; also called from DoDataExchange ReformatHolder::ReformatPart part; ReformatHolder::ReformatID id; int result; if (fBusy) { LOGI("BUSY!"); return; } fBusy = true; if (!fpSelSet->IterHasNext()) { ASSERT(false); return; } /* * Get the pieces of the file. */ SelectionEntry* pSelEntry = fpSelSet->IterNext(); GenericEntry* pEntry = pSelEntry->GetEntry(); result = ReformatPrep(pEntry); #if 0 { // for debugging -- simulate failure result = -1; delete fpHolder; fpHolder = NULL; delete fpOutput; fpOutput = NULL; } #endif fBusy = false; if (result != 0) { ASSERT(fpHolder == NULL); ASSERT(fpOutput == NULL); return; } /* * Format a piece. */ ConfigurePartButtons(pSelEntry->GetEntry()); part = GetSelectedPart(); id = ConfigureFormatSel(part); Reformat(pSelEntry->GetEntry(), part, id); DisplayText(pSelEntry->GetEntry()->GetDisplayName()); }
CString MainWindow::CreateFileList(SelectionSet* pSelSet) { SelectionEntry* pSelEntry; GenericEntry* pEntry; CString tmpStr, fullStr; WCHAR fileTypeBuf[ContentList::kFileTypeBufLen]; WCHAR auxTypeBuf[ContentList::kAuxTypeBufLen]; CString fileName, subVol, fileType, auxType, modDate, format, length; pSelEntry = pSelSet->IterNext(); while (pSelEntry != NULL) { pEntry = pSelEntry->GetEntry(); ASSERT(pEntry != NULL); fileName = DblDblQuote(pEntry->GetPathNameUNI()); subVol = pEntry->GetSubVolName(); ContentList::MakeFileTypeDisplayString(pEntry, fileTypeBuf); fileType = DblDblQuote(fileTypeBuf); // Mac HFS types might have '"'? ContentList::MakeAuxTypeDisplayString(pEntry, auxTypeBuf); auxType = DblDblQuote(auxTypeBuf); FormatDate(pEntry->GetModWhen(), &modDate); format = pEntry->GetFormatStr(); length.Format(L"%I64d", (LONGLONG) pEntry->GetUncompressedLen()); tmpStr.Format(L"\"%ls\"\t%ls\t\"%ls\"\t\"%ls\"\t%ls\t%ls\t%ls\r\n", (LPCWSTR) fileName, (LPCWSTR) subVol, (LPCWSTR) fileType, (LPCWSTR) auxType, (LPCWSTR) modDate, (LPCWSTR) format, (LPCWSTR) length); fullStr += tmpStr; pSelEntry = pSelSet->IterNext(); } return fullStr; }
bool AcuArchive::TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) { // TODO: this is essentially copy & paste from NufxArchive::TestSelection(). // We can move the implementation to GenericArchive and just have an // archive-specific TestEntry() function. NuError nerr; AcuEntry* pEntry; CString errMsg; bool retVal = false; ASSERT(fFp != NULL); LOGI("Testing %d entries", pSelSet->GetNumEntries()); SelectionEntry* pSelEntry = pSelSet->IterNext(); while (pSelEntry != NULL) { pEntry = (AcuEntry*) pSelEntry->GetEntry(); LOGD(" Testing '%ls' (offset=%ld)", (LPCWSTR) pEntry->GetDisplayName(), pEntry->GetOffset()); SET_PROGRESS_UPDATE2(0, pEntry->GetDisplayName(), NULL); nerr = pEntry->TestEntry(pMsgWnd); if (nerr != kNuErrNone) { if (nerr == kNuErrAborted) { CString title; CheckedLoadString(&title, IDS_MB_APP_NAME); errMsg = L"Cancelled."; pMsgWnd->MessageBox(errMsg, title, MB_OK); } else { errMsg.Format(L"Failed while testing '%ls': %hs.", (LPCWSTR) pEntry->GetPathNameUNI(), NuStrError(nerr)); ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED); } goto bail; } pSelEntry = pSelSet->IterNext(); } /* show success message */ errMsg.Format(L"Tested %d file%ls, no errors found.", pSelSet->GetNumEntries(), pSelSet->GetNumEntries() == 1 ? L"" : L"s"); pMsgWnd->MessageBox(errMsg); retVal = true; bail: SET_PROGRESS_END(); return retVal; }
void ViewFilesDialog::OnFviewPrev(void) { ReformatHolder::ReformatPart part; ReformatHolder::ReformatID id; int result; if (fBusy) { LOGI("BUSY!"); return; } fBusy = true; if (!fpSelSet->IterHasPrev()) { ASSERT(false); return; } /* * Get the pieces of the file. */ SelectionEntry* pSelEntry = fpSelSet->IterPrev(); GenericEntry* pEntry = pSelEntry->GetEntry(); result = ReformatPrep(pEntry); fBusy = false; if (result != 0) { ASSERT(fpHolder == NULL); ASSERT(fpOutput == NULL); return; } /* * Format a piece. */ ConfigurePartButtons(pEntry); part = GetSelectedPart(); id = ConfigureFormatSel(part); Reformat(pEntry, part, id); DisplayText(pEntry->GetDisplayName()); }
void ViewFilesDialog::OnFormatSelChange(void) { /* * The user has changed entries in the format selection drop box. * * Also called from the "quick change" buttons. */ CComboBox* pCombo = (CComboBox*) GetDlgItem(IDC_FVIEW_FORMATSEL); ASSERT(pCombo != NULL); LOGD("+++ SELECTION IS NOW %d", pCombo->GetCurSel()); SelectionEntry* pSelEntry = fpSelSet->IterCurrent(); GenericEntry* pEntry = pSelEntry->GetEntry(); ReformatHolder::ReformatPart part; ReformatHolder::ReformatID id; part = GetSelectedPart(); id = (ReformatHolder::ReformatID) pCombo->GetItemData(pCombo->GetCurSel()); Reformat(pEntry, part, id); DisplayText(pEntry->GetDisplayName()); }
HGLOBAL MainWindow::CreateFileCollection(SelectionSet* pSelSet) { SelectionEntry* pSelEntry; GenericEntry* pEntry; HGLOBAL hGlobal = NULL; HGLOBAL hResult = NULL; LPVOID pGlobal; size_t totalLength, numFiles; long priorLength; /* get len of text version(s), with kluge to avoid close & reopen */ priorLength = GetClipboardContentLen() * kClipTextMult; /* add some padding -- textmult doesn't work for fixed-size CF_LOCALE */ priorLength += kWin98NeutralZone; totalLength = sizeof(FileCollection); numFiles = 0; /* * Compute the amount of space required to hold it all. */ pSelSet->IterReset(); pSelEntry = pSelSet->IterNext(); while (pSelEntry != NULL) { pEntry = pSelEntry->GetEntry(); ASSERT(pEntry != NULL); //LOGI("+++ Examining '%s'", pEntry->GetDisplayName()); if (pEntry->GetRecordKind() != GenericEntry::kRecordKindVolumeDir) { totalLength += sizeof(FileCollectionEntry); totalLength += (wcslen(pEntry->GetPathNameUNI()) +1) * sizeof(WCHAR); numFiles++; if (pEntry->GetRecordKind() != GenericEntry::kRecordKindDirectory) { totalLength += (long) pEntry->GetDataForkLen(); totalLength += (long) pEntry->GetRsrcForkLen(); } } if (totalLength < 0) { DebugBreak(); LOGI("Overflow"); // pretty hard to do right now! return NULL; } pSelEntry = pSelSet->IterNext(); } #if 0 { CString msg; msg.Format("totalLength is %ld+%ld = %ld", totalLength, priorLength, totalLength+priorLength); if (MessageBox(msg, NULL, MB_OKCANCEL) == IDCANCEL) goto bail; } #endif LOGI("Total length required is %ld + %ld = %ld", totalLength, priorLength, totalLength+priorLength); if (IsWin9x() && totalLength+priorLength >= kWin98ClipboardMax) { CString errMsg; errMsg.Format(IDS_CLIPBOARD_WIN9XMAX, kWin98ClipboardMax / (1024*1024), ((float) (totalLength+priorLength)) / (1024.0*1024.0)); ShowFailureMsg(this, errMsg, IDS_MB_APP_NAME); goto bail; } /* * Create a big buffer to hold it all. */ hGlobal = ::GlobalAlloc(GHND | GMEM_SHARE, totalLength); if (hGlobal == NULL) { CString errMsg; errMsg.Format(L"ERROR: unable to allocate %ld bytes for copy", totalLength); LOGI("%ls", (LPCWSTR) errMsg); ShowFailureMsg(this, errMsg, IDS_FAILED); goto bail; } pGlobal = ::GlobalLock(hGlobal); ASSERT(pGlobal != NULL); ASSERT(GlobalSize(hGlobal) >= (DWORD) totalLength); LOGI("hGlobal=0x%08lx pGlobal=0x%08lx size=%ld", (long) hGlobal, (long) pGlobal, GlobalSize(hGlobal)); /* * Set up a progress dialog to track it. */ ASSERT(fpActionProgress == NULL); fpActionProgress = new ActionProgressDialog; fpActionProgress->Create(ActionProgressDialog::kActionExtract, this); fpActionProgress->SetFileName(L"Clipboard"); /* * Extract the data into the buffer. */ long remainingLen; void* buf; remainingLen = totalLength - sizeof(FileCollection); buf = (uint8_t*) pGlobal + sizeof(FileCollection); pSelSet->IterReset(); pSelEntry = pSelSet->IterNext(); while (pSelEntry != NULL) { CString errStr; pEntry = pSelEntry->GetEntry(); ASSERT(pEntry != NULL); fpActionProgress->SetArcName(pEntry->GetDisplayName()); errStr = CopyToCollection(pEntry, &buf, &remainingLen); if (!errStr.IsEmpty()) { ShowFailureMsg(fpActionProgress, errStr, IDS_MB_APP_NAME); goto bail; } //LOGI("remainingLen now %ld", remainingLen); pSelEntry = pSelSet->IterNext(); } ASSERT(remainingLen == 0); ASSERT(buf == (uint8_t*) pGlobal + totalLength); /* * Write the header. */ FileCollection fileColl; fileColl.version = kClipVersion; fileColl.dataOffset = sizeof(FileCollection); fileColl.length = totalLength; fileColl.count = numFiles; memcpy(pGlobal, &fileColl, sizeof(fileColl)); /* * Success! */ ::GlobalUnlock(hGlobal); hResult = hGlobal; hGlobal = NULL; bail: if (hGlobal != NULL) { ASSERT(hResult == NULL); ::GlobalUnlock(hGlobal); ::GlobalFree(hGlobal); } if (fpActionProgress != NULL) { fpActionProgress->Cleanup(this); fpActionProgress = NULL; } return hResult; }