|
1 /* |
|
2 * Copyright (c) 2000 - 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Provides file handling functions. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __FILEUTIL_H__ |
|
21 #define __FILEUTIL_H__ |
|
22 |
|
23 #include "vpnapidefs.h" |
|
24 |
|
25 /** |
|
26 * File name extensions |
|
27 */ |
|
28 _LIT(KPolFileExt, ".pol"); |
|
29 _LIT(KPinFileExt, ".pin"); |
|
30 _LIT(KCertFileExt, ".cer"); |
|
31 _LIT(KPrivKeyFileExt, ".key"); |
|
32 |
|
33 /** |
|
34 * File name patterns |
|
35 */ |
|
36 _LIT(KPinFilePat, "*.pin"); |
|
37 _LIT(KPolFilePat, "*.pol"); |
|
38 _LIT(KUserPrivKeyFilePat, "-user*.key"); |
|
39 _LIT(KCaCertFilePat, "-ca*.cer"); |
|
40 _LIT(KPeerCertFilePat, "-peer*.cer"); |
|
41 _LIT(KAllFilesPat, "*.*"); |
|
42 |
|
43 /** |
|
44 * File names |
|
45 */ |
|
46 _LIT(KPolListFile, "vpnpolicies"); |
|
47 |
|
48 /** |
|
49 * Paths |
|
50 */ |
|
51 |
|
52 class RFs; |
|
53 |
|
54 /** |
|
55 * A collection of methods for handling files and file names. |
|
56 */ |
|
57 class TFileUtil |
|
58 { |
|
59 public: |
|
60 TFileUtil(RFs& aFs); |
|
61 TFileName ReplaceExtension(const TFileName& aFileName, |
|
62 const TDesC& aExtension); |
|
63 TBool FileExists(const TFileName& aFileName); |
|
64 HBufC8* LoadFileDataL(const TFileName& aFileName); |
|
65 HBufC* LoadFileDataUL(const TFileName& aFileName); |
|
66 void SaveFileDataL(const TFileName& aFileName, |
|
67 const TDesC8& aFileData); |
|
68 void SaveFileDataL(const TFileName& aFileName, |
|
69 const TDesC& aFileData); |
|
70 // Ownership of the return object transferred to caller |
|
71 // in Make* and Get* functions |
|
72 HBufC* MakeFileNameLC(const TDesC& aDir, const TDesC& aName, |
|
73 const TDesC& aExtension); |
|
74 TFileName MakeFileName(const TDesC& aDir, const TDesC& aNameAndExtension); |
|
75 HBufC* GetPolFileNameLC(const TVpnPolicyId& aPolicyId); |
|
76 HBufC* GetPinFileNameLC(const TVpnPolicyId& aPolicyId); |
|
77 HBufC* GetPolFileNameL(const TVpnPolicyId& aPolicyId); |
|
78 HBufC* GetPinFileNameL(const TVpnPolicyId& aPolicyId); |
|
79 TFileName PolListFileNameL(); |
|
80 void DeleteFileL(const TFileName& aFileName); |
|
81 void DeleteFilesL(const TFileName& aFileFilter); |
|
82 void MoveFileL(const TFileName& aSrcFileName, const TFileName& aDstFileName); |
|
83 void CopyFileL(const TFileName& aSrcFileName, const TFileName& aDstFileName); |
|
84 void CreateDirIfNeededL(const TFileName& aDirName); |
|
85 HBufC8* To8BitL(const TDesC16& aDes); |
|
86 HBufC16* To16BitL(const TDesC8& aDes); |
|
87 void DeleteDirL(const TFileName& aDirName); |
|
88 |
|
89 private: |
|
90 RFs& iFs; |
|
91 }; |
|
92 |
|
93 #endif // __FILEUTIL_H__ |