TVerdict CAddDriveStep::runTestStepL(TBool /*aOomTest*/)
    {
    TPtrC str;
    TInt drive(0);
    if (!GetStringFromConfig(ConfigSection(), _L("drive"), str))
        {
        ERR_PRINTF1(_L("Missing drive setting"));
        SetTestStepResult(EFail);
        }
    else
        {
        RFs fs;
        fs.Connect();
        
        User::LeaveIfError(fs.CharToDrive(str[0], drive));
        //iDriveChar = str[0];
        fs.Close();
        }
    RSisRegistryWritableSession registrySession;
            
    User::LeaveIfError(registrySession.Connect());
    CleanupClosePushL(registrySession);
    registrySession.AddDriveL(drive);

    CleanupStack::PopAndDestroy(&registrySession);    

    return EPass;
    }
void CScrEMMCComponentStep::ImplTestStepL()
    {
    TInt noOfComponents(0);
    GetIntFromConfig(ConfigSection(), KNoOfComponents, noOfComponents);
    
    TPtrC formatDrive;
    GetStringFromConfig(ConfigSection(), KFormatDrive, formatDrive);
    TInt drive;
    RFs fs;
    User::LeaveIfError(fs.Connect());
    User::LeaveIfError(fs.CharToDrive(formatDrive[0], drive));
    fs.Close();
    TDriveList filterFormatDrive;
    filterFormatDrive.FillZ(KMaxDrives);
    filterFormatDrive[drive] = 1;
        
    CComponentFilter* componentFilter = CComponentFilter::NewLC();
    componentFilter->SetInstalledDrivesL(filterFormatDrive);
            
    RArray<TComponentId> foundComponentIds;
    CleanupClosePushL(foundComponentIds);
        
    iScrSession.GetComponentIdsL(foundComponentIds, componentFilter);
    
    if (foundComponentIds.Count() != noOfComponents)
        {
        ERR_PRINTF1(_L("Mismatch for number of components found."));
        SetTestStepResult(EFail);
        }
    CleanupStack::PopAndDestroy(2);
    }
Exemple #3
0
TInt CurrentDrive()
//
// Return the current drive number
//
	{
	TInt driveNum;
	TInt r = TheFs.CharToDrive(gSessionPath[0],driveNum);
	test_KErrNone(r);
	return(driveNum);
	}
Exemple #4
0
TInt CurrentDrive(TChar aDriveChar)
//
// Return the current drive number
//
	{
	TInt driveNum;
	TInt r = TheFs.CharToDrive(aDriveChar,driveNum);
	test_KErrNone(r);
	gDriveToTest = gSessionPath[0] = (TText)aDriveChar;
	return(driveNum);
	}
//static
TUint32 WidgetUnzipUtilityS60::uncompressedSizeL(const QString& aZipFileName, const TChar& aDriveLetter)
{
    RFs fs;
    User::LeaveIfError(fs.Connect()); // not possible to continue without RFs
    CleanupClosePushL(fs);

    TUint64 uncompressedSize(0);
    TInt allocUnitSize(8192); // use 8kb cluster size when no information is available

    TInt drive(0);
    TInt err = fs.CharToDrive(aDriveLetter, drive);
    // get cluster size to calculate uncompressed widget size more accurately
    if (!err) {
        TVolumeIOParamInfo ioInfo;
        err = fs.VolumeIOParam(drive, ioInfo);

        // VolumeIOParam.iClusterSize contains also possible error code
        if (!err && ioInfo.iClusterSize > 0) {
            allocUnitSize = ioInfo.iClusterSize;
        }
    }

    QString zipFileName = QDir::toNativeSeparators(aZipFileName);

    TPtrC16 zName(reinterpret_cast<const TUint16*>(zipFileName.utf16()));
    CZipFile *zipfile = CZipFile::NewL(fs, zName);
    CleanupStack::PushL(zipfile);

    CZipFileMemberIterator *members = zipfile->GetMembersL();
    CleanupStack::PushL(members);

    CZipFileMember* member = members->NextL();
    while (member != NULL) {
        TUint32 fileSize(member->UncompressedSize());
        if(fileSize != UINT_MAX)
            fileSize = (fileSize + (allocUnitSize - (fileSize % allocUnitSize)));
        uncompressedSize += fileSize;
        delete member;
        member = members->NextL();
    }
    CleanupStack::PopAndDestroy(3);  // members, zipfile, fs.connect

    if(uncompressedSize > UINT_MAX)
        return UINT_MAX;
    return (TUint32)uncompressedSize;
}
// -----------------------------------------------------------------------------
// CbsUtils::VolumeCriticalLevelCheckL
// Leaves with KErrDiskFull if writing aBytesToWrite bytes
// to the RAM File System would reduce the free space on RAM
// under the critical level.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CbsUtils::VolumeCriticalLevelCheckL(
    const TDesC& aFileName,
    TInt aBytesToWrite,
    const RFs& aFs )
{
    // Convert file name to a volume number
    TInt volumeNumber;
    aFs.CharToDrive( aFileName[0], volumeNumber );

    // Find out if the volume has enough free space
    TVolumeInfo volume;
    User::LeaveIfError( aFs.Volume( volume, volumeNumber ) );
    if ( volume.iFree < aBytesToWrite )
    {
        User::Leave( KErrDiskFull );
    }
}
// this function was copied from t_sdpartition.cpp
TInt FindMmcLocalDriveNumber(TChar aDriveChar, TInt& aLocalDriveNum, TInt aDriveNum)
	{
	TInt r = fs.CharToDrive(aDriveChar, aDriveNum);
	test(r==KErrNone);

	TDriveInfo driveInfo;
    r = fs.Drive(driveInfo, aDriveNum);
    test(r==KErrNone);


	TVolumeInfo vi;
	r = fs.Volume(vi, aDriveNum);
    test(r==KErrNone);


	TMediaSerialNumber serialNum;
	r = fs.GetMediaSerialNumber(serialNum, aDriveNum);
    test(r==KErrNone);


    test.Printf(_L("Drive %C size %ld\n"), (char) aDriveChar, vi.iSize);
	TInt len = serialNum.Length();
	test.Printf(_L("Serial number (len %d) :"), len);
	TInt n;
	for (n=0; n<len; n+=16)
		{
		TBuf16<16*3 +1> buf;
		for (TInt m=n; m<n+16; m++)
			{
			TBuf16<3> hexBuf;
			hexBuf.Format(_L("%02X "),serialNum[m]);
			buf.Append(hexBuf);
			}
		buf.Append(_L("\n"));
		test.Printf(buf);
		}

	TBusLocalDrive drv;
	TBool chg(EFalse);
	aLocalDriveNum = -1;
	TInt serialNumbersMatched = 0;
	for (n=0; n<KMaxLocalDrives; n++)
		{
		r = drv.Connect(n, chg); //for user area
//RDebug::Print(_L("TBusLocalDrive::Connect(%d) %d"), n, r);

		if(r != KErrNone)
			{
			test.Printf(_L("drive %d: TBusLocalDrive::Connect() failed %d\n"), n, r);
			continue;
			}	

	    TLocalDriveCapsV5Buf capsBuf;
	    TLocalDriveCapsV5& caps = capsBuf();
		r = drv.Caps(capsBuf);
		if(r != KErrNone)
			{
			test.Printf(_L("drive %d: TBusLocalDrive::Caps() failed %d\n"), n, r);
			continue;
			}	

//RDebug::Print(_L("areaSize %ld cardCapacity %ld"), caps.iSize, caps.iFormatInfo.iCapacity);

		TPtrC8 localSerialNum(caps.iSerialNum, caps.iSerialNumLength);
		if (serialNum.Compare(localSerialNum) == 0)
			{
			serialNumbersMatched++;
			TBool sizeMatch = (vi.iSize < caps.iSize);
			test.Printf(_L("drive %d: Serial number match, size match: %S\n"), n, sizeMatch?&KYes:&KNo);
			if (sizeMatch)
				{
				aLocalDriveNum = n;
				drv.Disconnect();
				break;
				}
			}
		drv.Disconnect();
		}


	return aLocalDriveNum == -1?KErrNotFound:KErrNone;
	}
LOCAL_C void doComponentTest()
    //
    // Do the component test
    //
	{
#ifndef __NO_HEAP_CHECK
	__UHEAP_MARK;
#endif	

    TInt ret;
    test.Printf(_L("Start MountStart test. Be sure MMC card is inserted.\n"));
    // Parse the CommandLine argument: removal drive
    ParseCommandArguments();

    // Connect to the server
    LOG_AND_TEST(KErrNone,  fs.Connect());
	CleanupClosePushL(fs); 
	   
    // Convert drive letter to its numerical equivalent
	ret = fs.CharToDrive(driveLetter,removalDrvNo);
	LOG_AND_TEST(ret,  KErrNone);	

	// Load the logical device
	_LIT(KDriverFileName,"TESTUSBC.LDD");
	ret = User::LoadLogicalDevice(KDriverFileName);
	LOG_AND_TEST(KErrNone, ret);

    // Add MS file system
	_LIT(KMsFsFsy, "MSFS.FSY");
	LOG_AND_TEST(KErrNone, fs.AddFileSystem(KMsFsFsy));
	
    // Start Ms file system
    RUsbMassStorage usbMs;
    CleanupClosePushL(usbMs);

    TMassStorageConfig config;
    
    config.iVendorId.Copy(_L("vendorId"));
    config.iProductId.Copy(_L("productId"));
    config.iProductRev.Copy(_L("rev"));

	ret = usbMs.Connect();
    LOG_AND_TEST(KErrNone, ret);
  
    // Start usb mass storage device
    LOG_AND_TEST(KErrNone , usbMs.Start(config));

    // Format removable drive using FAT FS
    RFormat format;
    TBuf<2> removalDrive;
    removalDrive.Append(driveLetter);
    removalDrive.Append(':');
    TInt tracksRemaining;
    test.Printf(_L("Start MMC card formatting\n"));
    LOG_AND_TEST(KErrNone, format.Open(fs, removalDrive, EHighDensity|EQuickFormat, tracksRemaining));
    while (tracksRemaining)
        {
        test.Printf(_L("."));
        LOG_AND_TEST(KErrNone,  format.Next(tracksRemaining));
        }
    format.Close();
  	test.Printf(_L("\nDone!\n"));

    // Open a session to LDD
    test.Printf(_L("Open LDD\n"));
    LOG_AND_TEST(KErrNone, usbcClient.Open(0));

	test.Printf(_L("Creating CActiveScheduler\n"));
	CActiveScheduler* sched = new(ELeave) CActiveScheduler;
	CleanupStack::PushL(sched);
	CActiveScheduler::Install(sched);
  	
	// Create a state machine
	CStateMachine* sm = CStateMachine::NewL();
	CleanupStack::PushL(sm);
    sm->AddState(EUsbMsDriveState_Disconnected);
    sm->AddState(EUsbMsDriveState_Connecting);
    sm->AddState(EUsbMsDriveState_Connected);
    sm->AddState(EUsbMsDriveState_Disconnecting);
    sm->AddState(EUsbMsDriveState_Active);
    sm->AddState(EUsbMsDriveState_Locked);
    sm->AddState(EUsbMsState_Written);
    sm->AddState(EUsbMsState_Read);
    
    sm->SetInitState(EUsbMsDriveState_Disconnected);

  	CPropertyHandler* driveStatusHandler 	= CMsDriveStatusHandler::NewLC(removalDrvNo, *sm);
  	CPropertyHandler* readStatusHandler 	= CMsReadStatusHandler::NewLC(removalDrvNo, *sm);
  	CPropertyHandler* writtenStatusHandler 	= CMsWrittenStatusHandler::NewLC(removalDrvNo, *sm);
  	
 	CPropertyWatch::NewLC(EUsbMsDriveState_DriveStatus, *driveStatusHandler);
 	CPropertyWatch::NewLC(EUsbMsDriveState_KBytesRead, *readStatusHandler);
 	CPropertyWatch::NewLC(EUsbMsDriveState_KBytesWritten, *writtenStatusHandler);
 	
	CActiveScheduler::Start();

	ret = usbMs.Stop();
	test.Printf(_L("usbMs.Stop returned %d\n"), ret);
	test(ret == KErrNone);
	usbMs.Close();
	// 1 sec delay for MSFS to stop
	User::After(1000000);
	ret = fs.RemoveFileSystem(KMsFs);
	test(ret == KErrNone || ret == KErrNotFound);
	test.Printf(_L("RemoveFileSystem returned %d\n"), ret);

	usbcClient.Close();
	ret = User::FreeLogicalDevice(_L("USBC"));
	test.Printf(_L("FreeLogicalDevice returned %d\n"), ret);
	test(ret == KErrNone);			

	CleanupStack::PopAndDestroy(3);	// 3 CPropertyWatches 
	CleanupStack::PopAndDestroy(3);	// 3 property status change handlers
	CleanupStack::PopAndDestroy(sm);
	CleanupStack::PopAndDestroy(sched);
	CleanupStack::PopAndDestroy(&usbMs);
	CleanupStack::PopAndDestroy(&fs);

#ifndef __NO_HEAP_CHECK
	__UHEAP_MARKEND;
#endif
	}
LOCAL_C TInt testAsyncAccess(TAny* aData)
//
/// Test read file handling.
///
/// @param aData pointer to the thread data area
    {
	TThreadData& data = *(TThreadData*)aData;
	TFileName fileName = data.iFile;
	TBool     dowrite  = (data.iData != NULL);
	TBuf8<KBufLen>* buffer = gBufferArr[data.iNum];
	TRequestStatus* status = gStatusArr[data.iNum];

	RFs   myFs;
	TInt r = myFs.Connect();
	TEST(r==KErrNone);

	r = myFs.SetSessionPath(gSessionPath);
	if (r != KErrNone)
		TTest::Fail(HERE, _L("SetSessionPath returned %d"), r);

	TVolumeInfo vol;
	TInt        drv;
	r = myFs.CharToDrive(fileName[0], drv);
	if (r != KErrNone)
		TTest::Fail(HERE, _L("CharToDrive(%c) returned %d"), fileName[0], r);
	r = myFs.Volume(vol, drv);
	if (r != KErrNone)
		TTest::Fail(HERE, _L("Volume() returned %d"), r);

	TInt64 maxwrite = vol.iFree / 2 - KBufLen;
	if (maxwrite < KBufLen*2)
		TTest::Fail(HERE, _L("Not enough space to do test, only %d KB available"),
					 TInt(vol.iFree/1024));

    RFile f;
	RTimer timer;
	TRequestStatus tstat;
	TTime startTime;
	TTime endTime;
	TTimeIntervalMicroSeconds timeTaken;

	TInt wrnum = 0;
	TInt rdnum = 0;
	TInt opnum = 0;
	TInt opfin = 0;
	TInt i;

	timer.CreateLocal();

	if (dowrite)
		{
		r = f.Replace(myFs, fileName, EFileStreamText | EFileWrite);
		TEST(r==KErrNone);

		// wait for both tasks to have a chance to complete opening the files
		User::After(1000);

		for (i = 0; i < KNumBuf; i++)
			buffer[i].Fill('_', KBufLen);

		timer.After(tstat, KTimeBM * KSecond);

		startTime.HomeTime();

		while (tstat == KRequestPending)
			{
			TInt pos = TInt((wrnum * KBufLen) % maxwrite);
			TInt bnum = opnum++ % KNumBuf;
			f.Write(pos, buffer[bnum], status[bnum]);
			if (opnum - opfin > KMaxLag)
				{
				while (status[opfin % KNumBuf] == KRequestPending)
					User::WaitForRequest(status[opfin % KNumBuf]);
				opfin++;
				}
			++wrnum;
			}

		while (opfin < opnum)
			{
			while (status[opfin % KNumBuf] == KRequestPending)
				User::WaitForRequest(status[opfin % KNumBuf]);
			opfin++;
			}

		endTime.HomeTime();
		TTimeIntervalMicroSeconds timeTaken=endTime.MicroSecondsFrom(startTime);

		TInt64 dtime = timeTaken.Int64();
		TInt64 dsize = wrnum * KBufLen * TInt64(KSecond);
		TInt32 speed = TInt32((dsize + dtime/2) / dtime);
		AddStats(gWrStats, dsize, dtime);

		TTest::Printf(_L("%8d writes in %6d mS = %8d bytes per second\n"),
					  wrnum, TInt32(dtime)/1000, speed);
		}
	else
		{
		r = f.Open(myFs, fileName, EFileStreamText);
		TEST(r==KErrNone);

		timer.After(tstat, KTimeBM * KSecond);

		startTime.HomeTime();

		while (tstat == KRequestPending)
			{
			TInt pos = TInt((rdnum * KBufLen) % maxwrite);
			TInt bnum = opnum++ % KNumBuf;
			f.Read(pos, buffer[bnum], status[bnum]);
			if (opnum - opfin > KMaxLag)
				{
				User::WaitForRequest(status[opfin++ % KNumBuf]);
				}
			++rdnum;
			}

		while (opfin < opnum)
			{
			if (status[opfin % KNumBuf] == KRequestPending)
				User::WaitForRequest(status[opfin % KNumBuf]);
			opfin++;
			}

		endTime.HomeTime();
		timeTaken=endTime.MicroSecondsFrom(startTime);
		TInt64 dtime = timeTaken.Int64();
		TInt64 dsize = rdnum * KBufLen * TInt64(KSecond);
		TInt32 speed = TInt32((dsize + dtime/2) / dtime);
		AddStats(gRdStats, dsize, dtime);

		// wait to allow the dust to settle
		User::After(KSecond);

		TTest::Printf(_L("%8d reads  in %6d mS = %8d bytes per second\n"),
					  rdnum, TInt32(dtime)/1000, speed);

		myFs.Delete(fileName);
		}

	timer.Cancel();
	timer.Close();
	f.Close();
	myFs.Close();
	return r;
    }
bool LongStream::freeSpace( const QString &path, int min)
{
    unsigned long long boundary = minFree;
    if (min >= 0)
        boundary = min;

    QString partitionPath = tempDir() + "/.";
    if (!path.isEmpty())
        partitionPath = path;
    
#if defined(Q_OS_SYMBIAN)
    bool result(false);
   
    RFs fsSession;
    TInt rv;
    if ((rv = fsSession.Connect()) != KErrNone) {
        qDebug() << "Unable to connect to FS:" << rv;
    } else {
        TParse parse;
        TPtrC name(path.utf16(), path.length());

        if ((rv = fsSession.Parse(name, parse)) != KErrNone) {
            qDebug() << "Unable to parse:" << path << rv;
        } else {
            TInt drive;
            if ((rv = fsSession.CharToDrive(parse.Drive()[0], drive)) != KErrNone) {
                qDebug() << "Unable to convert:" << QString::fromUtf16(parse.Drive().Ptr(), parse.Drive().Length()) << rv;
            } else {
                TVolumeInfo info;
                if ((rv = fsSession.Volume(info, drive)) != KErrNone) {
                    qDebug() << "Unable to volume:" << drive << rv;
                } else {
                    result = (info.iFree > boundary);
                }
            }
        }
        
        fsSession.Close();
    }
    
    return result;
#elif !defined(Q_OS_WIN)
    struct statfs stats;

    statfs(partitionPath.toLocal8Bit(), &stats);
    unsigned long long bavail = ((unsigned long long)stats.f_bavail);
    unsigned long long bsize = ((unsigned long long)stats.f_bsize);

    return ((bavail * bsize) > boundary);
#else
    // MS recommend the use of GetDiskFreeSpaceEx, but this is not available on early versions
    // of windows 95.  GetDiskFreeSpace is unable to report free space larger than 2GB, but we're 
    // only concerned with much smaller amounts of free space, so this is not a hindrance.
    DWORD bytesPerSector(0);
    DWORD sectorsPerCluster(0);
    DWORD freeClusters(0);
    DWORD totalClusters(0);

    if (::GetDiskFreeSpace(partitionPath.utf16(), &bytesPerSector, &sectorsPerCluster, &freeClusters, &totalClusters) == FALSE) {
        qWarning() << "Unable to get free disk space:" << partitionPath;
    }

    return ((bytesPerSector * sectorsPerCluster * freeClusters) > boundary);
#endif
}
// Member for thread function
TInt CSMPSoakThread::DoSMPStressDeviceThread()
	{
	RTest test(_L("SMPStressDeviceThread"));
	test.Start(_L("SMPStressDeviceThread"));
	
	RTimer timer;
	RFs session;
	TFileName sessionPath;

	test_KErrNone(timer.CreateLocal());
	TRequestStatus s;

	TDesC** ptrDevices =  (TDesC**) (iThreadData.listPtr);
	PRINT ((_L("Devices  Number %d [%s]\n"), ptrDevices[0]->Length(), ptrDevices[0]->Ptr()));
	for (TInt i = 1; ptrDevices[i] ; i++)
		PRINT ((_L("LDD%d=%s "),i,ptrDevices[i]->Ptr()));
	PRINT (_L("\n"));

	FOREVER
		{
		for (TInt i = 0; i < ptrDevices[0]->Length(); i++)
			{
			TText driveLetter = (*ptrDevices[0])[i];
			PRINT ((_L("Device %c\n"),driveLetter));

			test_KErrNone(session.Connect());

			sessionPath=(_L("?:\\SESSION_TEST\\"));
			sessionPath[0]=driveLetter;
			test_KErrNone(session.SetSessionPath(sessionPath));

			TInt driveNumber;
			test_KErrNone(session.CharToDrive(driveLetter, driveNumber));

			TBuf<64> fileSystemName;
			test_KErrNone(session.FileSystemName(fileSystemName,driveNumber));

			PRINT ((_L("File System Name %s\n"),fileSystemName.PtrZ()));

			TDriveInfo driveInfo;
			test_KErrNone(session.Drive(driveInfo, driveNumber));

			TVolumeInfo volumeInfo;
			test_KErrNone(session.Volume(volumeInfo, driveNumber));

			session.Close();
			}
		for (TInt i = 1; ptrDevices[i] ; i += 2)
			{
			RDevice device;

			TInt r = User::LoadLogicalDevice(*ptrDevices[i]);
			if (r != KErrNone && r != KErrAlreadyExists)
				{
				test.Printf(_L("LDD %S not present\n"), ptrDevices[i]);
				continue;
				}

			test_KErrNone(device.Open(*ptrDevices[i+1]));

			TBuf8<64> deviceCaps;
			device.GetCaps(deviceCaps);

			TVersion deviceVersion;
			device.QueryVersionSupported(deviceVersion);

			device.Close();
			}
		SetThreadPriority();
		timer.After(s, iThreadData.delayTime*1000);
		User::WaitForRequest(s);
		test (s == KErrNone);

		if (gAbort)
			break;
		User::After(gPeriod);
		}
	timer.Close();
	PRINT((_L("SMPStressDeviceThread MyTimer.Cancel() called\n")));
	test.End();
	test.Close();
	return 0x00;
	}
/*
-------------------------------------------------------------------------------

    Class: TStifUtil

    Method: CorrectFilePath

    Description: Checks if file path contains drive letter. If not file is serched
                 on all drives and first hit is added to file name.

    Parameters: TDes& aFilePath: in/out: file path to correct

    Return Values: None

    Errors/Exceptions: Leaves if some of called leaving methods leaves

-------------------------------------------------------------------------------
*/
EXPORT_C void TStifUtil::CorrectFilePathL( TDes& aFilePath )
	{
	_LIT( KDriveSelector, ":\\" );
	_LIT( KDriveSelectorFormat_1, "%c:" );                                                                  
	_LIT( KDriveSelectorFormat_2, "%c:\\" );                                                                
	TChar KDriveZ = EDriveZ;//'Z';                                                                          
	                                                                                                              
	_LIT( KBackslash, "\\" );                                                                              
	                                                                                                                
	TInt length = aFilePath.Length();                                                                      
	                                                                                                                
	if (length == 0 )                                                                                     
	   {                                                                                                  
	   return;                                                                                            
	   }                                                                                                  
	if (length > 2 )                                                                                      
	   {                                                                                                  
	   // Check if file path contains drive selector                                                      
	   if ( aFilePath.Mid( 1, 2 ) == KDriveSelector )                                                     
	       {                                                                                               
	       // File path contains selector letter so we have nothing to do here                             
	       return;                                                                                         
	       }                                                                                               
	   }                                                                                                  
	                                                                                                                
	// Check if file path contains backslash at the begining and                                          
	// select proper drive selector format according to this information                                  
	TInt driveSelectorFormat = 2;                                                                         
	if ( aFilePath.Mid( 0, 1 ) == KBackslash )                                                            
	   {                                                                                               
	   driveSelectorFormat = 1;                                                                        
	   }                                                                                               
	                                                                                                                
	RFs rfs;                                                                                              
	if ( rfs.Connect() != KErrNone )                                                                      
	   {                                                                                                  
	   return;                                                                                            
	   }                                                                                                  
	                                                                                                                
	// Get available drives list, revers it order and move z drive at                                     
	// the end of the list.  
	TDriveList drivesList; 
	rfs.DriveList(drivesList); 

	// Set drive variable to last drive (except for Z, which will be checked at the end)
	char drive = 'Y' ;

	// Loop through all the drives in following order: YX..CBAZ
	while(drive >= 'A' && drive <= 'Z')
	     {
	     // Do further action only if drive exists
	     TInt driveint;
	     rfs.CharToDrive(drive, driveint);
	     if(drivesList[driveint])
	          {
	          //further checking (drive selector and file existence)
	          
	          // Prepare drive selector                                                                         
	          TBuf<3> driveSelector;                                                                            
	          if ( driveSelectorFormat == 1 )                                                                   
	              {                                                                                           
	              driveSelector.Format( KDriveSelectorFormat_1, drive );                                    
	              }                                                                                           
	          else if ( driveSelectorFormat == 2 )                                                              
	              {                                                                                           
	              driveSelector.Format( KDriveSelectorFormat_2, drive );                                    
	              }                                                                                           
	                                                                                                                
	          aFilePath.Insert( 0, driveSelector );                                                             
	                                                                                                                
	          TEntry entry;                                                                                     
	          if ( rfs.Entry(aFilePath, entry) == KErrNone )                                                    
	              {                                                                                         
	              rfs.Close();                                                                                
	              return;                                                                                     
	              }                                                                                           
	                                                                                                                
	          // File does not exists on selected drive. Restoring orginal file path                            
	          aFilePath.Delete( 0, driveSelector.Length() );    	         
	          }//if(drivesList[driveint])       
	            
	   // Select next drive
	   if(drive == 'Z')
	       break; // the last driver
	   else if(drive ==  'A' )
	       drive = 'Z'; //after checking A check Z
	   else
	       drive =  (TChar)(TInt(drive)-1) ; //after checking Y check X and so on in reverse alphabetical order
	   } //while 
	rfs.Close(); 
	}