Ejemplo n.º 1
0
void CIniFileManager::GetIniFileNameL(TDes& aFileName, TBool aIncPrivatePath)
	{
	if (aIncPrivatePath)
		{
		User::LeaveIfError(iFs.PrivatePath(aFileName));
		}
	// Drive name goes before the path.
	aFileName.Insert(0,TDriveUnit(EDriveC).Name());
	// Filename goes after the path.
	aFileName.Append(KContactsIniFileName);
	}
Ejemplo n.º 2
0
void GetResourcePath(TDes& aAppPath)
{
#if defined ( EKA2 )
    TParsePtrC parse((CEikonEnv::Static()->EikAppUi()->Application())->ResourceFileName());
    aAppPath.Insert(0, parse.Drive());
#else
    CompleteWithAppPath(aAppPath);
#endif
#ifdef __WINS__
	aAppPath[0] = 'c';
#endif		
}
Ejemplo n.º 3
0
void GetAppPath(TDes& aAppPath)
{
#if defined ( EKA2 )
	User::LeaveIfError(CEikonEnv::Static()->FsSession().PrivatePath(aAppPath));
    // insert the drive to the private path
    TParsePtrC parse((CEikonEnv::Static()->EikAppUi()->Application())->AppFullName());
    aAppPath.Insert(0, parse.Drive());
#else
    CompleteWithAppPath(aAppPath);

#endif
#ifdef __WINS__
	aAppPath[0] = 'c';
#endif	
}
Ejemplo n.º 4
0
EXPORT_C TInt TEFparser::GetiniPath( TDesC& aBuf, 
									const TDesC& aScriptPath,
									TDes& aIniFilePath)
	{
	
	TInt err = KErrNone;	
	TInt endPos = aScriptPath.LocateReverse('\\');
	if (endPos == KErrNotFound)
		{
		err = KErrNotFound;
		}
	else
		{
		aIniFilePath.Copy(aBuf);
		aIniFilePath.Insert(0, aScriptPath.Left(endPos+1));
		}
	return err;
	}
Ejemplo n.º 5
0
// -----------------------------------------------------------------------------
// CapParser::MakeElementL(TDes& aText, TInt aId, const TDesC& aValue)
// Constructs element with value (eg. "<Free>23456</Free>").
// -----------------------------------------------------------------------------
//
void CapParser::MakeElementL(TDes& aText, TInt aId, const TDesC& aValue)
    {
    aText=KNullDesC;
    ReplaceSpecialCharsL( aText, aValue );
    
    TBuf<KTagSize> buf;
    MakeElementL( buf, aId, TXmlParser::EElementBegin );
    
    TInt len = aText.Length() + buf.Length() + buf.Length() + 1;
    if ( len > aText.MaxLength())
        {
        User::Leave(KErrTooBig);
        }
    
    aText.Insert( 0, buf );
    MakeElementL( buf, aId, TXmlParser::EElementEnd );
    aText.Append( buf );
    }
Ejemplo n.º 6
0
// -----------------------------------------------------------------------------
// CCapInfo::AddFormatText( TDes& aText, TInt aNum ) const
// Adds format text
// -----------------------------------------------------------------------------
//
void CCapInfo::AddFormatText( TDes& aText, TInt aNum ) const
    {
    TBuf<KBufSize> buf;
    buf = KNullDesC;

    if ( aNum > KNestingLimit )
        {
        aNum = KNestingLimit;
        }
        
    for ( TInt i=0; i<aNum; i++ )
        {
        buf.Append( KFormatText );
        }
    if ( aText.MaxLength()-aText.Length()>buf.Length() )
        {
        aText.Insert( 0, buf );
        }
    }
Ejemplo n.º 7
0
	void CompleteWithAppPathM(TDes &aPath)
	{
		TFileName fullAppName = RProcess().FileName();
		TParse parse;
		TParse parse1;
		parse.Set(fullAppName, NULL, NULL);
		parse1.Set(aPath, NULL, NULL);

		if(parse1.DrivePresent())
		{
			aPath[0] = parse.Drive()[0];
		}
		else
		{
			aPath.Insert(0, parse.Drive());
		}
#ifdef __WINS__
		aPath[0] = 'c';
#endif
	}
/**
Finds the keystring from the source string and replaces it with the
replacement string. The formated string is stored in the destination
descriptor.
*/
TInt CResourceLoader::Formater(TDes& aDest, const TDesC& aSource, const TDesC& aKey, const TDesC& aSubs, TBidiText::TDirectionality aDirectionality)    
    {
    // substitute string must not contain KSubStringSeparator, 
    // or results will be unpredictable 
    __ASSERT_DEBUG(aSubs.Locate(KSubStringSeparator) == KErrNotFound, 
        User::Panic(KPanicCategory, EInvalidSubstitute));

    TInt keylength(aKey.Length());

    //aDest must be empty.
    aDest.Zero();

    // offset indicates end of last handled key in source
    TInt offset(0);

    // offset in destination string
    TInt desOffset(0);

    // Substring directionalities are adjusted after all changes are done.
    TBool checkSubstringDirectionalities(EFalse);

    // count is the position in the source from which the substring starts
    TInt count(0);

    // Replaced parameters count
    TInt replaceCount(0);

    while (count != KErrNotFound)
        {
        // desCount is the position of the substring starts in destination.
        TInt desCount(0);

        TPtrC remainder = aSource.Right(aSource.Length() - offset);
        count = remainder.Find(aKey);

        TInt maxSubLength = -1;
        if (count != KErrNotFound)
            {
            replaceCount++;
            desOffset += count;
            offset += count;
            count = offset;
            desCount = desOffset;

            // copy source to destination if first time
            if (aDest.Length() == 0)
                aDest.Append(aSource);

            // delete found key from destination
            aDest.Delete(desCount, keylength);

            offset += keylength; // increase offset by key length

            if (count + keylength < (aSource.Length()-1)) // aKey is not at the end of string
                {
                if (aSource[count+keylength] == '[') // Key includes max datalength
                    {
                    maxSubLength = 10*(aSource[count+keylength+1]-'0') 
                                   + (aSource[count+keylength+2]-'0');
                    aDest.Delete(desCount,4); // Length information stored->delete from descriptor
                    offset += 4; // increase offset by max sub length indicator
                    }
                }
         
            aDest.Insert(desCount, aSubs);
        
            desOffset = desCount + aSubs.Length();

            if (maxSubLength > 0 && aSubs.Length() > maxSubLength)
                {
                aDest.Delete(desCount+maxSubLength-1, aSubs.Length()+1-maxSubLength);     
                TText ellipsis(KEllipsis);
                aDest.Insert(desCount+maxSubLength-1, TPtrC(&ellipsis,1));
                desOffset = desCount + maxSubLength;
                }

            TBidiText::TDirectionality subsDir =
                TBidiText::TextDirectionality(aDest.Mid(desCount, desOffset - desCount));

            // If inserted string has different directionality,
            // insert directionality markers so that bidi algorithm works in a desired way.
            if (aDirectionality != subsDir)
                {
                checkSubstringDirectionalities = ETrue;

                TInt freeSpace = aDest.MaxLength() - aDest.Length();

                // Protect the directionality of the inserted string.
                if (freeSpace >= KExtraSpaceForSubStringDirMarkers)
                    {
                    TBuf<1> subsMarker;
                    subsMarker.Append(subsDir == TBidiText::ELeftToRight ?
                        KLRMarker : KRLMarker);

                    aDest.Insert(desOffset, subsMarker);
                    aDest.Insert(desCount, subsMarker);
                    desOffset += KExtraSpaceForSubStringDirMarkers;
                    }
                }
            }
        }

    // Adjust substring directionality markers if necessary
    // and if there is enough room in destination string
    if (checkSubstringDirectionalities)
        {
        TText mainMarker = (aDirectionality == TBidiText::ELeftToRight ? 
            KLRMarker : KRLMarker);

        TInt freeSpace = aDest.MaxLength() - aDest.Length();

        // If not already done, protect the directionality of the original string
        // and all of the KSubStringSeparator separated substrings.
        if (freeSpace > 0 
            && aDest.Length()
            && aDest[0] != mainMarker 
            && aDest[0] != KSubStringSeparator
            && aDest[0] != KDirNotFound)  
            {
            aDest.Insert(0, TPtrC(&mainMarker, 1));
            freeSpace--;
            }

        // Find and protect KSubStringSeparator separated substrings.
        // Go through string backwards so that any changes will not affect indexes 
        // that are not yet checked.
        TInt j(aDest.Length()-1);
        while (freeSpace > 0 && j >= 0) 
            {
            if (aDest[j] == KSubStringSeparator && j < (aDest.Length() - 1) 
                && aDest[j+1] != mainMarker && aDest[j+1] != KDirNotFound)
                {
                aDest.Insert(j+1, TPtrC(&mainMarker, 1));
                freeSpace--;
                }
            j--;
            }
        }

    return replaceCount;
    }
Ejemplo n.º 9
0
/*
-------------------------------------------------------------------------------

    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(); 
	}