|
1 /* |
|
2 * Copyright (c) 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ncdstoragefiledataitem.h" |
|
20 |
|
21 #include <s32file.h> |
|
22 |
|
23 #include "catalogsdebug.h" |
|
24 |
|
25 // ======== MEMBER FUNCTIONS ======== |
|
26 |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // Second phase constructor |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 void CNcdStorageFileDataItem::ConstructL( const TDesC& aFilename ) |
|
33 { |
|
34 if ( !aFilename.Length() ) |
|
35 { |
|
36 User::Leave( KErrArgument ); |
|
37 } |
|
38 |
|
39 iFilename.CreateL( aFilename ); |
|
40 } |
|
41 |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // NewL |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 CNcdStorageFileDataItem* CNcdStorageFileDataItem::NewL( |
|
48 const TDesC& aFilename, RFs& aFs ) |
|
49 { |
|
50 CNcdStorageFileDataItem* self = CNcdStorageFileDataItem::NewLC( |
|
51 aFilename, aFs ); |
|
52 CleanupStack::Pop( self ); |
|
53 return self; |
|
54 } |
|
55 |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // NewLC |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 CNcdStorageFileDataItem* CNcdStorageFileDataItem::NewLC( const TDesC& |
|
62 aFilename, RFs& aFs ) |
|
63 { |
|
64 CNcdStorageFileDataItem* self = new( ELeave ) CNcdStorageFileDataItem( |
|
65 aFs ); |
|
66 CleanupStack::PushL( self ); |
|
67 self->ConstructL( aFilename ); |
|
68 return self; |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // Destructor |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 CNcdStorageFileDataItem::~CNcdStorageFileDataItem() |
|
76 { |
|
77 iFilename.Close(); |
|
78 } |
|
79 |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // ExternalizeL |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 void CNcdStorageFileDataItem::ExternalizeL( RWriteStream& aStream ) |
|
86 { |
|
87 DLTRACEIN(( _L("Externalizing: %S"), &iFilename )); |
|
88 |
|
89 #ifdef CATALOGS_BUILD_CONFIG_DEBUG |
|
90 RFile file; |
|
91 CleanupClosePushL( file ); |
|
92 User::LeaveIfError( file.Open( iFs, iFilename, EFileRead ) ); |
|
93 TInt fileSize = -1; |
|
94 User::LeaveIfError( file.Size( fileSize ) ); |
|
95 CleanupStack::PopAndDestroy( &file ); |
|
96 DLINFO(("File size: %d", fileSize )); |
|
97 #endif |
|
98 |
|
99 RFileReadStream rstream; |
|
100 CleanupClosePushL( rstream ); |
|
101 |
|
102 DLTRACE(("Opening file")); |
|
103 User::LeaveIfError( rstream.Open( iFs, iFilename, |
|
104 EFileRead | EFileStream | EFileShareReadersOnly ) ); |
|
105 |
|
106 DLTRACE(("Externalizing data")); |
|
107 aStream.WriteL( rstream ); |
|
108 CleanupStack::PopAndDestroy( &rstream ); |
|
109 |
|
110 DLTRACEOUT(("")); |
|
111 } |
|
112 |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // InternalizeL |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 void CNcdStorageFileDataItem::InternalizeL( RReadStream& /* aStream */ ) |
|
119 { |
|
120 User::Leave( KErrNotSupported ); |
|
121 } |
|
122 |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // Constructor |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 CNcdStorageFileDataItem::CNcdStorageFileDataItem( RFs& aFs ) : iFs( aFs ) |
|
129 { |
|
130 } |
|
131 |
|
132 |