os/security/cryptoservices/filebasedcertificateandkeystores/source/generic/server/fstokenutil.cpp
First public contribution.
2 * Copyright (c) 2003-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.
19 #include "fstokenutil.h"
23 // RMessage::Panic() also completes the message. This is:
24 // (a) important for efficient cleanup within the kernel
25 // (b) a problem if the message is completed a second time
26 void PanicClient(const RMessage2& aMessage, ETokenTypeServerPanic aPanic)
28 _LIT(KPanicClient,"TTSERVERCLIENT");
29 aMessage.Panic(KPanicClient,aPanic);
32 void PanicServer(ETokenTypeServerPanic aPanicCode)
34 _LIT(KPanicServer,"TOKENTYPESERVER");
35 User::Panic(KPanicServer, aPanicCode);
38 /// Rom drive where the initial store data is
39 _LIT(KFileStoreROMDrive, "Z:");
41 TBool FileUtils::ExistsL(RFs& aFs, const TDesC& aFile)
43 TBool result = EFalse;
45 TInt err = aFs.IsFileOpen(aFile, open);
51 else if (err != KErrNotFound && err != KErrPathNotFound)
59 void FileUtils::EnsurePathL(RFs& aFs, const TDesC& aFile)
61 TInt err = aFs.MkDirAll(aFile);
62 if (err != KErrNone && err != KErrAlreadyExists)
68 void FileUtils::CopyL(RFs& aFs, const TDesC& aSouce, const TDesC& aDest)
71 User::LeaveIfError(in.Open(aFs, aSouce, EFileRead | EFileShareReadersOnly));
72 CleanupClosePushL(in);
75 User::LeaveIfError(out.Replace(aFs, aDest, EFileWrite | EFileShareExclusive));
76 CleanupClosePushL(out);
79 CleanupStack::PopAndDestroy(2, &in);
82 void FileUtils::MakePrivateFilenameL(RFs& aFs, const TDesC& aLeafName, TDes& aNameOut)
84 aNameOut.SetLength(0);
85 aNameOut.Append(RFs::GetSystemDriveChar());
91 aFs.PrivatePath(privatePath);
92 aNameOut.Append(privatePath);
94 aNameOut.Append(aLeafName);
97 void FileUtils::MakePrivateROMFilenameL(RFs& aFs, const TDesC& aLeafName, TDes& aNameOut)
99 aNameOut.Copy(KFileStoreROMDrive);
102 TBuf<20> privatePath;
103 aFs.PrivatePath(privatePath);
104 aNameOut.Append(privatePath);
106 aNameOut.Append(aLeafName);