Example #1
0
int main(int argc, char **argv) {
    try {
        std::vector<Common::UString> args;
        Common::Platform::getParameters(argc, argv, args);

        Aurora::GameID game = Aurora::kGameIDUnknown;

        int returnValue = 1;
        Command command = kCommandNone;
        Common::UString archive;
        std::set<Common::UString> files;
        std::vector<byte> password;

        if (!parseCommandLine(args, returnValue, command, archive, files, game, password))
            return returnValue;

        Aurora::ERFFile erf(new Common::ReadFile(archive), password);

        if      (command == kCommandInfo)
            displayInfo(erf);
        else if (command == kCommandList)
            listFiles(erf, game);
        else if (command == kCommandListVerbose)
            listVerboseFiles(erf, game);
        else if (command == kCommandExtract)
            extractFiles(erf, game, files, kExtractModeStrip);
        else if (command == kCommandExtractSub)
            extractFiles(erf, game, files, kExtractModeSubstitute);

    } catch (...) {
        Common::exceptionDispatcherError();
    }

    return 0;
}
Example #2
0
int main(int argc, char **argv) {
	std::vector<Common::UString> args;
	Common::Platform::getParameters(argc, argv, args);

	Aurora::GameID game = Aurora::kGameIDUnknown;

	int returnValue = 1;
	Command command = kCommandNone;
	Common::UString file;

	try {
		if (!parseCommandLine(args, returnValue, command, file, game))
			return returnValue;

		Aurora::RIMFile rim(new Common::ReadFile(file));

		if      (command == kCommandList)
			listFiles(rim, game);
		else if (command == kCommandExtract)
			extractFiles(rim, game);

	} catch (...) {
		Common::exceptionDispatcherError();
	}

	return 0;
}
Example #3
0
int main(int argc, char **argv) {
	std::vector<Common::UString> args;
	Common::Platform::getParameters(argc, argv, args);

	int returnValue = 1;
	Command command = kCommandNone;
	Common::UString file;

	try {
		if (!parseCommandLine(args, returnValue, command, file))
			return returnValue;

		Aurora::NDSFile nds(new Common::ReadFile(file));

		if      (command == kCommandInfo)
			displayInfo(nds);
		else if (command == kCommandList)
			listFiles(nds);
		else if (command == kCommandExtract)
			extractFiles(nds);

	} catch (...) {
		Common::exceptionDispatcherError();
	}

	return 0;
}
Example #4
0
int main(int argc, char **argv) {
	std::vector<Common::UString> args;
	Common::Platform::getParameters(argc, argv, args);

	int returnValue = 1;
	Command command = kCommandNone;
	Common::UString file;

	try {
		if (!parseCommandLine(args, returnValue, command, file))
			return returnValue;

		Aurora::HERFFile herf(new Common::ReadFile(file));

		if      (command == kCommandList)
			listFiles(herf);
		else if (command == kCommandExtract)
			extractFiles(herf);

	} catch (Common::Exception &e) {
		Common::printException(e);
		return -1;
	} catch (std::exception &e) {
		error("%s", e.what());
	}

	return 0;
}
Example #5
0
int main(int argc, char **argv) {
	if (argc < 2) {
		printHelp(argv[0]);
		return -1;
	}

	std::ifstream pgfFile;

	pgfFile.open(argv[1]);

	if (!pgfFile.is_open()) {
		printf("Error opening file \"%s\"\n", argv[1]);
		return -1;
	}

	uint32 fileCount = readUint32BE(pgfFile);

	printf("Number of file: %d\n", fileCount);

	std::list<FileInfo> files;

	readFileList(pgfFile, files, fileCount);

	extractFiles(pgfFile, files);

	files.clear();
	pgfFile.close();

	return 0;
}
Example #6
0
GLOBAL_LOGGING

int main(int argc, char *argv[], char *env[])
{
  Context *cnt = (Context *)malloc(sizeof(Context));
  FILE *f = NULL;
  int _error = 0;

  INIT_LOGGING;
  LOGGING_FUNC_START;
  INFO(L"Programm started");
  INFO(L"Тест русского языка");
  printf("Hello World!\n");
  INFO(L"Programm ended");
  cnt->argv = argv;
  cnt->argc = argc;
  cnt->env  = env;
  _error = parseArgs(&cnt);

  if (0 != _error) {
    printHelp();
  } else {
    switch(cnt->keys) {
    case 0x0:
      ;
      break;
    case 0x1:
      f = fopen(argv[2], "rb");
      checkIntegrity_my(f);
      break;
    case 0x2:
        f = fopen(argv[2], "r");
        printf("In file `%s`, folder", argv[2]);
        printFilesOfFolder(f, argv[3]);
      break;
    case 0x4:
      ;
      break;
    case 0x8:
      f = fopen(argv[2], "rb");
      extractFiles(f, cnt);
      fclose(f);
      break;
      case 0x10:
        addFiles2Arch(*cnt);
        break;
    default:
      printHelp();
      break;
    }
  }

  LOGGING_FUNC_STOP;
  DEINIT_LOGGING;
  printf("Programm exit!\n");
  return 0;
}
Example #7
0
void MainWindow::on_actionExtract_All_triggered()
{
    QList<QTableWidgetItem*> items;
    for (int i = 0; i < ui->tableWidget->rowCount(); i++)
        items.push_back(ui->tableWidget->item(i, 0));
    for (int x = 0; x < ui->tableWidget->rowCount() * 3; x++)
        items.push_back(NULL);

    extractFiles(items);
}
Example #8
0
/* ========================================================================
PURPOSE :
*/
int splitFiles (const char *sourceFilePath, const char *destDir)
{
    stJAndSHeader *splitHdr = NULL;
    FILE *fileHdl = NULL;        
    char splitName[_MAX_DIR];
    short nErr = EZERO;

    sprintf ( splitName, "%s%s", sourceFilePath, ".CAT" );

    if ((nErr = file_uncompress( sourceFilePath, splitName)) != 0) // @1
    {
        String msg = String("Failed uncompress from ") + sourceFilePath + " to "+ splitName;
        throw std::exception ( msg.c_str() );
        return nErr;
    }
        
    // Clear any outstanding errors
    errno = EZERO;

    // Get memory for the split header structure
    if ((splitHdr = (stJAndSHeader*)malloc(sizeof(stJAndSHeader))) != NULL)
    {
        // Open the join file...
        if ((fileHdl = fopen (splitName, "rb")) != NULL)
        {
            // Populate the header from the join file
            if (readHeader (splitHdr, fileHdl) == 0)
            {
                String strDestDir ( destDir );
                if ( strDestDir.back() != '\\' && strDestDir.back() != '/' )
                    strDestDir.push_back ( '/' );
                // ... and split out all the files.
                extractFiles ( strDestDir.c_str(), splitHdr, fileHdl );
            }
			fclose(fileHdl);
        }
        free (splitHdr);
    }
    else
        throw std::exception ("Insufficient memory");
    
    _unlink (splitName);

    // For debugging only
    #ifdef DEBUG_MODE
    printHeader (stdout,splitHdr);
    #endif

    return errno;
}
Example #9
0
void MainWindow::showRemoveContextMenu(const QPoint &pos)
{
    if (ui->tableWidget->selectedItems().length() == 0)
        return;

    QPoint globalPos = ui->tableWidget->mapToGlobal(pos);

    QMenu contextMenu;
    QIcon icon, icon2;
    icon.addPixmap(QPixmap::fromImage(QImage(":/images/extract.png")));
    contextMenu.addAction(icon, "Extract Selected");

    icon2.addPixmap(QPixmap::fromImage(QImage(":/images/cancel.png")));
    contextMenu.addAction(icon2, "Remove Selected");

    QAction *selectedItem = contextMenu.exec(globalPos);
    if(selectedItem == NULL)
        return;

    try
    {
        if(selectedItem->text() == "Remove Selected")
        {
            QList<QTableWidgetItem*> items = ui->tableWidget->selectedItems();

            for(int i = 0; i < items.count(); i++)
                qDebug("%d: %s", i, items.at(i)->text().toStdString().c_str());

            for(int i = 0; i < items.count(); i += 4)
            {
                bool hexOnly = hexNumbersOnly(items.at(i)->text().remove("0x"));
                unsigned long long id = hexOnly ? items.at(i)->text().toULongLong(0, 16) : getIdFromName(items.at(i)->text().toStdString());
                unsigned short type = getTypeFromName(items.at(i + 3)->text().toStdString());
                Entry *e = xdbf->getEntryById(id, type);
                xdbf->removeEntry(e);
            }

            for(int i = 0; i < items.count(); i += 4)
                ui->tableWidget->removeRow(items[i]->row());
        }
        else if(selectedItem->text() == "Extract Selected")
        {
            extractFiles(ui->tableWidget->selectedItems());
        }
    }
    catch(char *str)
    {
        QMessageBox::warning(this, "Error Thrown", QString::fromLocal8Bit(str));
    }
}
Example #10
0
bool unpackPackage(const wchar_t* packagePath, const wchar_t* targetDir) {
	writeLog(LOG_NORMAL, L"Unpacking package: %s", packagePath);
	writeLog(LOG_NORMAL, L"To Directory: %s", targetDir);
	if (!fsEnsureDirectoryExists(targetDir)) {
		writeLog(LOG_QUIET, L"ERROR: Target directory does not exist and cannot be created.", targetDir);
		return false;
	}
	NexasPackage* package = openPackage(packagePath);
	if (!package) return false;
	bool result = validateHeader(package)
			&& readIndex(package)
			&& extractFiles(package, targetDir);
	closePackage(package);
	writeLog(LOG_NORMAL, (result) ? L"Unpacking Successful." : L"ERROR: Unpacking Failed.");
	return result;
}
Example #11
0
MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){
  ui->setupUi(this);
  QString title = tr("Archive Manager");
  if( getuid()==0){ title.append(" ("+tr("Admin Mode")+")"); }
  this->setWindowTitle(title);
  BACKEND = new Backend(this);
  connect(BACKEND, SIGNAL(ProcessStarting()), this, SLOT(ProcStarting()) );
  connect(BACKEND, SIGNAL(ProcessFinished(bool, QString)), this, SLOT(ProcFinished(bool, QString)) );
  connect(BACKEND, SIGNAL(ProgressUpdate(int, QString)), this, SLOT(ProcUpdate(int, QString)) );

  //Add a spacer between toolbar items
  QWidget *spacer = new QWidget(this);
    spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
  ui->toolBar->insertWidget(ui->actionAdd_File, spacer);

  //Connect the UI signals/slots
  connect(ui->action_New, SIGNAL(triggered()), this, SLOT(NewArchive()) );
  connect(ui->action_Open, SIGNAL(triggered()), this, SLOT(OpenArchive()) );
  connect(ui->action_Quit, SIGNAL(triggered()), this, SLOT(close()) );
  connect(ui->actionAdd_File, SIGNAL(triggered()), this, SLOT(addFiles()) );
  connect(ui->actionRemove_File, SIGNAL(triggered()), this, SLOT(remFiles()) );
  connect(ui->actionExtract_All, SIGNAL(triggered()), this, SLOT(extractFiles()) );
  connect(ui->actionExtract_Sel, SIGNAL(triggered()), this, SLOT(extractSelection()) );
  connect(ui->actionAdd_Dirs, SIGNAL(triggered()), this, SLOT(addDirs()) );
  connect(ui->tree_contents, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(ViewFile(QTreeWidgetItem*)) );
  connect(ui->actionUSB_Image, SIGNAL(triggered()), this, SLOT(BurnImgToUSB()) );

  //Set Keyboard Shortcuts
  ui->action_New->setShortcut(tr("CTRL+N"));
  ui->action_Open->setShortcut(tr("CTRL+O"));
  ui->action_Quit->setShortcut(tr("CTRL+Q"));
  ui->actionExtract_All->setShortcut(tr("CTRL+E"));
  
  ui->progressBar->setVisible(false);
  ui->label_progress->setVisible(false);
  ui->label_progress_icon->setVisible(false);
  ui->actionAdd_File->setEnabled(false);
  ui->actionRemove_File->setEnabled(false);
  ui->actionExtract_All->setEnabled(false);
  ui->actionAdd_Dirs->setEnabled(false);
  ui->actionUSB_Image->setEnabled(false);
  loadIcons();
  ui->tree_contents->setHeaderLabels( QStringList() << tr("File") << tr("MimeType") << tr("Size")+" " );
}
Example #12
0
//------------------------------------------------------------------------------------
void ExtractThread::run()
{
    try
    {
        ofsFile.mount(ofsFileName.c_str());
    }
    catch(...)
    {
        return;
    }

    mTotalFileSize = generateList(mlist);

    std::sort(mlist.begin(), mlist.end(), OFS::FileEntry::Compare);
    
    extractFiles(path, mlist);

    ofsFile.unmount();
}
Example #13
0
int LocalPackage::fill_scripts(PACKAGE *package)
{
	string scripts_dir=SCRIPTS_DIR+"/" + package->get_filename() + "_" + package->get_md5() + "/";
	string tmp_preinstall=scripts_dir+"preinstall.sh";
	string tmp_postinstall=scripts_dir+"doinst.sh";
	string tmp_preremove=scripts_dir+"preremove.sh";
	string tmp_postremove=scripts_dir+"postremove.sh";
	string mkdir_pkg="mkdir -p "+scripts_dir+" 2>/dev/null";
	if (!simulate) system(mkdir_pkg);
	string sys_cache=SYS_CACHE;
	string filename=sys_cache + package->get_filename();
	if (!simulate)
	{
		//mDebug("extracting scripts");
		extractFiles(filename, "install/preinstall.sh install/doinst.sh install/preremove.sh install/postremove.sh", scripts_dir);
		if (FileExists(scripts_dir + "/install")) {
			system("(cd " + scripts_dir + "/install; mv * ..; cd ..; rmdir install)");
		}
	}

	return 0;
}
Example #14
0
void ParametricAd::checkInputSandbox(std::vector<std::string>& extracted){
	GLITE_STACK_TRY("ParametricAd::checkInputSandbox(std::vector<std::string>&)");
	// This vector contains all ISB string extracted Values
	unsigned int iter_i = extracted.size();
	// This Vector will replace the old InputSanbox with the extracted values
	vector<ExprTree*> isVect ;
	ExprTree* isbTree = Lookup (JDL::INPUTSB);
	if (!isbTree){ /* No inputFiles found: return */ return; }
	// These variables are needed when extracting
	const string wmpURI = (hasAttribute(JDL::WMPISB_BASE_URI))? (getString(JDL::WMPISB_BASE_URI)):"";
	const string isbURI=   (hasAttribute(JDL::ISB_BASE_URI))  ? (getString(JDL::ISB_BASE_URI)   ):"";
	Value val ;
	string isb ;
	EvaluateExpr(isbTree,val);
	inputRemotes.clear();
	switch ( val.GetType() ){
		case Value::UNDEFINED_VALUE:
			inputRemotes.push_back(isbTree->Copy());
			isVect.push_back(isbTree->Copy());
			break;
		case Value::STRING_VALUE:
			val.IsStringValue(isb);
			toBretrieved=extractFiles (JDL::INPUTSB, isb, extracted,
				lookInto_b,wmpURI,isbURI,extractedAd.get()) || toBretrieved;
			// put the extracted files back into the InputSandbox attribute
			for(;iter_i<extracted.size();iter_i++){	// Iterate ONLY over new value(s)
				val.SetStringValue(extracted[iter_i]);	// create classad Value
				isVect.push_back(Literal::MakeLiteral(val));	// Update ISB value
			}
			break;
		case Value::LIST_VALUE:{
			const ExprList *el;
			val.IsListValue( el );
			vector<ExprTree*> vectList ;
			el->GetComponents(vectList) ;
			for ( unsigned int i = 0; i< vectList.size() ; i++){
				if (vectList[i]->GetKind()!=ExprTree::LITERAL_NODE){
					// not a literal node
					inputRemotes.push_back( vectList[i]->Copy() );
					isVect.push_back(vectList[i]->Copy());
				}
				else if (vectList[i]->Evaluate(val)){
					switch (val.GetType()){
						case Value::STRING_VALUE:
							val.IsStringValue(isb);
							toBretrieved=extractFiles (JDL::INPUTSB, isb, extracted,
								lookInto_b,wmpURI,isbURI,extractedAd.get()) || toBretrieved;
							// put the extracted files back into the InputSandbox attribute
							for(;iter_i<extracted.size();iter_i++){	// Iterate ONLY over new value(s)
								val.SetStringValue(extracted[iter_i]);	// create classad Value
								isVect.push_back(Literal::MakeLiteral(val));	// Update ISB value
							}
							break;
						case Value::UNDEFINED_VALUE:
							// It's an Expression evaluated
							inputRemotes.push_back( vectList[i]->Copy() );
							isVect.push_back(vectList[i]->Copy());
							break;
						default:
							throw AdMismatchException (__FILE__,__LINE__,
							METHOD,WMS_JDLMISMATCH , JDL::INPUTSB );
					}
				}else{
					// It's an Expression not evaluated, leave it unchanged
					inputRemotes.push_back( vectList[i]->Copy() );
					isVect.push_back(vectList[i]->Copy());
				}
				val.Clear() ;
			}
		}
		break;
		default:
			throw AdMismatchException (__FILE__ , __LINE__ ,METHOD, WMS_JDLMISMATCH , JDL::INPUTSB );
			break;
	}
	classad:ExprTree* tmp_expr = ExprList::MakeExprList(isVect);
	Insert (JDL::INPUTSB , tmp_expr) ;
	GLITE_STACK_JDL_CATCH_ALL() ; //Exiting from method: remove line from stack trace
}