void CR823_TVolDetailQuery::updateRecord(char* arg) { GSFile wtarget(arg, GSFile::ReadOnly); currentItem = 0; record_item_header tmp_item; memset(&tmp_item, 0, sizeof(record_item_header)); wtarget.ReadRecordHeader(&tmp_item, sizeof(record_item_header)); int len = tmp_item.sum_count; int subvol = tmp_item.sum_subvol; int byte_count = 0; record_item tmp_record; memset(&tmp_record, 0, sizeof(record_item)); tmp_record.tiny_deficency = tmp_item.sum_tiny; tmp_record.mid_deficency = tmp_item.sum_mid; tmp_record.huge_deficency = tmp_item.sum_huge; tmp_record.iron_tramp = tmp_item.sum_iron; memcpy(tmp_record.volume, tmp_item.volume, MAX_LINE); int count = m_entry.GetCount(); char tmpbuf[MAX_PATH]; memset(tmpbuf, 0, MAX_PATH); memcpy(tmpbuf, mConfigure.getProjectName().GetBuffer(), mConfigure.getProjectName().GetLength()*sizeof(TCHAR)); /*for (int i = 0; i<count; i++) { m_entry.DeleteString(i); }*/ m_table_content.DeleteAllItems(); m_entry.ResetContent(); for (int i = 0; i < subvol; i++) { bool am = ((i+1) == mConfigure.current_subvol); bool bm = (memcmp(tmpbuf, tmp_record.volume, 100) == 0); if (!(am && bm)) { CString subvolum; subvolum.Format(_T("%d"),i+1); //m_entry.AddString(subvolum); m_entry.InsertString(i, subvolum); count = m_entry.GetCount(); } //m_entry.InsertString(i, subvolum); } m_entry.SetCurSel(0); wtarget.Done(); }
void CR823_TVolDetailQuery::onSelect() { GSFile wtarget(chconf, GSFile::ReadOnly); currentItem = 0; record_item_header tmp_item; memset(&tmp_item, 0, sizeof(record_item_header)); wtarget.ReadRecordHeader(&tmp_item, sizeof(record_item_header)); int len = tmp_item.sum_count; record_item tmp_record; int subvolume_target = m_entry.GetCurSel() + 1; m_table_content.DeleteAllItems(); m_table_content.SetRowCount(0); for (int i = 0; i < len; i++) { wtarget.ReadRecord(&tmp_record, sizeof(record_item)); if ((tmp_record.subVolum == subvolume_target)) { AddItem(tmp_record); } } wtarget.Done(); }
void Path::copy(const std::string & source, const std::string & destination) { NTA_CHECK(!source.empty()) << "Can't copy from an empty source"; NTA_CHECK(!destination.empty()) << "Can't copy to an empty destination"; NTA_CHECK(source != destination) << "Source and destination must be different"; if (isDirectory(source)) { Directory::copyTree(source, destination); return; } // The target is always a filename. The input destination // Can be either a directory or a filename. If the destination // doesn't exist it is treated as a filename. std::string target(destination); if (Path::exists(destination) && isDirectory(destination)) target = Path::normalize(Path::join(destination, Path::getBasename(source))); bool success = true; #ifdef WIN32 // Must remove read-only or hidden files before copy // because they cannot be overwritten. For simplicity // I just always remove if it exists. if (Path::exists(target)) Path::remove(target); // This will quietly overwrite the destination file if it exists std::wstring wsource(utf8ToUnicode(source)); std::wstring wtarget(utf8ToUnicode(target)); BOOL res = ::CopyFile(/*(LPCTSTR)*/wsource.c_str(), /*(LPCTSTR)*/wtarget.c_str(), FALSE); success = res != FALSE; #else try { OFStream out(target.c_str()); out.exceptions(std::ofstream::failbit | std::ofstream::badbit); UInt64 size = Path::getFileSize(source); if(size) { IFStream in(source.c_str()); if(out.fail()) { std::cout << OS::getErrorMessage() << std::endl; } in.exceptions(std::ifstream::failbit | std::ifstream::badbit); out << in.rdbuf(); } } catch(std::exception &e) { std::cerr << "Path::copy('" << source << "', '" << target << "'): " << e.what() << std::endl; } catch (...) { success = false; } #endif if (!success) NTA_THROW << "Path::copy() - failed copying file " << source << " to " << destination << " os error: " << OS::getErrorMessage(); }