Example #1
0
bool Inscription::ecrireFichier(){
    QString statut;
    if(radioStatutCanadien->isChecked()){
        statut = "Canadien";
    }
    else{
        statut = "Non canadien";
    }
 
    QString langue;
    if(checkLangueFrancais->isChecked()){
        langue = "Français";
        if(checkLangueAnglais->isChecked()){
            langue += ", anglais";
        }
    }
    else{
        langue = "Anglais";
    }
 
    QFile fileInfos(txtConnectionUsager->text() + ".txt");
    if (!fileInfos.open(QIODevice::WriteOnly | QIODevice::Text))
        return false;
    QTextStream outInfos(&fileInfos);
    outInfos << "Nom : " << txtPersoNom->text() << "\n"
             << "Prénom : " << txtPersoPrenom->text() << "\n"
             << "Date de naissance : " << datePersoNaissance->date().toString() << "\n"
             << "Numéro de téléphone : " << txtPersoTelephone->text() << "\n"
             << "\n"
             << "Numéro civique : " << txtAddrNumero->text() << "\n"
             << "Rue : " << txtAddrRue->text() << "\n"
             << "Ville : " << txtAddrVille->text() << "\n"
             << "Province : " << comboAddrProvince->currentText() << "\n"
             << "Code postal : " << txtAddrCodePostal->text() << "\n"
             << "\n"
             << "Statut : " << statut << "\n"
             << "\n"
             << "Langue(s) : " << langue << "\n";
    fileInfos.close();
 
    QFile fileLogin(txtConnectionUsager->text() + ".bin");
    if (!fileLogin.open(QIODevice::WriteOnly | QIODevice::Text))
        return false;
    QTextStream outLogin(&fileLogin);
    outLogin << txtConnectionMDP->text();
    fileLogin.close();
 
    QFile fileCash(txtConnectionUsager->text() + ".dat");
    if (!fileCash.open(QIODevice::WriteOnly | QIODevice::Text))
        return false;
    QTextStream outCash(&fileCash);
    outCash << 0;
    fileCash.close();
    return true;
}
Example #2
0
// see bsa.h
bool BSA::open()
{
	QMutexLocker lock( & bsaMutex );
	
	try
	{
		if ( ! bsa.open( QIODevice::ReadOnly ) )
			throw QString( "file open" );
		
		quint32 magic, version;
		
		bsa.read( (char*) &magic, sizeof( magic ) );
		
		if ( magic == OB_BSAHEADER_FILEID )
		{
			bsa.read( (char*) &version, sizeof( version ) );
			
			if ( version != OB_BSAHEADER_VERSION && version != F3_BSAHEADER_VERSION )
				throw QString( "file version" );
			
			OBBSAHeader header;
			
			if ( bsa.read( (char *) & header, sizeof( header ) ) != sizeof( header ) )
				throw QString( "header size" );
			
			//qWarning() << bsaName << header;
			
			if ( ( header.ArchiveFlags & OB_BSAARCHIVE_PATHNAMES ) == 0 || ( header.ArchiveFlags & OB_BSAARCHIVE_FILENAMES ) == 0 )
				throw QString( "header flags" );
			
			compressToggle = header.ArchiveFlags & OB_BSAARCHIVE_COMPRESSFILES;
			
			if (version == F3_BSAHEADER_VERSION) {
				namePrefix = header.ArchiveFlags & F3_BSAARCHIVE_PREFIXFULLFILENAMES;
			} else {
				namePrefix = false;
			}
			
			if ( ! bsa.seek( header.FolderRecordOffset + header.FolderNameLength + header.FolderCount * ( 1 + sizeof( OBBSAFolderInfo ) ) + header.FileCount * sizeof( OBBSAFileInfo ) ) )
				throw QString( "file name seek" );
			
			QByteArray fileNames( header.FileNameLength, char(0) );
			if ( bsa.read( fileNames.data(), header.FileNameLength ) != header.FileNameLength )
				throw QString( "file name read" );
			quint32 fileNameIndex = 0;
			
			// qDebug() << file.pos() - header.FileNameLength << fileNames;
			
			if ( ! bsa.seek( header.FolderRecordOffset ) )
				throw QString( "folder info seek" );
			
			QVector<OBBSAFolderInfo> folderInfos( header.FolderCount );
			if ( bsa.read( (char *) folderInfos.data(), header.FolderCount * sizeof( OBBSAFolderInfo ) ) != header.FolderCount * sizeof( OBBSAFolderInfo ) )
				throw QString( "folder info read" );
			
			quint32 totalFileCount = 0;
			
			foreach ( OBBSAFolderInfo folderInfo, folderInfos )
			{
				// useless?
				/*
				qDebug() << __LINE__ << "position" << bsa.pos() << "offset" << folderInfo.offset;
				if ( folderInfo.offset < header.FileNameLength || ! bsa.seek( folderInfo.offset - header.FileNameLength ) )
					throw QString( "folder content seek" );
				*/
				
				
				QString folderName;
				if ( ! BSAReadSizedString( bsa, folderName ) || folderName.isEmpty() )
				{
					//qDebug() << "folderName" << folderName;
					throw QString( "folder name read" );
				}
				
				// qDebug() << folderName;
				
				BSAFolder * folder = insertFolder( folderName );
				
				quint32 fcnt = folderInfo.fileCount;
				totalFileCount += fcnt;
				QVector<OBBSAFileInfo> fileInfos( fcnt );
				if ( bsa.read( (char *) fileInfos.data(), fcnt * sizeof( OBBSAFileInfo ) ) != fcnt * sizeof( OBBSAFileInfo ) )
					throw QString( "file info read" );
				
				foreach ( OBBSAFileInfo fileInfo, fileInfos )
				{
					if ( fileNameIndex >= header.FileNameLength )
						throw QString( "file name size" );
					
					QString fileName = ( fileNames.data() + fileNameIndex );
					fileNameIndex += fileName.length() + 1;
					
					insertFile( folder, fileName, fileInfo.sizeFlags, fileInfo.offset );
				}
			}
			
			if ( totalFileCount != header.FileCount )
				throw QString( "file count" );
		}
void VJSLanguageSyntaxTester::_ParseFile( XBOX::VJSParms_callStaticFunction &ioParams, void * )
{
	// The caller has passed us the path to the symbol table and the path to the file to be
	// parsed.  We want to parse that file and then return back to the caller once the
	// parsing is complete.
	
	// We are expecting 4 parameters.  One for the path to the symbol table,
	// one for the path to the test file
	if (ioParams.CountParams() < 4)	return;

	VString symTablePathStr, testFilePathStr, testFileBaseFolderStr, testFileExecContextStr;

	if (!ioParams.GetStringParam( 1, symTablePathStr ))	return;
	if (!ioParams.GetStringParam( 2, testFilePathStr ))	return;
	if (!ioParams.GetStringParam( 3, testFileBaseFolderStr ))	return;
	if (!ioParams.GetStringParam( 4, testFileExecContextStr ))	return;

	VFilePath testFilePath( testFilePathStr, FPS_POSIX);
	
	if ( ! testFilePath.IsValid() )
		return;

	ESymbolFileBaseFolder	baseFolder;
	ESymbolFileExecContext	execContext;

	// Get file base folder
	if (testFileBaseFolderStr == CVSTR("project"))
		baseFolder = eSymbolFileBaseFolderProject;
	else if (testFileBaseFolderStr == CVSTR("jsf"))
		baseFolder = eSymbolFileBaseFolderStudio;
	else
		return;

	// Get file execution context
	if (testFileExecContextStr == CVSTR("client"))
		execContext = eSymbolFileExecContextClient;
	else if (testFileExecContextStr == CVSTR("server"))
		execContext = eSymbolFileExecContextServer;
	else if (testFileExecContextStr == CVSTR("both"))
		execContext = eSymbolFileExecContextClientServer;
	else
		return;

	VFilePath			symbolTablePath( symTablePathStr, FPS_POSIX);

	if ( ! symbolTablePath.IsValid() )
		return;
	
	CLanguageSyntaxComponent *languageSyntax = (CLanguageSyntaxComponent *)VComponentManager::RetainComponent( (CType)CLanguageSyntaxComponent::Component_Type );
	if (languageSyntax)
	{
		// First, load up the symbol table as an actual table instead of just a path string
		ISymbolTable *symTable = languageSyntax->CreateSymbolTable();
		if (symTable)
		{
			VFile file(symbolTablePath);

			if (symTable->OpenSymbolDatabase( file))
			{
				IDocumentParserManager *parserManager = languageSyntax->CreateDocumentParserManager();
				// Limit parser waiter scope as destructor will disconnect parsing signal
				{
					ParsingWaiter	waiter( parserManager);
					VString			extension;

					testFilePath.GetExtension(extension);
					if ( extension == CVSTR("waModel") )
					{
						VLanguageSyntaxTesterCatalog* catalog = new VLanguageSyntaxTesterCatalog( testFilePath );

						parserManager->ScheduleTask( (const void *)0xFEEDFACE, catalog, waiter.GetCookie(), symTable, IDocumentParserManager::kPriorityAboveNormal);
						catalog->Release();
					}
					else
					{
						VSymbolFileInfos	fileInfos(testFilePath, baseFolder, execContext);

						parserManager->ScheduleTask( (const void *)0xFEEDFACE, /* Just needs to be unique per scheduler, but since this is a static method, there is no this pointer*/
													 fileInfos, waiter.GetCookie(), symTable, IDocumentParserManager::kPriorityAboveNormal );
					}
					waiter.Wait();
				}
				parserManager->Release();
			}
			symTable->Release();
		}
		languageSyntax->Release();
	}
}