Example #1
0
void ProjectView::slotProject(int id)
{
	ProjectViewItem *item = dynamic_cast<ProjectViewItem*>(currentItem());
	if(item) {
		if(item->type() == KileType::Project) {
			switch(id) {
				case KPV_ID_BUILDTREE:
					emit(buildProjectTree(item->url()));
				break;
				case KPV_ID_OPTIONS:
					emit(projectOptions(item->url()));
				break;
				case KPV_ID_CLOSE:
					emit(closeProject(item->url()));
				return; //don't access "item" later on
				case KPV_ID_ARCHIVE:
					emit(projectArchive(item->url()));
				break;
				case KPV_ID_ADDFILES:
					emit(addFiles(item->url()));
				break;
				case KPV_ID_OPENALLFILES:
					emit(openAllFiles(item->url()));
				break;
				default:
				break;
			}
		}
	}
}
Example #2
0
    Database::Database(TransactionExperiment* txn, const char *nm, bool& newDb, const string& path )
        : _name(nm), _path(path),
          _namespaceIndex( _path, _name ),
          _extentManager(new MmapV1ExtentManager(_name, _path, storageGlobalParams.directoryperdb)),
          _profileName(_name + ".system.profile"),
          _namespacesName(_name + ".system.namespaces"),
          _indexesName(_name + ".system.indexes"),
          _collectionLock( "Database::_collectionLock" )
    {
        Status status = validateDBName( _name );
        if ( !status.isOK() ) {
            warning() << "tried to open invalid db: " << _name << endl;
            uasserted( 10028, status.toString() );
        }

        try {
            newDb = _namespaceIndex.exists();
            _profile = serverGlobalParams.defaultProfile;
            checkDuplicateUncasedNames(true);

            // If already exists, open.  Otherwise behave as if empty until
            // there's a write, then open.
            if (!newDb) {
                _namespaceIndex.init( txn );
                openAllFiles(txn);

                // upgrade freelist
                string oldFreeList = _name + ".$freelist";
                NamespaceDetails* details = _namespaceIndex.details( oldFreeList );
                if ( details ) {
                    if ( !details->firstExtent().isNull() ) {
                        _extentManager->freeExtents(txn,
                                                    details->firstExtent(),
                                                    details->lastExtent());
                    }
                    _namespaceIndex.kill_ns( txn, oldFreeList );
                }
            }
            _magic = 781231;
        }
        catch(std::exception& e) {
            log() << "warning database " << path << " " << nm << " could not be opened" << endl;
            DBException* dbe = dynamic_cast<DBException*>(&e);
            if ( dbe != 0 ) {
                log() << "DBException " << dbe->getCode() << ": " << e.what() << endl;
            }
            else {
                log() << e.what() << endl;
            }
            _extentManager.reset();
            throw;
        }
    }
Example #3
0
    Database::Database(const char *nm, bool& newDb, const string& _path )
        : name(nm), path(_path), namespaceIndex( path, name ), 
          profileName(name + ".system.profile")
    {
        
        { // check db name is valid
            size_t L = strlen(nm);
            uassert( 10028 ,  "db name is empty", L > 0 );
            uassert( 10029 ,  "bad db name [1]", *nm != '.' );
            uassert( 10030 ,  "bad db name [2]", nm[L-1] != '.' );
            uassert( 10031 ,  "bad char(s) in db name", strchr(nm, ' ') == 0 );
            uassert( 10032 ,  "db name too long", L < 64 );
        }
        
        newDb = namespaceIndex.exists();
        profile = 0;

        {
            vector<string> others;
            getDatabaseNames( others , path );
            
            for ( unsigned i=0; i<others.size(); i++ ){

                if ( strcasecmp( others[i].c_str() , nm ) )
                    continue;

                if ( strcmp( others[i].c_str() , nm ) == 0 )
                    continue;
                
                stringstream ss;
                ss << "db already exists with different case other: [" << others[i] << "] me [" << nm << "]";
                uasserted( DatabaseDifferCaseCode , ss.str() );
            }
        }

        
        // If already exists, open.  Otherwise behave as if empty until
        // there's a write, then open.
        if ( ! newDb || cmdLine.defaultProfile ) {
            namespaceIndex.init();
            if( _openAllFiles )
                openAllFiles();
            
        }
       

        magic = 781231;
    }
Example #4
0
    Database::Database(const char *nm, bool& newDb, const string& path )
        : _name(nm), _path(path),
          _namespaceIndex( _path, _name ),
          _extentManager( _name, _path, directoryperdb /* this is a global right now */ ),
          _profileName(_name + ".system.profile"),
          _namespacesName(_name + ".system.namespaces"),
          _collectionLock( "Database::_collectionLock" )
    {
        Status status = validateDBName( _name );
        if ( !status.isOK() ) {
            warning() << "tried to open invalid db: " << _name << endl;
            uasserted( 10028, status.toString() );
        }

        try {
            newDb = _namespaceIndex.exists();
            _profile = cmdLine.defaultProfile;
            checkDuplicateUncasedNames(true);

            // If already exists, open.  Otherwise behave as if empty until
            // there's a write, then open.
            if (!newDb) {
                _namespaceIndex.init();
                openAllFiles();
            }
            _magic = 781231;
        }
        catch(std::exception& e) {
            log() << "warning database " << path << " " << nm << " could not be opened" << endl;
            DBException* dbe = dynamic_cast<DBException*>(&e);
            if ( dbe != 0 ) {
                log() << "DBException " << dbe->getCode() << ": " << e.what() << endl;
            }
            else {
                log() << e.what() << endl;
            }
            _extentManager.reset();
            throw;
        }
    }