Пример #1
0
//================================================================================
//convertPathL
//================================================================================
void convertPathL(TDesC& aPath, TDesC& aPathName, RFs& aFs, TDesC& aTargetFile)
	{
	aFs.MkDirAll(aPathName);

	CDir* entryList = NULL;
	TInt error = aFs.GetDir(aPath,KEntryAttMatchMask,ESortByName,entryList);
	User::LeaveIfError(error);

	TInt numberOfFiles = entryList->Count();
	for (TInt i=0; i<numberOfFiles; i++)
		{
		//get the source file
		HBufC* temp=HBufC::NewLC(((*entryList)[i].iName).Length());
		TPtr sourceFileName(temp->Des());
		sourceFileName.Copy((*entryList)[i].iName);

		HBufC* temp2=HBufC::NewLC(((*entryList)[i].iName).Length()+aPathName.Length());
		TPtr sourceFile(temp2->Des());
		sourceFile = aPathName;
		sourceFile.Append(sourceFileName);
		//do the conversion
		synchronousL(sourceFile, aTargetFile);
		//output result
		_LIT(KString,"%S");
		test.Printf(KString,&(sourceFileName));
		test.Printf(_L("\n"));
		CleanupStack::PopAndDestroy(2);//temp, temp2
		}

	delete entryList;
	test.Printf(_L("\n%d files converted\n"),numberOfFiles);
	}
// ---------------------------------------------------------------------------
// Cplaylistenginetest::CMPXPlaylistEngineInternalizePlaylistLRFile
// ?implementation_description
// (other items were commented in a header).
// ---------------------------------------------------------------------------
//
TInt Cplaylistenginetest::CMPXPlaylistEngineInternalizePlaylistLRFile( CStifItemParser& aItem )
    {
    TInt err=KErrNone;
    iLog->Log(_L("Cplaylistenginetest::CMPXPlaylistEngineInternalizePlaylistLRFile"));
    TPtrC string;
    while ( aItem.GetNextString( string ) == KErrNone )
          {
			TBuf<120> KPlaylistDir;
			KPlaylistDir.Append(Kplaylistenginetest_testPath);
			KPlaylistDir.Append(string);
		    
		    RFs fs;
	        User::LeaveIfError(fs.Connect());
	        CDir* entryList(NULL);
	      //  User::LeaveIfError(
	      //  fs.GetDir(KPlaylistDir, KEntryAttNormal, KEntryAttNormal, entryList));
	        User::LeaveIfError(
    		fs.GetDir(KPlaylistDir, KEntryAttMaskSupported, ESortByName|EDirsFirst, entryList));
	        CleanupStack::PushL(entryList);
	        RFile playlistFile;				
	        User::LeaveIfError(playlistFile.Open(fs, KPlaylistDir, EFileRead ));	
	        iPlaylistEngine->PlaylistPluginHandler().SelectPlaylistPluginL(playlistFile);
		    TRAP(err, iPlaylistEngine->InternalizePlaylistL(playlistFile));	
		    CleanupStack::PopAndDestroy(entryList);
		    playlistFile.Close();
		    fs.Close();
		   
          }
	iLog->Log(_L("Cplaylistenginetest::InternalizePlaylistL returned: %d"), err);
       
    return err;
    }
RArray<TFileName> ListImages::searchJPGL(TFileName tot, RFs fs,
        TFileName current)
{
    RArray<TFileName> result;
    TInt i;
    TBuf<50> totalPath;
    TBuf<30> fileName;
    CDir* dirList;

    totalPath = tot;
    CleanupStack::PushL(dirList);
    if ((current.Length()) > 0)
        totalPath.Append(current);
    //CleanupClosePushL(result);
    TRAPD(err,fs.GetDir(totalPath, KEntryAttMaskSupported,
                        ESortByDate, dirList));
    CleanupStack::Pop(1);
    if (!dirList)
        return result;

    for (i = 0; i < dirList->Count(); i++)
    {
        if ((*dirList)[i].IsDir())
        {
            TFileName tmp;
            tmp.Append((*dirList)[i].iName);
            tmp.Append(_L("\\"));
            RArray<TFileName> res = searchJPGL(totalPath, fs, tmp);
            for (int j = 0; j < res.Count(); j++)
                result.Append(res[j]);
            res.Reset();

        }
        else
        {
            fileName = (*dirList)[i].iName;
            if (fileName.Find(_L(".jpg")) != KErrNotFound)
            {
                TBuf<50> tmp;
                tmp = totalPath;
                tmp.Append(fileName);
                result.Append(tmp);
                tmp.Delete(0, tmp.Length() - 1);
            }
        }
    }
    delete dirList;
    return result;
}
int DeviceManagementNode::getChildrenMaxCount() {
    int count = 0;

    RFs fileSession;
    RFile file;
    int cleanupStackSize = 0;

    StringBuffer fileSpecSb(currentDir);
    concatDirs(fileSpecSb, "*.*");

    // TODO use utility function for string conversion
    TBuf8<DIM_MANAGEMENT_PATH> buf8((const unsigned char*)fileSpecSb.c_str());
    HBufC* fileSpec = CnvUtfConverter::ConvertToUnicodeFromUtf8L(buf8);
    CleanupStack::PushL(fileSpec);
    ++cleanupStackSize;

    //
    // Connect to the file server
    //
    fileSession.Connect();
    CleanupClosePushL(fileSession);
    ++cleanupStackSize;

    StringBuffer buf;

    //
    // Get the directories list, sorted by name
    // (Leave if an error occurs)
    //
    CDir* dirList;
    TRAPD(err, fileSession.GetDir(*fileSpec, KEntryAttDir|KEntryAttMatchExclusive,
                                  ESortByName, dirList));
    if (err != KErrNone || dirList == NULL) {
        goto finally;
    }
    CleanupStack::PushL(dirList);
    ++cleanupStackSize;

    count = dirList->Count();

finally:
    //
    // Close the connection with the file server
    // and destroy dirList
    //
    fileSession.Close();
    CleanupStack::PopAndDestroy(cleanupStackSize);
    return count;
}
/**
  Function : ExecuteActionL
  Description : Entry point for the this test action in the test framework
  @internalTechnology
  @param : none
  @return : void
  @pre none 
  @post none
*/
void CMtfTestActionCheckDrmMetaData::ExecuteActionL()
{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCheckDrmMetaData);
	HBufC* metaDataFile = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(0));
	TInt numberOfFiles = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(1));
	
	RFs fs;
	RFile file;
	User::LeaveIfError(fs.Connect());
	CleanupClosePushL(fs);
	
	// Get the contents of the directory
	CDir* dir = NULL;
	
	{
		TFileName dirString;
		dirString.Append(*metaDataFile);
		dirString.Append(KFileFilter);
		
		User::LeaveIfError(fs.GetDir(dirString, KEntryAttMaskSupported, ESortByName, dir));
		CleanupStack::PushL(dir);
	}
	
	TBool success = ETrue;
	TInt count = dir->Count();
	
	if (count != numberOfFiles)
	{
		// no meta data generated. failed.
		TestCase().ERR_PRINTF3(_L("CMtfTestActionCheckDrmMetaData: FAILED! Incorrect number of files, expected [%d], found [%d]"), numberOfFiles, count);
		success = EFalse;
	}
	else
	{
		for (TInt i = 0; i < count; i++)
		{
			// open the file
			TFileName fileName;
			fileName.Append(*metaDataFile);
			fileName.Append((*dir)[i].iName);
			
			User::LeaveIfError(file.Open(fs, fileName, EFileShareAny | EFileRead));
			CleanupClosePushL(file);
			
			// Parse the file and verify its contents
			TInt fileSize = 0;
			User::LeaveIfError(file.Size(fileSize));
			
			HBufC8* fileContent = HBufC8::NewLC(fileSize);
			TPtr8 des = fileContent->Des();
			
			User::LeaveIfError(file.Read(des, fileSize));
			
			if (fileContent->FindF(KContentTypeString) == KErrNotFound)
			{
				TestCase().ERR_PRINTF1(_L("CMtfTestActionCheckDrmMetaData: FAILED! Content-Type not found. Meta-data file corrupt!"));
				success = EFalse;
			}
			
			CleanupStack::PopAndDestroy(2); // file, fileContent
		}
	}

	if (count > 0)
	{
		// delete the meta data files
		for (TInt i = 0; i < count; i++)
		{
			TFileName fileName;
			fileName.Append(*metaDataFile);
			fileName.Append((*dir)[i].iName);
			TInt err = fs.Delete(fileName);
			if (err != KErrNone)
			{
				TestCase().ERR_PRINTF2(_L("CMtfTestActionCheckDrmMetaData: FAILED! Couldn't delete Meta-data file: [%d]!"), err);
				success = EFalse;
			}
		}
	}
	
	CleanupStack::PopAndDestroy(2); // fs, dir
	
	if (success)
	{
		TestCase().INFO_PRINTF1(_L("CMtfTestActionCheckDrmMetaData: Meta-data check successful. Test case PASSED."));
		TestCase().SetTestStepResult(EPass);
	}
	else
	{
		TestCase().ERR_PRINTF1(_L("CMtfTestActionCheckDrmMetaData: Meta-data check failed. Test case FAILED."));
		TestCase().SetTestStepResult(EFail);
	}
	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCheckDrmMetaData);
	TestCase().ActionCompletedL(*this);
}