Update contrib.
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Contains miscellaneous utility functions that can be used by any code in security component
29 * Function used to extract lines of text from a buffer. Note that this only works for non-unicode text. It skips
30 * over blank lines and the characters '\n' or '\r' are treated as end-of-line markers.
32 * @param aBuffer Input buffer
33 * @param aPos Starting index into aBuffer
34 * @return ETrue if a line was successfully extracted from the buffer, EFalse if end of buffer reached
37 EXPORT_C TBool ReadNonEmptyLineL(const TDesC8& aBuffer, TInt& aPos, TPtrC8& aLine)
39 TBool lineIdentified = ETrue;
42 TInt bufferLength = aBuffer.Length();
43 __ASSERT_ALWAYS(aPos >=0 && aPos <= bufferLength, User::Leave(KErrArgument));
46 while (aPos < bufferLength)
48 TChar c = aBuffer[aPos];
49 if (c != '\r' && c != '\n')
56 // Find the position of the next delimter
58 while (endPos < bufferLength)
60 TChar c = aBuffer[endPos];
61 if (c == '\n' || c == '\r') // Find end of line
70 TInt tokenLen = endPos - aPos;
71 aLine.Set(&aBuffer[aPos], tokenLen);
75 lineIdentified = EFalse; // End of buffer
79 return lineIdentified;
83 * Recursively deletes all folders in the path (as long as they are empty)
85 * @param aFs Connected filesystem session
86 * @param aPath Fully qualified path to start the recursive delete
88 EXPORT_C void DeletePathIfEmpty(RFs& aFs, const TDesC& aPath)
91 path.Set(aPath,NULL,NULL);
93 if (path.PathPresent())
95 while ((aFs.RmDir(path.DriveAndPath()) == KErrNone) && (path.PopDir() == KErrNone))
100 } // namespace MiscUtil