author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 43 | c1f20ce4abcf |
parent 0 | a41df078684a |
child 44 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// f32\sfile\sf_dir.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include "sf_std.h" |
|
19 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
20 |
#ifdef OST_TRACE_COMPILER_IN_USE |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
21 |
#include "sf_dirTraces.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
22 |
#endif |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
23 |
|
0 | 24 |
LOCAL_C CDirCB* GetDirFromHandle(TInt aHandle,CSessionFs* aSession) |
25 |
// |
|
26 |
// Get the dir control block from its handle. |
|
27 |
// |
|
28 |
{ |
|
29 |
return((CDirCB*)(SessionObjectFromHandle(aHandle,Dirs->UniqueID(),aSession))); |
|
30 |
} |
|
31 |
||
32 |
LOCAL_C TInt DoInitialise(CFsRequest* aRequest) |
|
33 |
// |
|
34 |
// Determine asynchronicity from dir control block |
|
35 |
// |
|
36 |
{ |
|
37 |
CDirCB* dir; |
|
38 |
dir=GetDirFromHandle(aRequest->Message().Int3(),aRequest->Session()); |
|
39 |
if(!dir) |
|
40 |
return(KErrBadHandle); |
|
41 |
aRequest->SetDrive(&dir->Drive()); |
|
42 |
aRequest->SetScratchValue((TUint)dir); |
|
43 |
return KErrNone; |
|
44 |
} |
|
45 |
||
46 |
#ifndef __ARMCC__ |
|
47 |
LOCAL_C |
|
48 |
#endif |
|
49 |
void fsDirReadPacked(TEntry* pE,TEntry* pEnd,volatile TInt& aLen,CDirCB& aDir) |
|
50 |
// |
|
51 |
// Read packed directory entries. |
|
52 |
// |
|
53 |
{ |
|
54 |
||
55 |
FOREVER |
|
56 |
{ |
|
57 |
TEntry e; |
|
58 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
59 |
OstTrace1(TRACE_FILESYSTEM, FSYS_ECDIRCBREADL2, "fsDirReadPacked this %x", &aDir); |
0 | 60 |
aDir.ReadL(e); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
61 |
OstTraceExt5(TRACE_FILESYSTEM, FSYS_ECDIRCBREADL2RET, "fsDirReadPacked r %d att %x modified %x:%x size %d", (TUint) KErrNone, (TUint) e.iAtt, (TUint) I64HIGH(e.iModified.Int64()), (TUint) I64LOW(e.iModified.Int64()), (TUint) e.iSize); |
0 | 62 |
TInt len=EntrySize(e, EFalse); |
63 |
TInt rLen=EntrySize(e, ETrue); |
|
64 |
TEntry* pX=PtrAdd(pE,rLen); |
|
65 |
if (pX>pEnd) |
|
66 |
{ |
|
67 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
68 |
OstTrace1(TRACE_FILESYSTEM, FSYS_ECDIRCBSTORELONGENTRYNAMEL, "fsDirReadPacked this %x", &aDir); |
0 | 69 |
aDir.StoreLongEntryNameL(e.iName); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
70 |
OstTrace1(TRACE_FILESYSTEM, FSYS_ECDIRCBSTORELONGENTRYNAMELRET, "fsDirReadPacked r %d", KErrNone); |
0 | 71 |
|
72 |
aDir.SetPending(ETrue); |
|
73 |
break; |
|
74 |
} |
|
75 |
aLen+=rLen; |
|
76 |
Mem::Copy(pE,&e,len); |
|
77 |
||
78 |
/** |
|
79 |
* Flag the entry with KEntryAttPacked so we can unpack |
|
80 |
* these fields as required at a later date... |
|
81 |
*/ |
|
82 |
pE->iAtt |= KEntryAttPacked; |
|
83 |
||
84 |
/** |
|
85 |
* ...and pack the iSizeHigh and iReserved fields to the end of the name string |
|
86 |
*/ |
|
87 |
TUint32* pSizeHighSrc = PtrAdd((TUint32*)&e, sizeof(TEntry) - 2*sizeof(TInt)); |
|
88 |
TUint32* pSizeHighDst = PtrAdd((TUint32*)pE, EntrySize(*pE, EFalse)); |
|
89 |
||
90 |
*pSizeHighDst++ = *pSizeHighSrc++; // Copy length |
|
91 |
*pSizeHighDst = *pSizeHighSrc; // Copy reserved |
|
92 |
||
93 |
pE=pX; |
|
94 |
} |
|
95 |
} |
|
96 |
||
97 |
TInt TFsDirOpen::DoRequestL(CFsRequest* aRequest) |
|
98 |
// |
|
99 |
// Open a directory. |
|
100 |
// |
|
101 |
{ |
|
102 |
||
103 |
__PRINT(_L("TFsDirOpen::DoRequestL(CFsRequest* aRequest)")); |
|
104 |
TInt h; |
|
105 |
TUidType uidType; |
|
106 |
TPckgBuf<TUidType> pckgUid; |
|
107 |
aRequest->ReadL(KMsgPtr2,pckgUid); |
|
108 |
uidType=pckgUid(); |
|
109 |
TInt r=aRequest->Drive()->DirOpen(aRequest->Session(),h,aRequest->Src().FullName().Mid(2),aRequest->Message().Int1(),uidType); |
|
110 |
if (r!=KErrNone) |
|
111 |
return(r); |
|
112 |
||
113 |
||
114 |
//DirRead does not have a filename / src stored, so if there are plugins installed which |
|
115 |
//wish to intercept dirread1/packed then store the name in CDirCB::iName now. |
|
116 |
CFsPlugin* plugin = NULL; |
|
117 |
//Get the next plugin which is mounted on this drive (IsMounted called in NextPlugin) |
|
118 |
//Do not check whether we're registered for current operation (in case not registered for EFsDirOpen) |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
119 |
FsPluginManager::ReadLockChain(); //!Check operation |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
120 |
while(FsPluginManager::NextPlugin(plugin,(CFsMessageRequest*)aRequest,(TBool)EFalse)==KErrNone && plugin) |
0 | 121 |
{ |
122 |
if(plugin->IsRegistered(EFsDirReadOne) || |
|
123 |
plugin->IsRegistered(EFsDirReadPacked) || |
|
124 |
plugin->IsRegistered(EFsDirSubClose)) |
|
125 |
{ |
|
126 |
CDirCB* dir = GetDirFromHandle(h,aRequest->Session()); |
|
127 |
TPtrC name = aRequest->Src().FullName(); |
|
128 |
r = dir->SetName(&name); |
|
129 |
CheckForLeaveAfterOpenL(r, aRequest, h); |
|
130 |
break; |
|
131 |
} |
|
132 |
} |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
133 |
FsPluginManager::UnlockChain(); |
0 | 134 |
|
135 |
TPtrC8 pH((TUint8*)&h,sizeof(TInt)); |
|
136 |
TRAP(r,aRequest->WriteL(KMsgPtr3,pH)) |
|
137 |
CheckForLeaveAfterOpenL(r, aRequest, h); |
|
138 |
aRequest->Session()->IncResourceCount(); |
|
139 |
return(KErrNone); |
|
140 |
} |
|
141 |
||
142 |
||
143 |
TInt TFsDirOpen::Initialise(CFsRequest* aRequest) |
|
144 |
// |
|
145 |
// |
|
146 |
// |
|
147 |
{ |
|
148 |
||
149 |
TInt r=ParseSubstPtr0(aRequest,aRequest->Src()); |
|
150 |
if (r!=KErrNone) |
|
151 |
return(r); |
|
152 |
r=PathCheck(aRequest,aRequest->Src().FullName().Mid(2),&KCapFsSysDirOpen,&KCapFsPriDirOpen, __PLATSEC_DIAGNOSTIC_STRING("Dir Open")); |
|
153 |
if(r != KErrNone) |
|
154 |
return r; |
|
155 |
return KErrNone; |
|
156 |
} |
|
157 |
||
158 |
||
159 |
TInt TFsDirReadOne::DoRequestL(CFsRequest* aRequest) |
|
160 |
// |
|
161 |
// Read one directory entry. |
|
162 |
// |
|
163 |
{ |
|
164 |
__PRINT(_L("TFsDirReadOne::DoRequestL(CFsRequest* aRequest)")); |
|
165 |
CDirCB* dir=(CDirCB*)aRequest->ScratchValue(); |
|
166 |
TInt r=dir->CheckMount(); |
|
167 |
if (r!=KErrNone) |
|
168 |
return(r); |
|
169 |
TEntry e; |
|
170 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
171 |
OstTrace1(TRACE_FILESYSTEM, FSYS_ECDIRCBREADL1, "this %x", &dir); |
0 | 172 |
TRAP(r,dir->ReadL(e)) |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
173 |
OstTraceExt5(TRACE_FILESYSTEM, FSYS_ECDIRCBREADL1RET, "r %d att %x modified %x:%x size %d", (TUint) KErrNone, (TUint) e.iAtt, (TUint) I64HIGH(e.iModified.Int64()), (TUint) I64LOW(e.iModified.Int64()), (TUint) e.iSize); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
174 |
|
0 | 175 |
|
176 |
||
177 |
if (r==KErrNone) |
|
178 |
{ |
|
179 |
TPckgC<TEntry> pE(e); |
|
180 |
aRequest->WriteL(KMsgPtr0,pE); |
|
181 |
} |
|
182 |
return(r); |
|
183 |
} |
|
184 |
||
185 |
TInt TFsDirReadOne::Initialise(CFsRequest* aRequest) |
|
186 |
// |
|
187 |
// |
|
188 |
// |
|
189 |
{ |
|
190 |
return(DoInitialise(aRequest)); |
|
191 |
} |
|
192 |
||
193 |
TInt TFsDirReadPacked::DoRequestL(CFsRequest* aRequest) |
|
194 |
// |
|
195 |
// Read packed directory entries. |
|
196 |
// |
|
197 |
{ |
|
198 |
||
199 |
__PRINT(_L("TFsDirReadPacked::DoRequestL(CFsRequest* aRequest)")); |
|
200 |
CDirCB* dir=(CDirCB*)aRequest->ScratchValue(); |
|
201 |
TInt r=dir->CheckMount(); |
|
202 |
if (r!=KErrNone) |
|
203 |
return(r); |
|
204 |
||
205 |
TBuf8<KEntryArraySize> buf; |
|
206 |
TEntry* pE=(TEntry*)buf.Ptr(); |
|
207 |
TEntry* pEnd=PtrAdd(pE,KEntryArraySize); |
|
208 |
volatile TInt len=0; |
|
209 |
TRAP(r,fsDirReadPacked(pE,pEnd,len,*(dir))); |
|
210 |
buf.SetLength(len); |
|
211 |
aRequest->WriteL(KMsgPtr0,buf); |
|
212 |
return(r); |
|
213 |
} |
|
214 |
||
215 |
TInt TFsDirReadPacked::Initialise(CFsRequest* aRequest) |
|
216 |
// |
|
217 |
// Call GetDirFromHandle to determine asynchronicity *** |
|
218 |
// |
|
219 |
{ |
|
220 |
return(DoInitialise(aRequest)); |
|
221 |
} |
|
222 |
||
223 |
||
224 |
||
225 |
||
226 |
/** |
|
227 |
Default cosntructor. |
|
228 |
*/ |
|
229 |
EXPORT_C CDirCB::CDirCB() |
|
230 |
{ |
|
231 |
||
232 |
// iPending=EFalse; |
|
233 |
// iDrive=NULL; |
|
234 |
// iMount=NULL; |
|
235 |
} |
|
236 |
||
237 |
||
238 |
||
239 |
||
240 |
/** |
|
241 |
Destructor. |
|
242 |
||
243 |
Frees resources before destruction of the object. |
|
244 |
*/ |
|
245 |
EXPORT_C CDirCB::~CDirCB() |
|
246 |
{ |
|
247 |
if(iMount) |
|
248 |
{ |
|
249 |
RemoveResource(*iMount); |
|
250 |
iMount->Close(); |
|
251 |
} |
|
252 |
} |
|
253 |
||
254 |
TInt CDirCB::CheckMount() |
|
255 |
// |
|
256 |
// Check that the media is still mounted. |
|
257 |
// |
|
258 |
{ |
|
259 |
||
260 |
TDrive& d=Drive(); |
|
261 |
TInt r=d.CheckMount(); |
|
262 |
if (r!=KErrNone) |
|
263 |
return(r); |
|
264 |
if (&Mount()!=&d.CurrentMount()) |
|
265 |
return(KErrDisMounted); |
|
266 |
return(KErrNone); |
|
267 |
} |
|
268 |
||
269 |
EXPORT_C void CDirCB::InitL(TDrive* aDrive) |
|
270 |
// |
|
271 |
// Initialise |
|
272 |
// |
|
273 |
{ |
|
274 |
DoInitL(aDrive->DriveNumber()); |
|
275 |
iDrive=aDrive; |
|
276 |
iMount=&aDrive->CurrentMount(); |
|
277 |
User::LeaveIfError(iMount->Open()); |
|
278 |
} |
|
279 |
||
280 |
||
281 |
||
282 |
||
283 |
/** |
|
284 |
Stores a long full entry name, a TEntry::iName value, into a buffer, |
|
285 |
re-allocating the buffer first, if necessary, to make it large enough. |
|
286 |
||
287 |
The function should be implemented by a derived class; this implementation |
|
288 |
is empty. |
|
289 |
||
290 |
This function is called by a file server reading successive entries, |
|
291 |
when the file server reads an entry for which the full file name is longer than |
|
292 |
the maximum buffer size. Once this function has been called, the iPending flag |
|
293 |
is set to true by the file server and, on the next call to ReadL(), |
|
294 |
the buffer created in this function is used to store the long entry name. |
|
295 |
||
296 |
The function should leave with an appropriate error code on error detection. |
|
297 |
||
298 |
@param aName The name to be set to a newly read entry. |
|
299 |
*/ |
|
300 |
EXPORT_C void CDirCB::StoreLongEntryNameL(const TDesC& /*aName*/) |
|
301 |
{} |
|
302 |
||
303 |
||
304 |
EXPORT_C TInt CDirCB::GetInterface(TInt /*aInterfaceId*/,TAny*& /*aInterface*/,TAny* /*aInput*/) |
|
305 |
{ |
|
306 |
return(KErrNotSupported); |
|
307 |
} |
|
308 |