author | Pat Downey <patd@symbian.org> |
Wed, 01 Sep 2010 12:34:56 +0100 | |
branch | RCL_3 |
changeset 44 | 3e88ff8f41d5 |
parent 42 | a179b74831c9 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1998-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_std.inl |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#ifndef SF_STD_INL |
|
19 |
#define SF_STD_INL |
|
20 |
||
21 |
//Class CFsRequest |
|
22 |
||
23 |
void CFsRequest::Kill(TInt aReason) |
|
24 |
{ |
|
25 |
if(!ErrorPlugin(aReason)) |
|
26 |
Message().Kill(aReason); |
|
27 |
} |
|
28 |
||
29 |
void CFsRequest::Terminate(TInt aReason) |
|
30 |
{ |
|
31 |
if(!ErrorPlugin(aReason)) |
|
32 |
Message().Terminate(aReason); |
|
33 |
} |
|
34 |
||
35 |
void CFsRequest::Panic(const TDesC &aCategory,TInt aReason) |
|
36 |
{ |
|
37 |
__IF_DEBUG(Print(_L("CFsRequest::Panic %S %d"),&aCategory,aReason)); |
|
38 |
if(!ErrorPlugin(aReason)) |
|
39 |
Message().Panic(aCategory,aReason); |
|
40 |
} |
|
41 |
||
42 |
TBool CFsRequest::ErrorPlugin(TInt aError) |
|
43 |
{ |
|
44 |
CFsMessageRequest& self = *(CFsMessageRequest*)this; |
|
45 |
CFsPlugin* plugin = self.iOwnerPlugin; |
|
46 |
if(plugin) |
|
47 |
{ |
|
48 |
plugin->iLastError = aError; |
|
49 |
plugin->iThreadP->OperationLockSignal(); |
|
50 |
self.iOwnerPlugin = NULL; |
|
51 |
return ETrue; |
|
52 |
} |
|
53 |
return EFalse; |
|
54 |
} |
|
55 |
||
56 |
// class CFsObjectIx |
|
57 |
TInt CFsObjectIx::Count() const |
|
58 |
{return(iHighWaterMark);} |
|
59 |
TInt CFsObjectIx::ActiveCount() const |
|
60 |
{return(iNumEntries);} |
|
61 |
void CFsObjectIx::Lock() |
|
62 |
{iLock.Wait();} |
|
63 |
void CFsObjectIx::Unlock() |
|
64 |
{iLock.Signal();} |
|
65 |
||
66 |
// class CFsObjectCon |
|
67 |
void CFsObjectCon::Lock() |
|
68 |
{iLock.Wait();} |
|
69 |
void CFsObjectCon::Unlock() |
|
70 |
{iLock.Signal();} |
|
71 |
TInt CFsObjectCon::UniqueID() const |
|
72 |
{return(iUniqueID);} |
|
73 |
TInt CFsObjectCon::Count() const |
|
74 |
{return(iCount);} |
|
75 |
||
76 |
// class CDisconnectThread |
|
77 |
CFsInternalRequest* CDisconnectThread::GetRequest() |
|
78 |
{return(iRequest);} |
|
79 |
||
80 |
||
81 |
||
82 |
||
83 |
||
84 |
||
85 |
||
86 |
||
87 |
// class CServerFs |
|
88 |
void CServerFs::SessionQueueLockWait() |
|
89 |
{iSessionQueueLock.Wait();} |
|
90 |
||
91 |
void CServerFs::SessionQueueLockSignal() |
|
92 |
{iSessionQueueLock.Signal();} |
|
93 |
||
94 |
// class CSessionFs |
|
95 |
void CSessionFs::IncResourceCount() |
|
96 |
{ __e32_atomic_add_ord32(&iResourceCount, 1); } |
|
97 |
void CSessionFs::DecResourceCount() |
|
98 |
{ __e32_atomic_add_ord32(&iResourceCount, (TUint32)(-1)); } |
|
99 |
CFsObjectIx& CSessionFs::Handles() |
|
100 |
{return(*iHandles);} |
|
101 |
||
102 |
||
103 |
HBufC& CSessionFs::Path() |
|
104 |
{/*__CHECK_MAINTHREAD();*/ return(*iPath);} |
|
105 |
void CSessionFs::SetPath(HBufC* aPath) |
|
106 |
{__CHECK_MAINTHREAD(); iPath=aPath;} |
|
107 |
||
108 |
TThreadId& CSessionFs::ThreadId() |
|
109 |
{ return iId; } |
|
110 |
void CSessionFs::SetThreadId(const TThreadId& aId) |
|
111 |
{ |
|
112 |
iId = aId; |
|
113 |
} |
|
114 |
||
115 |
||
116 |
// class TReservedDriveAccess |
|
117 |
TReservedDriveAccess::TReservedDriveAccess(TInt aDriveNumber) |
|
118 |
: iDriveNumber(aDriveNumber), |
|
119 |
iReservedSpace(0), |
|
120 |
iReservedAccess(EFalse) |
|
121 |
{ } |
|
122 |
||
123 |
TReservedDriveAccess::TReservedDriveAccess(TInt aDriveNumber, TInt aReservedSpace) |
|
124 |
: iDriveNumber(aDriveNumber), |
|
125 |
iReservedSpace(aReservedSpace), |
|
126 |
iReservedAccess(EFalse) |
|
127 |
{ } |
|
128 |
||
129 |
||
130 |
// class TOperation |
|
131 |
TBool TOperation::IsSync() const |
|
132 |
{return(iFlags & ESync)?(TBool)ETrue:(TBool)EFalse;} |
|
133 |
TInt TOperation::Function() |
|
134 |
{return(iFunction);} |
|
135 |
TInt TOperation::Initialise(CFsRequest* aRequest) |
|
136 |
{return((*iInitialise)(aRequest));} |
|
137 |
TInt TOperation::PostInitialise(CFsRequest* aRequest) |
|
138 |
{return((*iPostInitialise)(aRequest));} |
|
139 |
TInt TOperation::DoRequestL(CFsRequest* aRequest) |
|
140 |
{return((*iDoRequestL)(aRequest));} |
|
141 |
TFsPluginRequest::TF32ArgType TOperation::Arg(TUint aIndex) |
|
142 |
{return((TFsPluginRequest::TF32ArgType)((TUint8*)&iArgs)[aIndex]);} |
|
143 |
||
144 |
||
145 |
inline void TMsgOperation::Set(TInt64 aPos, TInt aLength, TUint8* aData, TInt aOffset, TInt aNextState) |
|
146 |
{ |
|
147 |
iReadWriteArgs.iPos = aPos; |
|
148 |
iReadWriteArgs.iTotalLength = iReadWriteArgs.iLength = aLength; |
|
149 |
iReadWriteArgs.iData = aData; |
|
150 |
iReadWriteArgs.iOffset = aOffset; |
|
151 |
iClientRequest = EFalse; |
|
152 |
iState = aNextState; |
|
153 |
} |
|
154 |
||
155 |
//Operations pushed from the client use this version of Set |
|
156 |
inline void TMsgOperation::Set(TInt64 aPos, TInt aLength, TDesC8* aData, TInt aOffset, TInt aNextState) |
|
157 |
{ |
|
158 |
iReadWriteArgs.iPos = aPos; |
|
159 |
iReadWriteArgs.iTotalLength = iReadWriteArgs.iLength = aLength; |
|
160 |
iReadWriteArgs.iData = aData; |
|
161 |
iReadWriteArgs.iOffset = aOffset; |
|
162 |
iClientRequest = ETrue; |
|
163 |
iState = aNextState; |
|
164 |
} |
|
165 |
||
166 |
// class CFsRequest |
|
167 |
TOperation* CFsRequest::Operation() |
|
168 |
{return(iOperation);} |
|
169 |
CSessionFs* CFsRequest::Session() |
|
170 |
{return(iSession);} |
|
171 |
void CFsRequest::SetSession(CSessionFs* aSession) |
|
172 |
{iSession=aSession;} |
|
173 |
TInt CFsRequest::DriveNumber() |
|
174 |
{return(iDriveNumber);} |
|
175 |
void CFsRequest::SetDriveNumber(TInt aDriveNumber) |
|
176 |
{iDriveNumber=aDriveNumber;} |
|
177 |
TBool CFsRequest::IsCompleted() |
|
178 |
{return(iIsCompleted);} |
|
179 |
void CFsRequest::SetCompleted(TBool aIsCompleted) |
|
180 |
{iIsCompleted=aIsCompleted;} |
|
181 |
TUint CFsRequest::ScratchValue() |
|
182 |
{return I64LOW(iScratchValue);} |
|
183 |
void CFsRequest::SetScratchValue(const TUint aValue) |
|
184 |
{SetAndOpenScratchValue(aValue);} |
|
185 |
TInt64 CFsRequest::ScratchValue64() |
|
186 |
{return(iScratchValue);} |
|
187 |
void CFsRequest::SetScratchValue64(const TInt64& aValue) |
|
188 |
{SetAndOpenScratchValue(aValue);} |
|
189 |
TBool CFsRequest::IsSeparateThread() |
|
190 |
{return(!iOperation->IsSync());} |
|
191 |
TBool CFsRequest::IsPostOperation() const |
|
192 |
{return iFlags & EPostOperation;} |
|
193 |
void CFsRequest::SetPostOperation(TBool aSet) |
|
194 |
{aSet? iFlags |= EPostOperation : iFlags &= ~EPostOperation;} |
|
195 |
TBool CFsRequest::IsPluginSpecific() const |
|
196 |
{return(iOperation->iFunction == EFsPluginOpen || |
|
197 |
iOperation->iFunction == EFsPluginDoRequest || |
|
198 |
iOperation->iFunction == EFsPluginDoControl || |
|
199 |
iOperation->iFunction == EFsPluginDoCancel);} |
|
200 |
||
201 |
TBool CFsRequest::IsExpectedResult(TInt aError) const |
|
202 |
{return ((aError == KErrNone) || |
|
203 |
(iOperation->iFunction == EFsDirReadPacked && aError == KErrEof));} |
|
204 |
||
205 |
void CFsRequest::SetError(TInt aError) |
|
206 |
{iError = aError;} |
|
207 |
||
208 |
TInt CFsRequest::GetError() const |
|
209 |
{return iError;} |
|
210 |
||
211 |
TBool CFsRequest::IsChangeNotify() const |
|
212 |
{ return ( iSession && iSession->IsChangeNotify() && iOperation->IsChangeNotify()); } |
|
213 |
||
214 |
void CFsRequest::SetState(TReqStates aReqState) |
|
215 |
{ iReqState = aReqState; } |
|
216 |
||
217 |
TBool CFsRequest::DirectToDrive() |
|
218 |
{ return(iDirectToDrive); } |
|
219 |
||
220 |
TBool CFsRequest::IsFsObjectOpen() |
|
221 |
{ return iFlags & EFsObjectOpen;} |
|
222 |
void CFsRequest::SetFsObjectOpen(TBool aSet) |
|
223 |
{aSet? iFlags |= EFsObjectOpen : iFlags &= ~EFsObjectOpen;} |
|
224 |
||
225 |
/** |
|
226 |
Returns ETrue if the IPC Message Argument slot is packed with descriptor data for |
|
227 |
EFsFileRead, EFsFileWrite, EFsFileSeek, EFsFileLock, EFsFileUnLock, EFsFileSize, |
|
228 |
EFsFileSetSize and EFsReadFileSection requests. |
|
229 |
||
230 |
@panic if the aMsgNum is greater than the number of IPC message arguments, KMaxMessageArguments. |
|
231 |
||
232 |
@param IPC message argument index |
|
233 |
*/ |
|
234 |
TBool CFsRequest::IsDescData(TInt aMsgNum) |
|
235 |
{ |
|
236 |
__ASSERT_DEBUG(aMsgNum < KMaxMessageArguments, Fault(EBadMessageSlotIndex)); |
|
237 |
return ((1 << (aMsgNum + KIpcFlagOffset)) & Message().Function())?(TBool)ETrue:(TBool)EFalse; |
|
238 |
} |
|
239 |
||
240 |
/** |
|
241 |
Least 16 bits (0 to 15) are used for file server operation index. |
|
242 |
Remaining bits (16 to 31) are reserved for other purposes. |
|
243 |
Should be called in place of CFsRequest::Message().Function() |
|
244 |
if the file server operation index is required. |
|
245 |
||
246 |
@return Returns the file server operation index by masking the upper 16 bits. |
|
247 |
*/ |
|
248 |
TInt CFsRequest::FsFunction() |
|
249 |
{return (Message().Function() & KIpcFunctionMask);} |
|
250 |
||
251 |
// class CFsMessageRequest |
|
252 |
void CFsMessageRequest::SetMessage(RMessage2& aMessage) |
|
253 |
{iMessage=aMessage;} |
|
254 |
||
42
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
21
diff
changeset
|
255 |
|
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
21
diff
changeset
|
256 |
CFsMessageRequest* CFsMessageRequest::RequestFromMessage(const RMessagePtr2& aMessage) |
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
21
diff
changeset
|
257 |
{return _LOFF(&aMessage, CFsMessageRequest, iMessage);} |
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
21
diff
changeset
|
258 |
|
a179b74831c9
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
21
diff
changeset
|
259 |
|
0 | 260 |
TMsgOperation* CFsMessageRequest::CurrentOperationPtr() |
261 |
{return iCurrentOperation;} |
|
262 |
||
263 |
// class CFsInternalRequest |
|
264 |
void CFsInternalRequest::SetThreadHandle(TInt aThreadHandle) |
|
265 |
{iThreadHandle=aThreadHandle;} |
|
266 |
TInt CFsInternalRequest::ThreadHandle() |
|
267 |
{return(iThreadHandle);} |
|
268 |
TRequestStatus& CFsInternalRequest::Status() |
|
269 |
{return(iStatus);} |
|
270 |
TBool CFsInternalRequest::IsAllocated() |
|
271 |
{return(iIsAllocated);} |
|
272 |
void CFsInternalRequest::SetAllocated() |
|
273 |
{iIsAllocated=ETrue;} |
|
274 |
||
275 |
// class CFsMessageRequest |
|
276 |
TBool CFsMessageRequest::IsFreeChanged() |
|
277 |
{return(iFlags & EFreeChanged);} |
|
278 |
void CFsMessageRequest::SetFreeChanged(TBool aChanged) |
|
279 |
{ if (aChanged) iFlags |= EFreeChanged; else iFlags &= ~EFreeChanged;}; |
|
280 |
TBool CFsMessageRequest::IsAllocated() |
|
281 |
{return(iFlags & EIsAllocated);} |
|
282 |
void CFsMessageRequest::SetAllocated() |
|
283 |
{iFlags |= EIsAllocated;} |
|
284 |
CFsMessageRequest::CFsMessageRequest() |
|
285 |
{iFlags &= ~EIsAllocated;} |
|
286 |
||
287 |
TBool CFsMessageRequest::PostInterceptEnabled() |
|
288 |
{return iFlags & EPostInterceptEnabled;} |
|
289 |
void CFsMessageRequest::EnablePostIntercept(TBool aEnable) |
|
290 |
{if (aEnable) iFlags |= EPostInterceptEnabled; else iFlags &= ~EPostInterceptEnabled;} |
|
291 |
||
292 |
||
293 |
||
294 |
inline TInt& CFsMessageRequest::LastError() |
|
295 |
{ |
|
296 |
return iLastError; |
|
297 |
} |
|
298 |
inline void CFsMessageRequest::SetLastError(TInt aLastError) |
|
299 |
{ |
|
300 |
iLastError = aLastError; |
|
301 |
} |
|
302 |
||
303 |
inline void CFsMessageRequest::Init() |
|
304 |
{ |
|
305 |
SetLastError(KErrNone); |
|
306 |
iCurrentOperation = NULL; |
|
307 |
} |
|
308 |
||
309 |
||
310 |
// class CNotifyInfo |
|
311 |
CSessionFs* CNotifyInfo::Session() |
|
312 |
{return(iSession);} |
|
313 |
TRequestStatus* CNotifyInfo::Status() |
|
314 |
{return(iStatus);} |
|
315 |
||
316 |
#if defined(_USE_CONTROLIO) || defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
317 |
// Class RequestAllocator |
|
318 |
/** returns number of permanently & dynamically allocated requests */ |
|
21
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
319 |
TInt RequestAllocator::RequestCount() |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
320 |
{ return iRequestCount;} |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
321 |
TInt RequestAllocator::RequestCountPeak() |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
322 |
{ return iRequestCountPeak;} |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
323 |
|
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
324 |
TInt OperationAllocator::FreeCount() |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
325 |
{ return iFreeCount;} |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
326 |
TInt OperationAllocator::RequestCount() |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
327 |
{ return iRequestCount;} |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
328 |
TInt OperationAllocator::RequestCountPeak() |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
329 |
{ return iRequestCountPeak;} |
e7d2d738d3c2
Revision: 201010
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
330 |
|
0 | 331 |
#endif |
332 |
||
333 |
//--------------------------------------------------------------------------------------------------------------------- |
|
334 |
||
335 |
inline CFileSystem* CMountBody::GetFileSystem() const |
|
336 |
{ |
|
337 |
return iFSys; |
|
338 |
} |
|
339 |
||
340 |
inline void CMountBody::SetFileSystem(CFileSystem* aFsys) |
|
341 |
{ |
|
342 |
iFSys = aFsys; |
|
343 |
} |
|
344 |
||
345 |
||
346 |
||
347 |
#endif //SF_STD_INL |
|
348 |
||
349 |