1 /* |
|
2 * Copyright (c) 2002-2007 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: File system item definitions |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CGflmFileSystemItem.h" |
|
22 #include "GflmUtils.h" |
|
23 #include "GFLMConsts.h" |
|
24 #include <f32file.h> |
|
25 |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS =============================== |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CGflmFileSystemItem::CGflmFileSystemItem |
|
31 // C++ default constructor can NOT contain any code, that |
|
32 // might leave. |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CGflmFileSystemItem::CGflmFileSystemItem( |
|
36 const TEntry& aFSEntry, |
|
37 const TDesC& aBasePath ) : |
|
38 iFSEntry( &aFSEntry ), |
|
39 iBasePath( aBasePath ) |
|
40 { |
|
41 SetExt(); |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CGflmFileSystemItem::NewL |
|
46 // Two-phased constructor. |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 CGflmFileSystemItem* CGflmFileSystemItem::NewLC( |
|
50 const TEntry& aFSEntry, |
|
51 const TDesC& aBasePath ) |
|
52 { |
|
53 CGflmFileSystemItem* self = new( ELeave ) CGflmFileSystemItem( |
|
54 aFSEntry, aBasePath ); |
|
55 |
|
56 CleanupStack::PushL( self ); |
|
57 |
|
58 return self; |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CGflmFileSystemItem::~CGflmFileSystemItem |
|
63 // |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 CGflmFileSystemItem::~CGflmFileSystemItem() |
|
67 { |
|
68 delete iLocalizedName; |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CGflmFileSystemItem::Type |
|
73 // |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 CGflmGroupItem::TGflmItemType CGflmFileSystemItem::Type() const |
|
77 { |
|
78 if ( iFSEntry->IsDir() ) |
|
79 { |
|
80 return EDirectory; |
|
81 } |
|
82 return EFile; |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CGflmFileSystemItem::Name |
|
87 // |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 TPtrC CGflmFileSystemItem::Name() const |
|
91 { |
|
92 if ( iLocalizedName ) |
|
93 { |
|
94 return iLocalizedName->Des(); |
|
95 } |
|
96 // The entry has no localized name |
|
97 return TPtrC( iFSEntry->iName ); |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CGflmFileSystemItem::Date |
|
102 // |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 TTime CGflmFileSystemItem::Date() const |
|
106 { |
|
107 return iFSEntry->iModified; |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CGflmFileSystemItem::Size |
|
112 // |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 TInt64 CGflmFileSystemItem::Size() const |
|
116 { |
|
117 return static_cast<TUint>( iFSEntry->iSize ); |
|
118 } |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // CGflmFileSystemItem::Ext |
|
122 // |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 TPtrC CGflmFileSystemItem::Ext() const |
|
126 { |
|
127 return iExt; |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CGflmFileSystemItem::GetFullPath |
|
132 // |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 EXPORT_C void CGflmFileSystemItem::GetFullPath( TDes& aPath ) const |
|
136 { |
|
137 GflmUtils::GetFullPath( iBasePath, *iFSEntry, aPath ); |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CGflmFileSystemItem::SetLocalizedNameL |
|
142 // |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 EXPORT_C void CGflmFileSystemItem::SetLocalizedNameL( const TDesC& aName ) |
|
146 { |
|
147 HBufC* temp = aName.AllocL(); |
|
148 delete iLocalizedName; |
|
149 iLocalizedName = temp; |
|
150 } |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CGflmFileSystemItem::Entry |
|
154 // |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 EXPORT_C const TEntry& CGflmFileSystemItem::Entry() const |
|
158 { |
|
159 return *iFSEntry; |
|
160 } |
|
161 |
|
162 // ----------------------------------------------------------------------------- |
|
163 // CGflmFileSystemItem::FullPathLC |
|
164 // |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 EXPORT_C HBufC* CGflmFileSystemItem::FullPathLC() const |
|
168 { |
|
169 return GflmUtils::FullPathLC( iBasePath, *iFSEntry ); |
|
170 } |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // CGflmFileSystemItem::FullPathL |
|
174 // |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 EXPORT_C HBufC* CGflmFileSystemItem::FullPathL() const |
|
178 { |
|
179 return GflmUtils::FullPathL( iBasePath, *iFSEntry ); |
|
180 } |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CGflmFileSystemItem::SetEntry |
|
184 // |
|
185 // ----------------------------------------------------------------------------- |
|
186 // |
|
187 void CGflmFileSystemItem::SetEntry( const TEntry& aEntry ) |
|
188 { |
|
189 iFSEntry = &aEntry; |
|
190 SetExt(); |
|
191 } |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CGflmFileSystemItem::SetExt |
|
195 // |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 void CGflmFileSystemItem::SetExt() |
|
199 { |
|
200 TPtrC name( iFSEntry->iName ); |
|
201 TInt pos( name.LocateReverse( KGFLMDot()[ 0 ] ) ); |
|
202 if( pos != KErrNotFound ) |
|
203 { |
|
204 iExt.Set( name.Mid( pos ) ); |
|
205 } |
|
206 else |
|
207 { |
|
208 iExt.Set( KNullDesC ); |
|
209 } |
|
210 } |
|
211 |
|
212 // End of File |
|