LRESULT CMainFrame::OnFileSave(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { VGMFile* pvgmfile = GetActiveFile(); if (pvgmfile != NULL) pvgmfile->OnSaveAsRaw(); return 0; }
bool VGMRoot::SaveAllAsRaw() { wstring dirpath = UI_GetSaveDirPath();\ if (dirpath.length() != 0) { for (uint32_t i=0; i<vVGMFile.size(); i++) { bool result; VGMFile* file = vVGMFile[i]; wstring filepath = dirpath + L"\\" + file->GetName()->c_str(); uint8_t* buf = new uint8_t[file->unLength]; //create a buffer the size of the file file->GetBytes(file->dwOffset, file->unLength, buf); result = UI_WriteBufferToFile(filepath.c_str(), buf, file->unLength); delete[] buf; } return true; } return false; }
bool CVGMFileListView::GetDraggedFileInfo ( std::vector<CDraggedFileInfo>& vec ) { int nIdx = -1; while ( (nIdx = GetNextItem ( nIdx, LVNI_SELECTED )) != -1 ) { VGMFile* vgmfile; //pInfo = (CCompressedFileInfo*) GetItemData ( nIdx ); vgmfile = (VGMFile*) GetItemData ( nIdx ); ATLASSERT(vgmfile != NULL); //if ( pInfo->bExtractable ) vec.push_back ( CDraggedFileInfo ( vgmfile->GetName()->c_str(), nIdx ) ); //else // ATLTRACE("Skipping partial/unavailable file <%s>\n", (LPCTSTR) vgmfile->sFilename); } return !vec.empty(); }
int CVGMFileListView::SortCallback ( const VGMFile& info1, const VGMFile& info2 ) const { int nRet = 0; LPCTSTR sz1, sz2; ATLASSERT(-1 != m_nSortedCol); //ATLASSERT(!info1.sFilename.IsEmpty()); //ATLASSERT(!info2.sFilename.IsEmpty()); // Default to comparing the file names, unless something in the switch // changes these pointers. sz1 = info1.GetName()->c_str(); sz2 = info2.GetName()->c_str(); //ItemType type1; //ItemType type2; switch ( m_nSortedCol ) { case 0: // file name break; case 1: // type description //ATLASSERT(!info1.sFileType.IsEmpty()); //ATLASSERT(!info2.sFileType.IsEmpty()); if (info1.GetType() > info2.GetType()) nRet = 1; else nRet = -1; break; /* case 2: // uncompressed size if ( info1.dwFileSize < info2.dwFileSize ) nRet = -1; else if ( info1.dwFileSize > info2.dwFileSize ) nRet = 1; break; case 3: // modified date/time { LONG lRet = CompareFileTime ( &info1.ftDateTime, &info2.ftDateTime ); if ( 0 != lRet ) nRet = lRet; } break; case 4: // file attributes if ( info1.uAttribs < info2.uAttribs ) nRet = -1; else if ( info1.uAttribs > info2.uAttribs ) nRet = 1; break; case 5: // prev/next CAB name if ( info1.location < info2.location ) nRet = -1; else if ( info1.location > info2.location ) nRet = 1; else if ( info1.location != CCompressedFileInfo::in_this_cab ) { ATLASSERT(!info1.sOtherCabName.IsEmpty()); ATLASSERT(!info2.sOtherCabName.IsEmpty()); nRet = lstrcmpi ( info1.sOtherCabName, info2.sOtherCabName ); } break;*/ DEFAULT_UNREACHABLE; } // If the primary comparison in the switch returned equality (nRet is still 0), // then compare sz1/sz2 so equal items will still be sorted by file names. if ( 0 == nRet ) nRet = lstrcmpi ( sz1, sz2 ); return m_bSortAscending ? nRet : -nRet; }