Ejemplo n.º 1
0
void SaveSetting::find_file()
{
    QDir dir(filename);
    //qDebug()<<"***********findfilepathname="<<filename;
    QStringList currentDirs = dir.entryList(QDir::Dirs, QDir::Name);
    QStringList filters;
    filters <<"*.xml";
    foreach (QString sContentDir, currentDirs)
    {
        int addCount = 0;//璁板綍宸茬粡妫�绱㈠埌鐨勬枃浠朵釜鏁?
        if(isNOExit)
        {
            QDir findDir(filename+QString(QDir::separator())+ sContentDir);//鏂囦欢鐨勭粷瀵硅矾寰?
            findDir.setNameFilters(filters);
            findDir.setSorting(QDir::DirsFirst|QDir::Name);
            QFileInfoList fl = findDir.entryInfoList( QDir::Files );
            while(!fl.isEmpty())
            {
                if(isNOExit)
                {
                    if(addCount >= 1000)
                    {
                        isNOExit = true;
                        //emit findDiskPathFinished();
                    }
                    QString tmp = fl.takeFirst().absoluteFilePath();
                    //qDebug()<<"find -------------------------------------------- "<<tmp<<addCount;
                    findDiskPathName(tmp, addCount);
                    addCount++;
                }
            }
        }
    }
Ejemplo n.º 2
0
uint32 mkDir (uint8 *parentDirName, uint8 *dirName) {
	dirEntry_t *parentDir = findDir (parentDirName);
	
	dirEntry_t *newRootDir = kmalloc (sizeof (dirEntry_t));
	newRootDir->extent = newRootDir;
	newRootDir->name = (uint8 *) ".";
	newRootDir->file = 0;

	dirEntry_t *newDir = kmalloc (sizeof (dirEntry_t));
	newDir->extent = parentDir;
	newDir->name = (uint8 *) "..";
	newRootDir->nextDir = newDir;
	newDir->nextDir = (dirEntry_t *) -1;
	newDir->file = 0;
	
	newDir = kmalloc (sizeof (dirEntry_t));
	newDir->extent = newRootDir;
	newDir->name = dirName;
	newDir->nextDir = (dirEntry_t *) -1;
	newDir->file = 0;

	while (parentDir->nextDir != (dirEntry_t *) -1) {
		parentDir = parentDir->nextDir;	
	}
	
	parentDir->nextDir = newDir;

	return 0;
}
Ejemplo n.º 3
0
uint32 listDir (uint8 *dir) {
	dirEntry_t *currentDir = findDir (dir);
	do {
		kprintf ("%s ", currentDir->name);
		currentDir = currentDir->nextDir;
	} while (currentDir != (dirEntry_t *) -1);
	kprintf ("\n");
	return 0;
}
Ejemplo n.º 4
0
	void addDir(const string &dir)
	{
		DirList::iterator it;
		if(!findDir(it, dir))
		{
			dirs[dir] = Dir();
			findDir(it, dir);

			// Add to parent list

			string current = dir;
			DirList::iterator currentIt = it;

			for(int i = 0; ; ++i)
			{
				string parent;
				getDirPart(current, parent);
				if(parent.empty())
					break;

				bool needAdd = false;

				DirList::iterator parentIt;
				if(!findDir(parentIt, parent))
				{
					dirs[parent] = Dir();
					findDir(parentIt, parent);
					needAdd = true;
				}

				parentIt->second.subDirs.push_back(currentIt);
				if(!needAdd)
					break;

				current = parent;
				currentIt = parentIt;
			}
		}
	}
Ejemplo n.º 5
0
bool FSFileFind::FindFileInDir(const unicode_t *path)
{
	Close();

	UniString	findDir(path);

	if ( findDir.EndWith(USTR("\\*.*")) )
	{
		findDir.Left(findDir.GetCount() - 4, mFilePath);
	}
	else if ( findDir.GetLastChar() == '\\' )
	{
		findDir.Left(findDir.GetCount() - 1, mFilePath);
		findDir += L"*.*";
	}
	else
	{
		mFilePath = findDir;
		findDir += L"\\*.*";
	}

	if ( !FSExistDirectory(mFilePath) ) return false;

#if defined(WIN32) || defined(_WIN32_WCE)

/*
	if ( !findDir.EndWith(USTR("\\*.*")) )
	{
		if ( findDir.GetLastChar() == '\\' )
			findDir += L"*.*";
		else
			findDir += L"\\*.*";
	}
	findDir.Left(findDir.GetCount() - 4, mFilePath);
*/
	
#if defined(_WIN32_WCE)
	mFind = FindFirstFile(findDir.GetString(), &mFindFileData);
#else
	mFind = FindFirstFileW(findDir.GetString(), &mFindFileData);
#endif

	return (mFind != INVALID_HANDLE_VALUE);

#else


#endif

	return false;
}
Ejemplo n.º 6
0
STATIC enum cacheRet maybeCache( const char *fullpath, CENTRYPTR *pc )
/********************************************************************/
{
    char            path[_MAX_PATH];
    char            name[NAME_MAX + 1];
    DHEADPTR        dcur;
    CENTRYPTR       centry;
    enum cacheRet   ret;
    PGROUP          pg;
    char const      *ext;

    assert( fullpath != NULL );

    _splitpath2( fullpath, pg.buffer, &pg.drive, &pg.dir, &pg.fname, &pg.ext );
    _makepath( path, pg.drive, pg.dir, NULL, NULL );
    ext = pg.ext;
    if( ext[0] == '.' && ext[1] == 0 ) {
        ext = NULL;
    }
    _makepath( name, NULL, NULL, pg.fname, ext );

    FixName( path );
    FixName( name );

    dcur = findDir( path );
    if( dcur == NULL ) {        /* must cache new directory */
        ret = cacheDir( &dcur, path );
        if( ret != CACHE_OK ) {
            return( ret );
        }
        dcur->dh_next = cacheHead;
        cacheHead = dcur;
    }

    /* now dcur points to Cached directory */
    assert( dcur != NULL );

    centry = findFile( dcur, name );
    if( centry == NULL ) {
        return( CACHE_FILE_NOT_FOUND );
    }

    if( pc != NULL ) {
        *pc = centry;
    }

    return( CACHE_OK );
}
Ejemplo n.º 7
0
uint32 mkFile (uint8 *dirName, uint8 *name) {
	dirEntry_t *dir = findDir (dirName);
	
	dirEntry_t *newFile = kmalloc (sizeof (dirEntry_t));	//file is represented as a directory entry, just like a directory
	newFile->name = name;					//the only difference is it's extent points to the first block of the file, rather than another
	newFile->nextDir = (dirEntry_t *) -1;			//directory entry
	newFile->file = 1;
	newFile->extent = kmalloc (2048);
	
	while (dir->nextDir != (dirEntry_t *) -1) {
		dir = dir->nextDir;
	}	

	dir->nextDir = newFile;

	return 0;
}
Ejemplo n.º 8
0
STATIC enum cacheRet maybeCache( const char *fullpath, CENTRYPTR *pc )
/********************************************************************/
{
    char            path[_MAX_PATH];
    char            name[NAME_MAX + 1];
    DHEADPTR        dcur;
    CENTRYPTR       centry;
    enum cacheRet   ret;

    assert( fullpath != NULL );

    splitFullPath( fullpath, path, name );
    FixName( path );
    FixName( name );

    dcur = findDir( path );
    if( dcur == NULL ) {        /* must cache new directory */
        ret = cacheDir( &dcur, path );
        if( ret != CACHE_OK ) {
            return( ret );
        }
        dcur->dh_next = cacheHead;
        cacheHead = dcur;
    }

    /* now dcur points to Cached directory */
    assert( dcur != NULL );

    centry = findFile( dcur, name );
    if( centry == NULL ) {
        return( CACHE_FILE_NOT_FOUND );
    }

    if( pc != NULL ) {
        *pc = centry;
    }

    return( CACHE_OK );
}
Ejemplo n.º 9
0
CupsdConf::CupsdConf()
{
    // start by trying to find CUPS directories (useful later)
    datadir_ = findDir(QStringList("/usr/share/cups") << "/usr/local/share/cups"
                                                      << "/opt/share/cups"
                                                      << "/opt/local/share/cups");
    documentdir_ = findDir(QStringList(datadir_ + "/doc") << datadir_.left(datadir_.length() - 5) + "/doc/cups");
    // fontpath_ << (datadir_+"/fonts");
    requestdir_ = findDir(QStringList("/var/spool/cups") << "/var/cups");
    serverbin_ = findDir(QStringList("/usr/lib" KDELIBSUFF "/cups") << "/usr/local/lib" KDELIBSUFF "/cups"
                                                                    << "/opt/lib" KDELIBSUFF "/cups"
                                                                    << "/opt/local/lib" KDELIBSUFF "/cups");
    serverfiles_ = findDir(QStringList("/etc/cups") << "/usr/local/etc/cups");
    tmpfiles_ = requestdir_ + "/tmp";

    // other options
    servername_ = QString::null;
    serveradmin_ = QString::null;
    classification_ = CLASS_NONE;
    otherclassname_ = QString::null;
    classoverride_ = false;
    charset_ = "utf-8";
    language_ = "en";
    printcap_ = "/etc/printcap";
    printcapformat_ = PRINTCAP_BSD;
    remoteroot_ = "remroot";
    systemgroup_ = "sys";
    encryptcert_ = serverfiles_ + "/ssl/server.crt";
    encryptkey_ = serverfiles_ + "/ssl/server.key";
    hostnamelookup_ = HOSTNAME_OFF;
    keepalive_ = true;
    keepalivetimeout_ = 60;
    maxclients_ = 100;
    maxrequestsize_ = "0";
    clienttimeout_ = 300;
    // listenaddresses_
    QString logdir = findDir(QStringList("/var/log/cups") << "/var/spool/cups/log"
                                                          << "/var/cups/log");
    accesslog_ = logdir + "/access_log";
    errorlog_ = logdir + "/error_log";
    pagelog_ = logdir + "/page_log";
    maxlogsize_ = "1m";
    loglevel_ = LOGLEVEL_INFO;
    keepjobhistory_ = true;
    keepjobfiles_ = false;
    autopurgejobs_ = false;
    maxjobs_ = 0;
    maxjobsperprinter_ = 0;
    maxjobsperuser_ = 0;
    user_ = "lp";
    group_ = "sys";
    ripcache_ = "8m";
    filterlimit_ = 0;
    browsing_ = true;
    browseprotocols_ << "CUPS";
    browseport_ = ippPort();
    browseinterval_ = 30;
    browsetimeout_ = 300;
    // browseaddresses_
    browseorder_ = ORDER_ALLOW_DENY;
    useimplicitclasses_ = true;
    hideimplicitmembers_ = true;
    useshortnames_ = true;
    useanyclasses_ = false;

    loadAvailableResources();
}
Ejemplo n.º 10
0
/* determines in which direction to fire.
   mode 0 fires straight ahead.
   mode 1 in a random direction.
   mode 2 aims at the current position of the closest player,
          then limits that to the sector in front of the cannon,
          then adds a small error.
   mode 3 calculates where the player will be when the shot reaches her,
          checks if that position is within limits and selects the player
          who will be closest in this way.
   the targeted player is also returned (for all modes).
   mode 0 always fires if it sees a player.
   modes 1 and 2 only fire if a player is within range of the selected weapon.
   mode 3 only fires if a player will be in range when the shot is expected to hit.
 */
static void Cannon_aim(cannon_t *c, int weapon, player_t **pl_p, int *dir)
{
    double speed = Cannon_get_shot_speed(c);
    double range = Cannon_get_max_shot_life(c) * speed;
    double visualrange = (CANNON_DISTANCE
			      + 2 * c->item[ITEM_SENSOR] * BLOCK_SZ);
    bool found = false, ready = false;
    double closest = range;
    int ddir, i, smartness = Cannon_get_smartness(c);

    switch (weapon) {
    case CW_MINE:
	speed = speed * 0.5 + 0.1 * smartness;
	range = range * 0.5 + 0.1 * smartness;
	break;
    case CW_LASER:
	speed = options.pulseSpeed;
	range = CANNON_PULSE_LIFE * speed;
	break;
    case CW_ECM:
	/* smarter cannons wait a little longer before firing an ECM */
	if (smartness > 1)
	    range = ((ECM_DISTANCE / smartness
		      + (rfrac() * (int)(ECM_DISTANCE
					 - ECM_DISTANCE / smartness))));
	else
	    range = ECM_DISTANCE;
	break;
    case CW_TRACTORBEAM:
	range = TRACTOR_MAX_RANGE(c->item[ITEM_TRACTOR_BEAM]);
	break;
    case CW_TRANSPORTER:
	/* smarter cannons have a smaller chance of using a transporter when
	   target is out of range */
	if (smartness > 2
	    || (int)(rfrac() * sqr(smartness + 1)))
	    range = TRANSPORTER_DISTANCE;
	break;
    case CW_GASJET:
	if (c->item[ITEM_EMERGENCY_THRUST]) {
	    speed *= 2.0;
	    range *= 2.0;
	}
	break;
    default:
	/* no need to do anything specail for this weapon. */
	break;
    }

    for (i = 0; i < NumPlayers && !ready; i++) {
	player_t *pl = Player_by_index(i);
	double tdist, tdx, tdy;

        /* KHS: cannon dodgers mode:               */
	/* Cannons fire on players in any range    */
	tdx = WRAP_DCX(pl->pos.cx - c->pos.cx) / CLICK;
	if (ABS(tdx) >= visualrange
	    && options.survivalScore == 0.0)
 	    continue;
	tdy = WRAP_DCY(pl->pos.cy - c->pos.cy) / CLICK;
	if (ABS(tdy) >= visualrange
	    && options.survivalScore == 0.0)
	    continue;
	tdist = LENGTH(tdx, tdy);
	if (tdist > visualrange
	    && options.survivalScore == 0.0)
	    continue;

	/* mode 3 also checks if a player is using a phasing device */
	if (Player_is_paused(pl)
	    || (BIT(world->rules->mode, TEAM_PLAY)
		&& pl->team == c->team)
	    || ((pl->forceVisible <= 0)
		&& Player_is_cloaked(pl)
		&& (int)(rfrac() * (pl->item[ITEM_CLOAK] + 1))
		   > (int)(rfrac() * (c->item[ITEM_SENSOR] + 1)))
	    || (smartness > 2
		&& Player_is_phasing(pl)))
	    continue;

	switch (smartness) {
	case 0:
	    ready = true;
	    break;
	default:
	case 1:
	    
	    /* KHS disable this range check, too */
            /* in cannon dodgers */
	    if (tdist < range 
		|| options.survivalScore != 0.0)
		ready = true;
	    break;
	case 2:
	    if (tdist < closest) {
		double a = findDir(tdx, tdy);
		*dir = (int) a;
		found = true;
	    }
	    break;
	case 3:
	    if (tdist < range) {
		double a, t = tdist / speed; /* time */
		int npx = (int)(pl->pos.cx
				+ pl->vel.x * t * CLICK
				+ pl->acc.x * t * t * CLICK);
		int npy = (int)(pl->pos.cy
				+ pl->vel.y * t * CLICK
				+ pl->acc.y * t * t * CLICK);
		int tdir;

		tdx = WRAP_DCX(npx - c->pos.cx) / CLICK;
		tdy = WRAP_DCY(npy - c->pos.cy) / CLICK;
		a = findDir(tdx, tdy);
		tdir = (int) a;
		ddir = MOD2(tdir - c->dir, RES);
		if ((ddir < (CANNON_SPREAD * 0.5)
		     || ddir > RES - (CANNON_SPREAD * 0.5))
		    && LENGTH(tdx, tdy) < closest) {
		    *dir = tdir;
		    found = true;
		}
	    }
	    break;
	}
	if (found || ready) {
	    closest = tdist;
	    *pl_p = pl;
	}
    }
    if (!(found || ready)) {
	*pl_p = NULL;
	return;
    }

    switch (smartness) {
    case 0:
	*dir = c->dir;
	break;
    default:
    case 1:
	*dir = c->dir;
	*dir += (int)((rfrac() - 0.5f) * CANNON_SPREAD);
	break;
    case 2:
	ddir = MOD2(*dir - c->dir, RES);
	if (ddir > (CANNON_SPREAD * 0.5) && ddir < RES / 2)
	    *dir = (int)(c->dir + (CANNON_SPREAD * 0.5) + 3);
	else if (ddir < RES - (CANNON_SPREAD * 0.5) && ddir > RES / 2)
	    *dir = (int)(c->dir - (CANNON_SPREAD * 0.5) - 3);
	*dir += (int)(rfrac() * 7) - 3;
	break;
    case 3:
	/* nothing to be done for mode 3 */
	break;
    }
    *dir = MOD2(*dir, RES);
}
Ejemplo n.º 11
0
uint32 openFS (uint8 *filename, uint32 bus, uint8 drive) {	//bus and drive are needed to maintain compatibility with ATAPI driver - figure out
	return 	(uint32) findDir (filename);			//a way to pass that info to ATAPI driver in a way which doesn't make this necessary for other drivers
}
Ejemplo n.º 12
0
void FSDeleteFolderAndFiles(const unicode_t *dirName)
{
	if ( dirName == NULL ) return;
	if ( *dirName == 0 ) return;

#if defined(WIN32) || defined(_WIN32_WCE)

	UniString	findDir(dirName);

	if ( !findDir.EndWith(USTR("\\*.*")) )
	{
		if ( findDir.GetLastChar() == '\\' )
			findDir += L"*.*";
		else
			findDir += L"\\*.*";

		if ( findDir.GetCount() <= 6 ) return;
	}
	else
	{
		if ( findDir.GetCount() <= 6 ) return;
	}

	HANDLE hFind;

#if defined(_WIN32_WCE)
	WIN32_FIND_DATA findFileData;
	hFind = FindFirstFile(findDir.GetString(), &findFileData);
#else
	WIN32_FIND_DATAW findFileData;
	hFind = FindFirstFileW(findDir.GetString(), &findFileData);
#endif

	if (hFind != INVALID_HANDLE_VALUE) 
	{
		UniString	filePath;

		do
		{
			if ( wcscmp(findFileData.cFileName, L".") == 0 || wcscmp(findFileData.cFileName, L"..") == 0 )
				continue;

			filePath = dirName;
			filePath += L"\\";
			filePath += findFileData.cFileName;

			if ( findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
			{
				FSDeleteFolderAndFiles(filePath);
			}
			else
			{
				if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
					SetFileAttributesW(filePath.GetString(), FILE_ATTRIBUTE_NORMAL);

			#if defined(_WIN32_WCE)
				DeleteFile(filePath);
			#else
				DeleteFileW(filePath);
			#endif
			}
		}
	#if defined(_WIN32_WCE)
		while (FindNextFile(hFind, &findFileData) != 0);
	#else
		while (FindNextFileW(hFind, &findFileData) != 0);
	#endif

		FindClose(hFind);
	}

	RemoveDirectoryW(dirName);

#elif defined(__APPLE_CPP__) || defined(__APPLE_CC__)
	FSString	fsString(dirName);
	
	if ( fsString.GetCount() <= 1 ) return;

	_DeleteFolderAndFiles(fsString.GetString());
#else
	FSString	fsString(dirName);
	_DeleteFolderAndFiles(fsString.GetString());
#endif
}