void SideConf::parseArgs(int argc, char** argv){ CmdLineParser::parse(argc, argv); std::string fu_folder(CmdLineParser::arguments.fufolder); std::string target_folder(CmdLineParser::arguments.output); std::string target_xml_folder(target_folder + "/xmlfiles/"); std::string target_verilog_folder(target_folder + "/verilog/"); std::string reportfile(target_folder + "/sideconf_generation.log"); mkdir(target_folder.c_str(),ACCESSPERMS); if(CmdLineParser::arguments.delay){ mkdir(target_xml_folder.c_str(),ACCESSPERMS); //rmdir(target_verilog_folder.c_str()); }else{ mkdir(target_verilog_folder.c_str(),ACCESSPERMS); //rmdir(target_xml_folder.c_str()); } if(CmdLineParser::arguments.report){ } }
void cmap_array_widget::reload() { while ( this->inside_widget->entries.count() > 0 ) { Cmap_button* b = this->inside_widget->entries.takeAt(0); delete b; } CInside_widget* iw = (CInside_widget*) this->scrollView_insW->takeWidget(); delete iw; this->inside_widget = new CInside_widget(); this->scrollView_insW->setWidget( this->inside_widget ); QDir target_folder( this->projectPath + "/maps/"); QStringList list = target_folder.entryList( QDir::Files | QDir::NoDotAndDotDot, QDir::Name ); QString str; // this->inside_widget->entries.clear(); this->inside_widget->entries.append( new Cmap_button( tr( "Open Any .." ), "0", this->inside_widget ) ); this->inside_widget->entries[0]->icon = QImage( ":/resources/img/open_map_128.png" ); QObject::connect( this->inside_widget->entries[0], SIGNAL(clicked()), this, SLOT(openManual()) ); QObject::connect( this->btnZoom64, SIGNAL(clicked()), this->inside_widget->entries[ 0 ], SLOT(scale_icon_to_64())); QObject::connect( this->btnZoom128, SIGNAL(clicked()), this->inside_widget->entries[ 0 ], SLOT(scale_icon_to_128())); QObject::connect( this->btnZoom256, SIGNAL(clicked()), this->inside_widget->entries[ 0 ], SLOT(scale_icon_to_256())); //first we fetch all the *.map files into this->scroll_widget->entryFilenames for ( int i = 0; i < list.count(); i++ ) { str = list[ i ]; if ( str.right( 4 ) == ".map" ) { Cmap_button* mb = new Cmap_button( str, this->projectPath + "/maps/" + str, this->inside_widget ); mb->show(); this->inside_widget->entries.append( mb ); // this->inside_widget->entries[ this->inside_widget->entries.count() -1 ]->setIcon( QIcon( this->projectPath + "/maps/" + str + ".preview" ) ); //connecting the click QObject::connect( this->inside_widget->entries[ this->inside_widget->entries.count() -1 ], SIGNAL(open_map_by_click(QString)), this, SIGNAL(loadMap(QString))); //connecting the zoomingz QObject::connect( this->btnZoom64, SIGNAL(clicked()), this->inside_widget->entries[ this->inside_widget->entries.count() -1 ], SLOT(scale_icon_to_64())); QObject::connect( this->btnZoom128, SIGNAL(clicked()), this->inside_widget->entries[ this->inside_widget->entries.count() -1 ], SLOT(scale_icon_to_128())); QObject::connect( this->btnZoom256, SIGNAL(clicked()), this->inside_widget->entries[ this->inside_widget->entries.count() -1 ], SLOT(scale_icon_to_256())); QObject::connect( mb, SIGNAL(please_refresh_as_we_deleted_something()), this, SLOT(reload()) ); } } //secound we fetch all the *.map.preview and store em in this->scroll_widget->entryPixmaps // for ( int i = 1; i < this->inside_widget->entries.count(); i++ ) // { // str = list[ i ]; // if ( str.right( 12 ) == ".map.preview" ) // this->inside_widget->entries[ i ]->setIcon( QIcon( this->projectPath + "/maps/" + str ) ); // } // this->inside_widget->setBasementSizez( this->scrollView_insW->size().width() ); this->inside_widget->setZoomFactor( this->inside_widget->zoom_factor ); // this->inside_widget->realign_entries(); }
int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); IO::IODevicePtr src_device = nullptr; if (argc == param_count) { uint64_t start_offset = 0; std::string offset_txt(argv[offset_param]); if (offset_txt.compare(offset_str) == 0) { start_offset = boost::lexical_cast<uint64_t>(argv[offset_value]); qInfo() << "offset : " << start_offset <<"(sectors)"; } std::string disk_file_string(argv[disk_file_param]); if (disk_file_string.compare(d_str) == 0) { auto drive_number = boost::lexical_cast<uint32_t>(argv[source_value]); auto drive_list = IO::ReadPhysicalDrives(); auto physical_drive = drive_list.find_by_number(drive_number); start_offset *= physical_drive->getBytesPerSector(); if (physical_drive) { qInfo() << "You selected"; qInfo() << "Number : " << drive_number; qInfo() << "Name :" << physical_drive->getDriveName().c_str(); qInfo() << "Serial number : " << physical_drive->getSerialNumber().c_str(); qInfo() << "Size : " << physical_drive->getSize() << "(bytes)"; } src_device = std::make_shared<IO::DiskDevice>(physical_drive); } else if (disk_file_string.compare(f_str) == 0) { std::string src_path = argv[source_value]; src_device = IO::makeFilePtr(IO::path_string(src_path.begin(), src_path.end())); start_offset *= default_sector_size; } if (!src_device->Open(IO::OpenMode::OpenRead)) { qInfo() << "Error open source device."; return -1; } std::string targer_path = argv[target_value]; IO::path_string target_folder(targer_path.begin(), targer_path.end()); if (!src_device) return -1; ////////////////////////////////////////////////////////////////////////// QList<JsonFileStruct> listFileStruct; QFile file("video.json"); if (!file.open(QIODevice::ReadOnly)) { qInfo() << "Error to open file. \"" << file.fileName() << "\""; return -1; } auto json_str = file.readAll(); ReadJsonFIle(json_str, listFileStruct); if ( listFileStruct.empty()) { qInfo() << "Error to read" << file.fileName() << "file. Wrong syntax."; return -1; } IO::HeaderBase::Ptr headerBase = std::make_shared<IO::HeaderBase>(); for (auto theFileStruct : listFileStruct) headerBase->addFileFormat(toFileStruct(theFileStruct)); IO::RawFactoryManager factory_manager; initFactoryMananger(factory_manager); IO::SignatureFinder signatureFinder(src_device, headerBase); //uint64_t start_offset = 0x0; uint64_t header_offset = 0; uint32_t counter = 0; while (start_offset < src_device->Size()) { auto file_struct = signatureFinder.findHeader(start_offset, header_offset); if (!file_struct) { qInfo() << endl << endl << endl << "No more signatures found. Press any key to exit."; break; } qInfo() << "Found signature for [" << file_struct->getName().c_str() << "] file."; qInfo() << "Offset : " << header_offset << "(bytes)"; start_offset = header_offset; auto raw_factory = factory_manager.Lookup(file_struct->getName()); IO::RawAlgorithm * raw_algorithm = nullptr; if (!raw_factory) { IO::StandartRaw * standard_raw = new IO::StandartRaw(src_device); standard_raw->setMaxFileSize(file_struct->getMaxFileSize()); standard_raw->setFooter(file_struct->getFooter(), file_struct->getFooterTailEndSize()); standard_raw->setFooterOffsetSearchBlock(4, 4096); raw_algorithm = standard_raw; } else { raw_algorithm = raw_factory->createRawAlgorithm(src_device); } if (raw_algorithm->Specify(header_offset)) { auto target_file = IO::offsetToPath(target_folder, header_offset, file_struct->getExtension(), 512); auto dst_file = IO::makeFilePtr(target_file); if (dst_file->Open(IO::OpenMode::Create)) { auto target_size = raw_algorithm->SaveRawFile(*dst_file, header_offset); if ( target_size == 0) { qInfo() << "Error to save file. Exit." ; //break; } auto dst_size = dst_file->Size(); dst_file->Close(); qInfo() << "Successfully saved " << target_size << "(bytes)" << endl << endl; uint64_t jump_size = default_sector_size; if ( raw_algorithm->Verify(target_file) ) { target_size /= default_sector_size; target_size *= default_sector_size; ////////////////////////////////////////////////////////////////////////// jump_size = target_size; } else { // remove file IO::path_string new_fileName = target_file + L".bad_file"; boost::filesystem::rename(target_file, new_fileName); //{ // qInfo() << "File" << target_file.c_str() << "was removed." << endl; //} //else // qInfo() << "File" << target_file.c_str() << "Error to delete." << endl; } //if (jump_size == 0) jump_size = default_sector_size; start_offset = header_offset + jump_size; } else { qInfo() << "Error to create target file." << QString::fromStdWString(target_file); qInfo() << "Exit."; break; } } else { qInfo() << "Not specified for " << QString::fromStdString(file_struct->getName()) << "continue search for other signatures."<<endl; start_offset += default_sector_size; } if ( raw_algorithm) delete raw_algorithm; } } else qInfo() << "Wrong params"; return a.exec(); }