0
|
1 |
// Copyright (c) 2005-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_plugin_util.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include "sf_std.h"
|
|
19 |
|
|
20 |
/**
|
|
21 |
Utility function to obtain the file name from a file share object
|
|
22 |
|
|
23 |
@param aFileShare A pointer to the file share
|
|
24 |
@param aName A reference to the descriptor to contain the file name
|
|
25 |
*/
|
|
26 |
LOCAL_C void NameFromShare(CFileShare* aFileShare, TDes& aName)
|
|
27 |
{
|
|
28 |
if(aFileShare)
|
|
29 |
{
|
|
30 |
CFileCB& theFile = aFileShare->File();
|
|
31 |
aName = _L("?:");
|
|
32 |
aName[0] = TText('A' + theFile.Drive().DriveNumber());
|
|
33 |
aName.Append(theFile.FileName());
|
|
34 |
}
|
|
35 |
}
|
|
36 |
|
|
37 |
/**
|
|
38 |
Utility function for obtaining info on file duplicate or adopt requests.
|
|
39 |
|
|
40 |
@param aRequest File access request
|
|
41 |
@param aDriveNumber The drive number
|
|
42 |
@param aHandle sub-session handle
|
|
43 |
@param aAtt File attributes
|
|
44 |
@param aSize FileSize
|
|
45 |
@param aName Name of the file
|
|
46 |
@return File modification time in format of TTime
|
|
47 |
*/
|
|
48 |
LOCAL_C TInt FileDuplicateAdoptVars(CFsRequest* aRequest, TInt& aDriveNumber, TInt& aHandle, TInt& aAtt, TInt& aSize, TDes& aName, TTime& aTime)
|
|
49 |
{
|
|
50 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsFileDuplicate || aRequest->Operation()->Function()==EFsFileAdopt,Fault(EBaseRequestMessage));
|
|
51 |
|
|
52 |
aDriveNumber = aRequest->DriveNumber();
|
|
53 |
aHandle = aRequest->Message().Int0();
|
|
54 |
|
|
55 |
CFileShare* share = (CFileShare*)aRequest->ScratchValue();
|
|
56 |
if(share == NULL)
|
|
57 |
return(KErrBadHandle);
|
|
58 |
|
|
59 |
NameFromShare(share, aName);
|
|
60 |
|
|
61 |
CFileCB& theFile = share->File();
|
|
62 |
aAtt = theFile.Att();
|
|
63 |
aSize = theFile.Size();
|
|
64 |
aTime = theFile.Modified();
|
|
65 |
|
|
66 |
return(KErrNone);
|
|
67 |
}
|
|
68 |
|
|
69 |
/**
|
|
70 |
Utility function for obtaining info on file open requests.
|
|
71 |
|
|
72 |
@param aRequest File open request
|
|
73 |
@param aMode File Open Mode
|
|
74 |
@param aHandle File handle
|
|
75 |
@param aName File's name
|
|
76 |
*/
|
|
77 |
LOCAL_C TInt FileOpenVar(CFsRequest* aRequest, TUint32& aMode, TInt& aHandle, TDes& aName)
|
|
78 |
{
|
|
79 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsFileOpen,Fault(EBaseRequestMessage));
|
|
80 |
|
|
81 |
aMode = aRequest->Message().Int1();
|
|
82 |
TPtr8 handle((TUint8*)&aHandle,sizeof(TInt));
|
|
83 |
TRAPD(err,aRequest->ReadL(KMsgPtr3,handle));
|
|
84 |
if(err != KErrNone)
|
|
85 |
{
|
|
86 |
handle=0;
|
|
87 |
return(err);
|
|
88 |
}
|
|
89 |
|
|
90 |
aName = aRequest->Src().FullName();
|
|
91 |
|
|
92 |
return(KErrNone);
|
|
93 |
}
|
|
94 |
|
|
95 |
/**
|
|
96 |
Utility function for obtaining info on file Create/Replace requests.
|
|
97 |
|
|
98 |
@param aRequest File Create/Replace request
|
|
99 |
@param aMode File Create/Replace Mode
|
|
100 |
@param aName File's name
|
|
101 |
*/
|
|
102 |
LOCAL_C TInt FileCreateReplaceVar(CFsRequest* aRequest, TUint32& aMode, TDes& aName)
|
|
103 |
{
|
|
104 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsFileCreate || aRequest->Operation()->Function()==EFsFileReplace,Fault(EBaseRequestMessage));
|
|
105 |
|
|
106 |
aMode = aRequest->Message().Int1();
|
|
107 |
aName = aRequest->Src().FullName();
|
|
108 |
|
|
109 |
return(KErrNone);
|
|
110 |
}
|
|
111 |
|
|
112 |
/**
|
|
113 |
Utility function for obtaining info on file temp requests.
|
|
114 |
|
|
115 |
@param aRequest File temp request
|
|
116 |
@param aMode File Mode
|
|
117 |
@param aName File's name
|
|
118 |
@param aPath File's path
|
|
119 |
*/
|
|
120 |
LOCAL_C TInt FileTempVar(CFsRequest* aRequest, TUint32& aMode, TDes& aName,TDes& aPath)
|
|
121 |
{
|
|
122 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsFileTemp,Fault(EBaseRequestMessage));
|
|
123 |
|
|
124 |
aMode = aRequest->Message().Int1();
|
|
125 |
aPath = aRequest->Src().FullName();
|
|
126 |
|
|
127 |
TInt nameLen = aRequest->GetDesLength(KMsgPtr2);
|
|
128 |
if(nameLen < 0 || nameLen > KMaxFileName)
|
|
129 |
{
|
|
130 |
return KErrBadName;
|
|
131 |
}
|
|
132 |
|
|
133 |
TRAPD(err, aRequest->ReadL(KMsgPtr2, aName));
|
|
134 |
return(err);
|
|
135 |
}
|
|
136 |
|
|
137 |
/**
|
|
138 |
Utility function for obtaining info on file read/write requests.
|
|
139 |
|
|
140 |
@param aRequest File access request
|
|
141 |
@param aLen The length of file for access
|
|
142 |
@param aPos Position of first byte to be accessed
|
|
143 |
@param aName File name
|
|
144 |
@return Client's buffer
|
|
145 |
*/
|
|
146 |
LOCAL_C TInt FileAccessVars(CFsRequest* aRequest, TInt& aLen, TInt& aPos, TDes& aName, const TAny*& aPtr)
|
|
147 |
{
|
|
148 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsFileRead || aRequest->Operation()->Function()==EFsFileWrite,Fault(EBaseRequestMessage));
|
|
149 |
|
|
150 |
TMsgOperation& currentOperation = ((CFsMessageRequest*) aRequest)->CurrentOperation();
|
|
151 |
aLen = currentOperation.iReadWriteArgs.iLength;
|
|
152 |
aPos = (TInt) currentOperation.iReadWriteArgs.iPos;
|
|
153 |
|
|
154 |
CFileShare* share = (CFileShare*)aRequest->ScratchValue();
|
|
155 |
if(share == NULL)
|
|
156 |
return(KErrBadHandle);
|
|
157 |
|
|
158 |
NameFromShare(share, aName);
|
|
159 |
if (aPos == KCurrentPosition64)
|
|
160 |
{
|
|
161 |
aPos = (TInt)share->iPos;
|
|
162 |
}
|
|
163 |
|
|
164 |
aPtr = (TAny*)aRequest->Message().Ptr0();
|
|
165 |
|
|
166 |
return(KErrNone);
|
|
167 |
}
|
|
168 |
|
|
169 |
/**
|
|
170 |
Utility function for obtaining info on file lock/unlcok requests.
|
|
171 |
|
|
172 |
@param aRequest File lock request
|
|
173 |
@param aLen The length of file
|
|
174 |
@param aPos Position of first byte
|
|
175 |
@param aName File name
|
|
176 |
*/
|
|
177 |
LOCAL_C TInt FileLockVars(CFsRequest* aRequest, TInt& aLen, TInt& aPos, TDes& aName)
|
|
178 |
{
|
|
179 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsFileLock || aRequest->Operation()->Function()==EFsFileUnLock,Fault(EBaseRequestMessage));
|
|
180 |
|
|
181 |
aLen = aRequest->Message().Int0();
|
|
182 |
aPos = aRequest->Message().Int1();
|
|
183 |
|
|
184 |
CFileShare* share = (CFileShare*)aRequest->ScratchValue();
|
|
185 |
if(share == NULL)
|
|
186 |
return(KErrBadHandle);
|
|
187 |
|
|
188 |
NameFromShare(share, aName);
|
|
189 |
|
|
190 |
return(KErrNone);
|
|
191 |
}
|
|
192 |
|
|
193 |
/**
|
|
194 |
Utility function for obtaining info on file seek requests.
|
|
195 |
|
|
196 |
@param aRequest File seek request
|
|
197 |
@param aPos The position within the file
|
|
198 |
@param aName File name
|
|
199 |
@return Seek mode in format of TSeek
|
|
200 |
*/
|
|
201 |
LOCAL_C TInt FileSeekVars(CFsRequest* aRequest, TInt& aPos, TDes& aName, const TAny*& aPtr)
|
|
202 |
{
|
|
203 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsFileSeek,Fault(EBaseRequestMessage));
|
|
204 |
|
|
205 |
aPos = aRequest->Message().Int0();
|
|
206 |
|
|
207 |
CFileShare* share = (CFileShare*)aRequest->ScratchValue();
|
|
208 |
if(share == NULL)
|
|
209 |
return(KErrBadHandle);
|
|
210 |
|
|
211 |
NameFromShare(share, aName);
|
|
212 |
|
|
213 |
aPtr = aRequest->Message().Ptr1();
|
|
214 |
|
|
215 |
return(KErrNone);
|
|
216 |
}
|
|
217 |
|
|
218 |
/**
|
|
219 |
Utility function for obtaining info on file flush requests.
|
|
220 |
|
|
221 |
@param aRequest File flush request
|
|
222 |
@param aName File name
|
|
223 |
*/
|
|
224 |
LOCAL_C TInt FileFlushVars(CFsRequest* aRequest, TDes& aName)
|
|
225 |
{
|
|
226 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsFileFlush,Fault(EBaseRequestMessage));
|
|
227 |
|
|
228 |
CFileShare* share = (CFileShare*)aRequest->ScratchValue();
|
|
229 |
if(share == NULL)
|
|
230 |
return(KErrBadHandle);
|
|
231 |
|
|
232 |
NameFromShare(share, aName);
|
|
233 |
|
|
234 |
return(KErrNone);
|
|
235 |
}
|
|
236 |
|
|
237 |
/**
|
|
238 |
Utility function for obtaining info on file size/SetSize requests.
|
|
239 |
|
|
240 |
@param aRequest File Size/SetSize request
|
|
241 |
@param aSize In case of Size() it is client's buffer, otherwise it is the desired size for SetSize
|
|
242 |
@param aName File name
|
|
243 |
*/
|
|
244 |
LOCAL_C TInt FileSizeVars(CFsRequest* aRequest,TInt& aSize, TDes& aName)
|
|
245 |
{
|
|
246 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsFileSize || aRequest->Operation()->Function()==EFsFileSetSize,Fault(EBaseRequestMessage));
|
|
247 |
|
|
248 |
aSize = aRequest->Message().Int0();
|
|
249 |
|
|
250 |
CFileShare* share = (CFileShare*)aRequest->ScratchValue();
|
|
251 |
if(share == NULL)
|
|
252 |
return(KErrBadHandle);
|
|
253 |
|
|
254 |
NameFromShare(share, aName);
|
|
255 |
|
|
256 |
return(KErrNone);
|
|
257 |
}
|
|
258 |
|
|
259 |
/**
|
|
260 |
Utility function for obtaining info on file Att requests.
|
|
261 |
|
|
262 |
@param aRequest File Att request
|
|
263 |
@param aAtt Attribute of the file in question.
|
|
264 |
@param aName File name
|
|
265 |
*/
|
|
266 |
LOCAL_C TInt FileAttVars(CFsRequest* aRequest,TInt& aAtt, TDes& aName)
|
|
267 |
{
|
|
268 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsFileAtt,Fault(EBaseRequestMessage));
|
|
269 |
|
|
270 |
CFileShare* share = (CFileShare*)aRequest->ScratchValue();
|
|
271 |
if(share == NULL)
|
|
272 |
return(KErrBadHandle);
|
|
273 |
|
|
274 |
aAtt = (TInt)share->File().Att();
|
|
275 |
NameFromShare(share, aName);
|
|
276 |
|
|
277 |
return(KErrNone);
|
|
278 |
}
|
|
279 |
|
|
280 |
/**
|
|
281 |
Utility function for obtaining info on file SetAtt requests.
|
|
282 |
|
|
283 |
@param aRequest File SetAtt request
|
|
284 |
@param aAtt Current Attribute of the file
|
|
285 |
@param aName File name
|
|
286 |
@param aSetAttMask The attribute mask to be set
|
|
287 |
@param aClearAttMask The attribute mask to be cleared
|
|
288 |
*/
|
|
289 |
LOCAL_C TInt FileSetAttVars(CFsRequest* aRequest,TInt& aAtt, TDes& aName, TUint& aSetAttMask,TUint& aClearAttMask)
|
|
290 |
{
|
|
291 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsFileSetAtt,Fault(EBaseRequestMessage));
|
|
292 |
|
|
293 |
CFileShare* share=(CFileShare*)aRequest->ScratchValue();
|
|
294 |
if(share == NULL)
|
|
295 |
return(KErrBadHandle);
|
|
296 |
|
|
297 |
aAtt = (TInt)share->File().Att();
|
|
298 |
NameFromShare(share, aName);
|
|
299 |
|
|
300 |
aSetAttMask = aRequest->Message().Int0();
|
|
301 |
aClearAttMask = aRequest->Message().Int1();
|
|
302 |
|
|
303 |
return(KErrNone);
|
|
304 |
}
|
|
305 |
|
|
306 |
/**
|
|
307 |
Utility function for obtaining info on file modification requests.
|
|
308 |
|
|
309 |
@param aRequest File Modified/SetModified request
|
|
310 |
@param aAtt Current Attribute of the file
|
|
311 |
@param aSize Current size of the file
|
|
312 |
@param aName File name
|
|
313 |
@param Moidfied Last modified time of the file
|
|
314 |
@return if request is Modified, returns clients buffer
|
|
315 |
if request is SetModified returns the desired last modification time
|
|
316 |
*/
|
|
317 |
LOCAL_C TInt FileModificationVars(CFsRequest* aRequest,TInt& aAtt, TInt& aSize, TDes& aName, TTime& aModified, TTime& aOldTime)
|
|
318 |
{
|
|
319 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsFileModified || aRequest->Operation()->Function()==EFsFileSetModified,Fault(EBaseRequestMessage));
|
|
320 |
|
|
321 |
CFileShare* share = (CFileShare*)aRequest->ScratchValue();
|
|
322 |
if(share == NULL)
|
|
323 |
return(KErrBadHandle);
|
|
324 |
|
|
325 |
NameFromShare(share, aName);
|
|
326 |
|
|
327 |
CFileCB& file = share->File();
|
|
328 |
aAtt = file.Att();
|
|
329 |
aSize = file.Size();
|
|
330 |
aOldTime = file.Modified();
|
|
331 |
|
|
332 |
TPtr8 timePkg((TUint8*)&aModified, sizeof(TTime));
|
|
333 |
TRAPD(err, aRequest->ReadL(KMsgPtr0, timePkg));
|
|
334 |
|
|
335 |
return(err);
|
|
336 |
}
|
|
337 |
|
|
338 |
/**
|
|
339 |
Utility function for obtaining info on file Set requests.
|
|
340 |
|
|
341 |
@param aRequest File Set request
|
|
342 |
@param aName File name
|
|
343 |
@param aCurrentAtt Current Attribute of the file
|
|
344 |
@param aNewSetAtt The new attribute to be set
|
|
345 |
@param aNewClearAtt The attribute to be cleared
|
|
346 |
@param aCurrentModified Last modified time of the file
|
|
347 |
@param aNewModified New last modified time of the file
|
|
348 |
*/
|
|
349 |
LOCAL_C TInt FileSetVars(CFsRequest* aRequest, TDes& aName, TInt& aCurrentAtt,TInt& aNewSetAtt, TInt& aNewClearAtt, TTime& aCurrentModified, TTime& aNewModified)
|
|
350 |
{
|
|
351 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsFileSet,Fault(EBaseRequestMessage));
|
|
352 |
|
|
353 |
CFileShare* share = (CFileShare*)aRequest->ScratchValue();
|
|
354 |
if(share == NULL)
|
|
355 |
return(KErrBadHandle);
|
|
356 |
|
|
357 |
NameFromShare(share, aName);
|
|
358 |
|
|
359 |
CFileCB& file = share->File();
|
|
360 |
aCurrentAtt= file.Att();
|
|
361 |
aCurrentModified = file.Modified();
|
|
362 |
|
|
363 |
aNewSetAtt = aRequest->Message().Int1();
|
|
364 |
aNewClearAtt = aRequest->Message().Int2();
|
|
365 |
|
|
366 |
TPtr8 timePkg((TUint8*)&aNewModified, sizeof(TTime));
|
|
367 |
TRAPD(err, aRequest->ReadL(KMsgPtr0, timePkg));
|
|
368 |
return(err);
|
|
369 |
}
|
|
370 |
|
|
371 |
/**
|
|
372 |
Utility function for obtaining info on file ChangeMode requests.
|
|
373 |
|
|
374 |
@param aRequest File Set request
|
|
375 |
@param aName File name
|
|
376 |
@param aCurrentMode Current mode of the file
|
|
377 |
@param aNewMode The new mode of file (switch between EFileShareExclusive and EFileShareReadersOnly
|
|
378 |
@param aModified Last modified time of the file
|
|
379 |
*/
|
|
380 |
LOCAL_C TInt FileChangeModeVars(CFsRequest* aRequest, TDes& aName, TInt& aCurrentMode,TInt& aNewMode, TTime& aModified)
|
|
381 |
{
|
|
382 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsFileChangeMode,Fault(EBaseRequestMessage));
|
|
383 |
|
|
384 |
CFileShare* share = (CFileShare*)aRequest->ScratchValue();
|
|
385 |
if(share == NULL)
|
|
386 |
return(KErrBadHandle);
|
|
387 |
|
|
388 |
NameFromShare(share, aName);
|
|
389 |
aCurrentMode = share->iMode & KFileShareMask;
|
|
390 |
aModified = share->File().Modified();
|
|
391 |
|
|
392 |
aNewMode = aRequest->Message().Int0();
|
|
393 |
|
|
394 |
return(KErrNone);
|
|
395 |
}
|
|
396 |
|
|
397 |
/**
|
|
398 |
Utility function for obtaining info on file Rename requests.
|
|
399 |
|
|
400 |
@param aRequest File Rename request
|
|
401 |
@param aCurrentName File's current name
|
|
402 |
@param aCurrentDrive File's current drive
|
|
403 |
@param aNewName the new name
|
|
404 |
@return KErrNone on successful read of info from CFsRequest or a system wide error
|
|
405 |
*/
|
|
406 |
LOCAL_C TInt FileRenameVars(CFsRequest* aRequest, TDes& aCurrentName, TDriveUnit& aCurrentDrive, TDes& aNewName)
|
|
407 |
{
|
|
408 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsFileRename,Fault(EBaseRequestMessage));
|
|
409 |
|
|
410 |
CFileShare* share = (CFileShare*)aRequest->ScratchValue();
|
|
411 |
if(share == NULL)
|
|
412 |
return(KErrBadHandle);
|
|
413 |
|
|
414 |
NameFromShare(share, aCurrentName);
|
|
415 |
aCurrentDrive = share->File().Mount().Drive().DriveNumber();
|
|
416 |
|
|
417 |
aNewName = aRequest->Dest().FullName();
|
|
418 |
|
|
419 |
return(KErrNone);
|
|
420 |
}
|
|
421 |
|
|
422 |
/**
|
|
423 |
Utility function for obtaining info on file Drive/Name requests.
|
|
424 |
|
|
425 |
@param aRequest File Rename request
|
|
426 |
@param aFileName File's current name
|
|
427 |
@param aCurrentDrive File's current drive
|
|
428 |
@param aDriveInfo File's drive information
|
|
429 |
*/
|
|
430 |
LOCAL_C TInt FileDriveNameVars(CFsRequest* aRequest, TDes& aFileName, TDriveUnit& aCurrentDrive,TDriveInfo& aDriveInfo)
|
|
431 |
{
|
|
432 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsFileDrive || aRequest->Operation()->Function()==EFsFileName,Fault(EBaseRequestMessage));
|
|
433 |
|
|
434 |
CFileShare* share = (CFileShare*)aRequest->ScratchValue();
|
|
435 |
if(share == NULL)
|
|
436 |
return(KErrBadHandle);
|
|
437 |
|
|
438 |
NameFromShare(share, aFileName);
|
|
439 |
aCurrentDrive = share->File().Mount().Drive().DriveNumber();
|
|
440 |
share->File().Mount().Drive().DriveInfo(aDriveInfo);
|
|
441 |
|
|
442 |
return(KErrNone);
|
|
443 |
}
|
|
444 |
|
|
445 |
/**
|
|
446 |
Utility function for obtaining info on file delete requests.
|
|
447 |
|
|
448 |
@param aRequest Dir read request
|
|
449 |
@param aFileName The name of the file
|
|
450 |
*/
|
|
451 |
LOCAL_C TInt FileDelVars(CFsRequest* aRequest, TDes& aFileName)
|
|
452 |
{
|
|
453 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsDelete,Fault(EBaseRequestMessage));
|
|
454 |
|
|
455 |
aFileName = aRequest->Src().FullName();
|
|
456 |
|
|
457 |
return(KErrNone);
|
|
458 |
}
|
|
459 |
|
|
460 |
/**
|
|
461 |
Utility function for obtaining info on file rename/replace requests.
|
|
462 |
|
|
463 |
@param aRequest File rename/replace request
|
|
464 |
@param aOldFileName The old name of the file
|
|
465 |
@param aNewFileName The new name of the file
|
|
466 |
*/
|
|
467 |
LOCAL_C TInt FileRenameReplaceVars(CFsRequest* aRequest, TDes& aOldFileName,TDes& aNewFileName)
|
|
468 |
{
|
|
469 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsRename || aRequest->Operation()->Function()==EFsReplace,Fault(EBaseRequestMessage));
|
|
470 |
|
|
471 |
aOldFileName = aRequest->Src().FullName();
|
|
472 |
aNewFileName = aRequest->Dest().FullName();
|
|
473 |
|
|
474 |
return(KErrNone);
|
|
475 |
}
|
|
476 |
|
|
477 |
/**
|
|
478 |
Utility function for obtaining info on file close requests.
|
|
479 |
|
|
480 |
@param aRequest File close request
|
|
481 |
@param aPath The path of the file
|
|
482 |
@return KErrNone
|
|
483 |
*/
|
|
484 |
LOCAL_C TInt FileCloseVars(CFsRequest* aRequest, TDes& aFileName)
|
|
485 |
{
|
|
486 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsFileSubClose,Fault(EBaseRequestMessage));
|
|
487 |
|
|
488 |
const TDes* fileName=(TDes*) I64HIGH(aRequest->ScratchValue64());
|
|
489 |
if(fileName == NULL)
|
|
490 |
return(KErrBadName);
|
|
491 |
|
|
492 |
aFileName = _L("?:");
|
|
493 |
aFileName[0] = TText('A' + aRequest->DriveNumber());
|
|
494 |
aFileName.Append(*fileName);
|
|
495 |
|
|
496 |
return(KErrNone);
|
|
497 |
}
|
|
498 |
|
|
499 |
/**
|
|
500 |
Dir Operations
|
|
501 |
*/
|
|
502 |
|
|
503 |
/**
|
|
504 |
Utility function for obtaining info on dir Open requests.
|
|
505 |
|
|
506 |
@param aRequest Dir Open request
|
|
507 |
@param aDirName Name of Dir
|
|
508 |
@param aAtt Attribute
|
|
509 |
@param aUidType Uid Type
|
|
510 |
*/
|
|
511 |
LOCAL_C TInt DirOpenVars(CFsRequest* aRequest, TDes& aDirName, TInt& aAtt,TInt& aUidType)
|
|
512 |
{
|
|
513 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsDirOpen,Fault(EBaseRequestMessage));
|
|
514 |
|
|
515 |
aDirName = aRequest->Src().FullName();
|
|
516 |
|
|
517 |
aAtt = aRequest->Message().Int1();
|
|
518 |
aUidType = aRequest->Message().Int2();
|
|
519 |
|
|
520 |
return(KErrNone);
|
|
521 |
}
|
|
522 |
|
|
523 |
|
|
524 |
/**
|
|
525 |
Utility function for obtaining info on dir Make requests.
|
|
526 |
|
|
527 |
@param aRequest MkDir/MkDirAll request
|
|
528 |
@param aMkDirAll if MkDirAll it will be 1
|
|
529 |
@param aPath The path name specifiying the directory or directories to create.
|
|
530 |
*/
|
|
531 |
LOCAL_C TInt DirMakeVars(CFsRequest* aRequest, TInt& aMkDirAll, TDes& aPath)
|
|
532 |
{
|
|
533 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsMkDir,Fault(EBaseRequestMessage));
|
|
534 |
|
|
535 |
aMkDirAll = aRequest->Message().Int1();
|
|
536 |
aPath = aRequest->Src().FullName();
|
|
537 |
|
|
538 |
return(KErrNone);
|
|
539 |
}
|
|
540 |
|
|
541 |
/**
|
|
542 |
Utility function for obtaining info on dir remove requests.
|
|
543 |
|
|
544 |
@param aRequest RmDir request
|
|
545 |
@param aPath The path name specifiying the directory to be removed.
|
|
546 |
*/
|
|
547 |
LOCAL_C TInt DirRemoveVars(CFsRequest* aRequest, TDes& aPath)
|
|
548 |
{
|
|
549 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsRmDir,Fault(EBaseRequestMessage));
|
|
550 |
|
|
551 |
aPath = aRequest->Src().FullName();
|
|
552 |
|
|
553 |
return(KErrNone);
|
|
554 |
}
|
|
555 |
|
|
556 |
/**
|
|
557 |
Utility function for obtaining info on file entry requests.
|
|
558 |
|
|
559 |
@param aRequest File entry request
|
|
560 |
@param aName Entry name
|
|
561 |
*/
|
|
562 |
LOCAL_C TInt FileEntryVars(CFsRequest* aRequest, TDes& aName)
|
|
563 |
{
|
|
564 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsEntry,Fault(EBaseRequestMessage));
|
|
565 |
|
|
566 |
aName = aRequest->Src().FullName();
|
|
567 |
|
|
568 |
return(KErrNone);
|
|
569 |
}
|
|
570 |
|
|
571 |
/**
|
|
572 |
Utility function for obtaining info on file read file section requests.
|
|
573 |
|
|
574 |
@param aRequest Read file section request
|
|
575 |
@param aLen The length of file for access
|
|
576 |
@param aPos Position of first byte to be accessed
|
|
577 |
@param aName File name
|
|
578 |
@return KErrNone successful (aLen aPos and aName updated)
|
|
579 |
*/
|
|
580 |
LOCAL_C TInt FileSectionVars(CFsRequest* aRequest, TInt& aLen, TInt& aPos, TDes& aName)
|
|
581 |
{
|
|
582 |
__ASSERT_ALWAYS(aRequest->Operation()->Function()==EFsReadFileSection,Fault(EBaseRequestMessage));
|
|
583 |
|
|
584 |
aPos = aRequest->Message().Int2();
|
|
585 |
aLen = aRequest->Message().Int3();
|
|
586 |
|
|
587 |
aName = aRequest->Src().FullName();
|
|
588 |
|
|
589 |
return(KErrNone);
|
|
590 |
}
|
|
591 |
|
|
592 |
/**
|
|
593 |
@internalTechnology
|
|
594 |
|
|
595 |
Utility function for obtaining the name of the file/dir from the client request
|
|
596 |
Supported requests are:
|
|
597 |
|
|
598 |
EFsFileDuplicate
|
|
599 |
EFsFileAdopt
|
|
600 |
EFsFileOpen
|
|
601 |
EFsFileCreate
|
|
602 |
EFsFileReplace
|
|
603 |
EFsFileTemp
|
|
604 |
EFsFileRead
|
|
605 |
EFsFileWrite
|
|
606 |
EFsFileLock
|
|
607 |
EFsFileUnLock
|
|
608 |
EFsFileSeek
|
|
609 |
EFsFileFlush
|
|
610 |
EFsFileSize
|
|
611 |
EFsFileSetSize
|
|
612 |
EFsFileAtt
|
|
613 |
EFsFileSetAtt
|
|
614 |
EFsFileModified
|
|
615 |
EFsFileSetModified
|
|
616 |
EFsFileSet
|
|
617 |
EFsFileChangeMode
|
|
618 |
EFsFileRename
|
|
619 |
EFsFileDrive
|
|
620 |
EFsFileName
|
|
621 |
EFsDelete
|
|
622 |
EFsRename
|
|
623 |
EFsReplace
|
|
624 |
EFsDirOpen
|
|
625 |
EFsFileSubClose
|
|
626 |
EFsEntry
|
|
627 |
EFsReadFileSection
|
|
628 |
EFsFileWriteDirty
|
|
629 |
|
|
630 |
@param aRequest The client request
|
|
631 |
@param aName Name of the file/folder
|
|
632 |
@return KErrNone on successful completion, KErrNotSupported if the request is not supported
|
|
633 |
*/
|
|
634 |
EXPORT_C TInt GetName(TFsPluginRequest* aRequest, TDes& aName)
|
|
635 |
{
|
|
636 |
TInt driveNumber;
|
|
637 |
TInt handle;
|
|
638 |
TInt att;
|
|
639 |
TInt size;
|
|
640 |
TUint32 mode;
|
|
641 |
TPath path;
|
|
642 |
TFileName newName;
|
|
643 |
TInt pos;
|
|
644 |
TInt len;
|
|
645 |
TUint attMask;
|
|
646 |
TTime modified;
|
|
647 |
TInt fmode;
|
|
648 |
TDriveUnit drive;
|
|
649 |
TDriveInfo info;
|
|
650 |
TInt uidType;
|
|
651 |
const TAny* ptr;
|
|
652 |
TInt err = KErrNone;
|
|
653 |
switch(aRequest->Function())
|
|
654 |
{
|
|
655 |
case EFsFileDuplicate:
|
|
656 |
case EFsFileAdopt:
|
|
657 |
err = FileDuplicateAdoptVars(aRequest->Request(), driveNumber, handle, att, size, aName, modified);
|
|
658 |
break;
|
|
659 |
case EFsFileOpen:
|
|
660 |
err = FileOpenVar(aRequest->Request(), mode, handle, aName);
|
|
661 |
break;
|
|
662 |
case EFsFileCreate:
|
|
663 |
case EFsFileReplace:
|
|
664 |
err = FileCreateReplaceVar(aRequest->Request(), mode, aName);
|
|
665 |
break;
|
|
666 |
case EFsFileTemp:
|
|
667 |
err = FileTempVar(aRequest->Request(), mode, aName, path);
|
|
668 |
break;
|
|
669 |
case EFsFileRead:
|
|
670 |
case EFsFileWrite:
|
|
671 |
err = FileAccessVars(aRequest->Request(), len, pos, aName, ptr);
|
|
672 |
break;
|
|
673 |
case EFsFileLock:
|
|
674 |
case EFsFileUnLock:
|
|
675 |
err = FileLockVars(aRequest->Request(), len, pos, aName);
|
|
676 |
break;
|
|
677 |
case EFsFileSeek:
|
|
678 |
err = FileSeekVars(aRequest->Request(), pos, aName, ptr);
|
|
679 |
break;
|
|
680 |
case EFsFileFlush:
|
|
681 |
err = FileFlushVars(aRequest->Request(), aName);
|
|
682 |
break;
|
|
683 |
case EFsFileSize:
|
|
684 |
case EFsFileSetSize:
|
|
685 |
err = FileSizeVars(aRequest->Request(),size, aName);
|
|
686 |
break;
|
|
687 |
case EFsFileAtt:
|
|
688 |
err = FileAttVars(aRequest->Request(),att, aName);
|
|
689 |
break;
|
|
690 |
case EFsFileSetAtt:
|
|
691 |
err = FileSetAttVars(aRequest->Request(),att, aName, attMask, attMask);
|
|
692 |
break;
|
|
693 |
case EFsFileModified:
|
|
694 |
case EFsFileSetModified:
|
|
695 |
err = FileModificationVars(aRequest->Request(),att, size, aName, modified, modified);
|
|
696 |
break;
|
|
697 |
case EFsFileSet:
|
|
698 |
err = FileSetVars(aRequest->Request(), aName, att,att, att, modified, modified);
|
|
699 |
break;
|
|
700 |
case EFsFileChangeMode:
|
|
701 |
err = FileChangeModeVars(aRequest->Request(), aName, fmode,fmode, modified);
|
|
702 |
break;
|
|
703 |
case EFsFileRename:
|
|
704 |
err = FileRenameVars(aRequest->Request(), aName, drive, (TDes&)newName);
|
|
705 |
break;
|
|
706 |
case EFsFileDrive:
|
|
707 |
case EFsFileName:
|
|
708 |
err = FileDriveNameVars(aRequest->Request(), aName, drive, info);
|
|
709 |
break;
|
|
710 |
case EFsDelete:
|
|
711 |
err = FileDelVars(aRequest->Request(), aName);
|
|
712 |
break;
|
|
713 |
case EFsRename:
|
|
714 |
case EFsReplace:
|
|
715 |
err = FileRenameReplaceVars(aRequest->Request(), aName, (TDes&)newName);
|
|
716 |
break;
|
|
717 |
case EFsDirOpen:
|
|
718 |
err = DirOpenVars(aRequest->Request(), aName, att,uidType);
|
|
719 |
break;
|
|
720 |
case EFsFileSubClose:
|
|
721 |
err = FileCloseVars(aRequest->Request(), aName);
|
|
722 |
break;
|
|
723 |
case EFsEntry:
|
|
724 |
err = FileEntryVars(aRequest->Request(), aName);
|
|
725 |
break;
|
|
726 |
case EFsReadFileSection:
|
|
727 |
err = FileSectionVars(aRequest->Request(), len, pos, (TDes&)aName);
|
|
728 |
break;
|
|
729 |
default:
|
|
730 |
err = KErrNotSupported;
|
|
731 |
}
|
|
732 |
|
|
733 |
return(err);
|
|
734 |
}
|
|
735 |
|
|
736 |
/**
|
|
737 |
@internalTechnology
|
|
738 |
|
|
739 |
Utility function for obtaining the proposed new name of the file/dir from the client rename/replace request
|
|
740 |
Supported requests are:
|
|
741 |
|
|
742 |
EFsFileRename
|
|
743 |
EFsRename
|
|
744 |
EFsReplace
|
|
745 |
|
|
746 |
@param aRequest The client request
|
|
747 |
@param aName New name of the file/folder
|
|
748 |
@return KErrNone on successful completion, KErrNotSupported if the request is not supported
|
|
749 |
*/
|
|
750 |
EXPORT_C TInt GetNewName(TFsPluginRequest* aRequest, TDes& aNewName)
|
|
751 |
{
|
|
752 |
TFileName name;
|
|
753 |
TDriveUnit drive;
|
|
754 |
TInt err = KErrNone;
|
|
755 |
|
|
756 |
switch(aRequest->Function())
|
|
757 |
{
|
|
758 |
case EFsFileRename:
|
|
759 |
err = FileRenameVars(aRequest->Request(), (TDes&)name, drive, aNewName);
|
|
760 |
break;
|
|
761 |
case EFsRename:
|
|
762 |
case EFsReplace:
|
|
763 |
err = FileRenameReplaceVars(aRequest->Request(), name, aNewName);
|
|
764 |
break;
|
|
765 |
default:
|
|
766 |
err = KErrNotSupported;
|
|
767 |
}
|
|
768 |
|
|
769 |
return(err);
|
|
770 |
}
|
|
771 |
|
|
772 |
|
|
773 |
/**
|
|
774 |
@internalTechnology
|
|
775 |
|
|
776 |
Utility function for obtaining the path from the client request
|
|
777 |
Supported requests currently are:
|
|
778 |
|
|
779 |
EFsFileTemp
|
|
780 |
EFsMkDir
|
|
781 |
EFsRmDir
|
|
782 |
|
|
783 |
@param aRequest The client request
|
|
784 |
@param aPath The path
|
|
785 |
@return KErrNone on successful completion, KErrNotSupported if the request is not supported
|
|
786 |
*/
|
|
787 |
EXPORT_C TInt GetPath(TFsPluginRequest* aRequest, TDes& aPath)
|
|
788 |
{
|
|
789 |
TFileName name;
|
|
790 |
TUint32 mode;
|
|
791 |
TInt fmode;
|
|
792 |
TInt err = KErrNone;
|
|
793 |
|
|
794 |
switch(aRequest->Function())
|
|
795 |
{
|
|
796 |
case EFsFileTemp:
|
|
797 |
err = FileTempVar(aRequest->Request(), mode, (TDes&)name, aPath);
|
|
798 |
break;
|
|
799 |
case EFsMkDir:
|
|
800 |
err = DirMakeVars(aRequest->Request(), fmode, aPath);
|
|
801 |
break;
|
|
802 |
case EFsRmDir:
|
|
803 |
err = DirRemoveVars(aRequest->Request(), aPath);
|
|
804 |
break;
|
|
805 |
default:
|
|
806 |
err = KErrNotSupported;
|
|
807 |
}
|
|
808 |
|
|
809 |
return(err);
|
|
810 |
}
|
|
811 |
|
|
812 |
/**
|
|
813 |
@internalTechnology
|
|
814 |
|
|
815 |
Utility function for obtaining the attribute of the file/folder from the client request
|
|
816 |
Supported requests currently are:
|
|
817 |
|
|
818 |
EFsFileDuplicate
|
|
819 |
EFsFileAdopt
|
|
820 |
EFsFileAtt
|
|
821 |
EFsFileSetAtt
|
|
822 |
EFsFileModified
|
|
823 |
EFsFileSetModified
|
|
824 |
EFsFileSet
|
|
825 |
EFsDirOpen
|
|
826 |
|
|
827 |
@param aRequest The client request
|
|
828 |
@param aAtt The attribute
|
|
829 |
@return KErrNone on successful completion, KErrNotSupported if the request is not supported
|
|
830 |
*/
|
|
831 |
EXPORT_C TInt GetAtt(TFsPluginRequest* aRequest, TInt& aAtt)
|
|
832 |
{
|
|
833 |
TInt size;
|
|
834 |
TFileName name;
|
|
835 |
TInt handle;
|
|
836 |
TInt driveNumber;
|
|
837 |
TUint attMask;
|
|
838 |
TTime modified;
|
|
839 |
TInt att;
|
|
840 |
TInt uidType;
|
|
841 |
TInt err = KErrNone;
|
|
842 |
|
|
843 |
switch(aRequest->Function())
|
|
844 |
{
|
|
845 |
case EFsFileDuplicate:
|
|
846 |
case EFsFileAdopt:
|
|
847 |
err = FileDuplicateAdoptVars(aRequest->Request(), driveNumber, handle, aAtt, size,(TDes&)name, modified);
|
|
848 |
break;
|
|
849 |
case EFsFileAtt:
|
|
850 |
err = FileAttVars(aRequest->Request(),aAtt, (TDes&)name);
|
|
851 |
break;
|
|
852 |
case EFsFileSetAtt:
|
|
853 |
err = FileSetAttVars(aRequest->Request(),aAtt, (TDes&)name, attMask, attMask);
|
|
854 |
break;
|
|
855 |
case EFsFileModified:
|
|
856 |
case EFsFileSetModified:
|
|
857 |
err = FileModificationVars(aRequest->Request(),aAtt, size,(TDes&)name, modified, modified);
|
|
858 |
break;
|
|
859 |
case EFsFileSet:
|
|
860 |
err = FileSetVars(aRequest->Request(), (TDes&)name, aAtt, att, att, modified, modified);
|
|
861 |
break;
|
|
862 |
case EFsDirOpen:
|
|
863 |
err = DirOpenVars(aRequest->Request(), (TDes&)name, aAtt, uidType);
|
|
864 |
break;
|
|
865 |
default:
|
|
866 |
err = KErrNotSupported;
|
|
867 |
}
|
|
868 |
|
|
869 |
return(err);
|
|
870 |
}
|
|
871 |
|
|
872 |
|
|
873 |
/**
|
|
874 |
@internalTechnology
|
|
875 |
|
|
876 |
Utility function for obtaining the last modified time of a file from the client request
|
|
877 |
Supported requests currently are:
|
|
878 |
|
|
879 |
EFsFileDuplicate
|
|
880 |
EFsFileAdopt
|
|
881 |
EFsFileModified
|
|
882 |
EFsFileSetModified
|
|
883 |
EFsFileSet
|
|
884 |
EFsFileChangeMode
|
|
885 |
|
|
886 |
@param aRequest The client request
|
|
887 |
@param aModified The last modified time
|
|
888 |
@param aCurrent If true it returns the current last modified time, otherwise it will return
|
|
889 |
the requested last modified time
|
|
890 |
@return KErrNone on successful completion, KErrNotSupported if the request is not supported
|
|
891 |
*/
|
|
892 |
EXPORT_C TInt GetModifiedTime(TFsPluginRequest* aRequest, TTime*& aModified, TBool aCurrent)
|
|
893 |
{
|
|
894 |
TFileName name;
|
|
895 |
TInt handle;
|
|
896 |
TInt att;
|
|
897 |
TInt size;
|
|
898 |
TInt driveNumber;
|
|
899 |
TTime modified;
|
|
900 |
TInt fmode;
|
|
901 |
|
|
902 |
TTime& _aModified = aModified ? *aModified : modified;
|
|
903 |
|
|
904 |
TInt err = KErrNone;
|
|
905 |
|
|
906 |
switch(aRequest->Function())
|
|
907 |
{
|
|
908 |
case EFsFileDuplicate:
|
|
909 |
case EFsFileAdopt:
|
|
910 |
err = FileDuplicateAdoptVars(aRequest->Request(), driveNumber, handle, att, size, (TDes&)name, _aModified);
|
|
911 |
break;
|
|
912 |
case EFsFileModified:
|
|
913 |
err = FileModificationVars(aRequest->Request(), att, size, (TDes&)name, _aModified, modified);
|
|
914 |
break;
|
|
915 |
case EFsFileSetModified:
|
|
916 |
if(aCurrent)
|
|
917 |
err = FileModificationVars(aRequest->Request(), att, size, (TDes&)name, _aModified, modified);
|
|
918 |
else
|
|
919 |
err = FileModificationVars(aRequest->Request(), att, size, (TDes&)name, modified, _aModified);
|
|
920 |
break;
|
|
921 |
case EFsFileSet:
|
|
922 |
if(aCurrent)
|
|
923 |
err = FileSetVars(aRequest->Request(), (TDes&)name, att, att, att, _aModified, modified);
|
|
924 |
else
|
|
925 |
err = FileSetVars(aRequest->Request(), (TDes&)name, att, att, att, modified, _aModified);
|
|
926 |
break;
|
|
927 |
case EFsFileChangeMode:
|
|
928 |
err = FileChangeModeVars(aRequest->Request(), (TDes&)name, fmode, fmode, _aModified);
|
|
929 |
break;
|
|
930 |
default:
|
|
931 |
err = KErrNotSupported;
|
|
932 |
}
|
|
933 |
|
|
934 |
return(err);
|
|
935 |
}
|
|
936 |
|
|
937 |
/**
|
|
938 |
@internalTechnology
|
|
939 |
|
|
940 |
Utility function for obtaining the file access information from the client request
|
|
941 |
Supported requests currently are:
|
|
942 |
|
|
943 |
EFsFileRead
|
|
944 |
EFsFileWrite
|
|
945 |
EFsFileLock
|
|
946 |
EFsFileUnLock
|
|
947 |
EFsFileSeek
|
|
948 |
EFsReadFileSection
|
|
949 |
|
|
950 |
@param aRequest The client request
|
|
951 |
@param aLength Length of access
|
|
952 |
@param aPos Position of access
|
|
953 |
@return KErrNone on successful completion, KErrNotSupported if the request is not supported
|
|
954 |
*/
|
|
955 |
EXPORT_C TInt GetFileAccessInfo(TFsPluginRequest* aRequest, TInt& aLength, TInt& aPos)
|
|
956 |
{
|
|
957 |
TFileName name;
|
|
958 |
const TAny* ptr;
|
|
959 |
TInt err = KErrNone;
|
|
960 |
|
|
961 |
switch(aRequest->Function())
|
|
962 |
{
|
|
963 |
|
|
964 |
case EFsFileRead:
|
|
965 |
case EFsFileWrite:
|
|
966 |
err = FileAccessVars(aRequest->Request(), aLength, aPos, (TDes&)name, ptr);
|
|
967 |
break;
|
|
968 |
case EFsFileLock:
|
|
969 |
case EFsFileUnLock:
|
|
970 |
err = FileLockVars(aRequest->Request(), aLength, aPos, (TDes&)name);
|
|
971 |
break;
|
|
972 |
case EFsFileSeek:
|
|
973 |
err = FileSeekVars(aRequest->Request(), aPos, (TDes&)name, ptr);
|
|
974 |
aLength=0;
|
|
975 |
break;
|
|
976 |
case EFsReadFileSection:
|
|
977 |
err = FileSectionVars(aRequest->Request(), aLength, aPos, (TDes&)name);
|
|
978 |
break;
|
|
979 |
default:
|
|
980 |
err = KErrNotSupported;
|
|
981 |
}
|
|
982 |
|
|
983 |
return(err);
|
|
984 |
}
|