Example #1
0
bool MainWindow::openPackage(const QString &name)
{
    if (m_package)
        closePackage();

    m_package = Opc::Package::open(name, QIODevice::ReadOnly);
    if (!m_package) {
        //Error occur.
        statusBar()->showMessage(tr("Fail to open the package %1").arg(name));
        setWindowTitle("Demo for Opc Package");
        return false;
    }

    m_recentFilesList.removeOne(name);
    m_recentFilesList.insert(0, name);
    if (m_recentFilesList.size() > 50)
        m_recentFilesList.removeLast();
    updateRecentFilesMenu();

    setWindowTitle(QString("%1 - Demo for Opc Package").arg(name));

    ui->partListWidget->addItem("/");
    foreach (Opc::PackagePart *part, m_package->parts())
        ui->partListWidget->addItem(part->partName());
    return true;
}
Example #2
0
static NexasPackage* openPackage(const wchar_t* packagePath) {
	NexasPackage* package = malloc(sizeof(NexasPackage));
	memset(package, 0, sizeof(NexasPackage));
	if (!(package->file = _wfopen(packagePath, L"wb"))) {
		writeLog(LOG_QUIET, L"ERROR: Cannot open the package file.");
		closePackage(package);
		return NULL;
	}
	writeLog(LOG_VERBOSE, L"Package Opened.");
	return package;
}
Example #3
0
bool packPackage(const wchar_t* sourceDir, const wchar_t* packagePath, bool isBfeFormat) {
	writeLog(LOG_NORMAL, L"Packing files under directory: %s", sourceDir);
	writeLog(LOG_NORMAL, L"To package: %s", packagePath);
	NexasPackage* package = openPackage(packagePath);
	if (!package) return false;
	bool result = determineEntryCountAndWriteHeader(package, sourceDir, isBfeFormat)
			&& recordAndWriteEntries(package, isBfeFormat)
			&& writeIndexes(package, isBfeFormat);
	closePackage(package);
	writeLog(LOG_NORMAL, (result) ? L"Packing Successful." : L"ERROR: Packing Failed.");
	return result;
}
Example #4
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;
}
VisualizeSquareMazeRunner::~VisualizeSquareMazeRunner ()
{
  closePackage();
}
Example #6
0
MainWindow::~MainWindow()
{
    if (m_package)
        closePackage();
    delete ui;
}
Example #7
0
void MainWindow::onActionCloseTriggered()
{
    if (!m_package)
        return;
    closePackage();
}