|
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\sfsrv\cl_file.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include "cl_std.h" |
|
19 |
|
20 static _LIT_SECURITY_POLICY_S1(KFileServerPolicy,KFileServerUidValue,ECapabilityTCB); |
|
21 |
|
22 EFSRV_EXPORT_C TInt RFile::Adopt(RFs& aFs, TInt aHandle) |
|
23 /** |
|
24 Adopts an already open file. |
|
25 |
|
26 @param aFs The file server session. |
|
27 @param aHandle The handle number of the already opened file |
|
28 |
|
29 @return KErrNone if successful, |
|
30 KErrBadHandle if the sub-session handle is invalid, |
|
31 otherwise one of the other system-wide error codes. |
|
32 |
|
33 @deprecated |
|
34 */ |
|
35 { |
|
36 |
|
37 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileAdopt, MODULEUID, aFs.Handle(), aHandle); |
|
38 |
|
39 // duplicate the sub-session handle; don't panic if it's invalid. |
|
40 RFile file; |
|
41 TInt r = file.CreateSubSession(aFs, EFsFileDuplicate, TIpcArgs(aHandle, EFalse)); |
|
42 if (r == KErrArgument) |
|
43 { |
|
44 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptReturn, MODULEUID, KErrBadHandle); |
|
45 return KErrBadHandle; |
|
46 } |
|
47 else if (r != KErrNone) |
|
48 { |
|
49 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptReturn, MODULEUID, r); |
|
50 return r; |
|
51 } |
|
52 // adopt the duplicated handle |
|
53 r = CreateAutoCloseSubSession(aFs, EFsFileAdopt, TIpcArgs(file.SubSessionHandle(), KFileAdopt32)); |
|
54 |
|
55 TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptReturn, MODULEUID, r, Session().Handle(), SubSessionHandle()); |
|
56 |
|
57 return r; |
|
58 } |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 EFSRV_EXPORT_C TInt RFile::AdoptFromServer(TInt aFsHandle, TInt aFileHandle) |
|
64 /** |
|
65 Allows a client to adopt an already open file from a server. |
|
66 |
|
67 Assumes that the server's RFs and RFile handles have been sent to the |
|
68 client using TransferToClient(). |
|
69 |
|
70 This RFile will own it's RFs session so that when the sub-session (RFile) |
|
71 is closed so will the RFs session. |
|
72 |
|
73 @param aFsHandle The file server session (RFs) handle |
|
74 @param aFileHandle The file (RFile) handle of the already opened file |
|
75 |
|
76 @return KErrNone if successful, otherwise one of the other system-wide |
|
77 error codes. |
|
78 */ |
|
79 { |
|
80 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromServer, MODULEUID, aFsHandle, aFileHandle); |
|
81 |
|
82 RFs fs; |
|
83 TInt r = fs.SetReturnedHandle(aFsHandle, KFileServerPolicy); |
|
84 if (r != KErrNone) |
|
85 { |
|
86 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromServerReturn, MODULEUID, r); |
|
87 return r; |
|
88 } |
|
89 r = CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(aFileHandle, KFileAdopt32)); |
|
90 |
|
91 TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromServerReturn, MODULEUID, r, Session().Handle(), SubSessionHandle()); |
|
92 |
|
93 return r; |
|
94 } |
|
95 |
|
96 |
|
97 EFSRV_EXPORT_C TInt RFile::AdoptFromClient(const RMessage2& aMsg, TInt aFsHandleIndex, TInt aFileHandleIndex) |
|
98 /** |
|
99 Allows a server to adopt an already open file from a client. |
|
100 The client's RFs and RFile handles are contained in message slots within aMsg. |
|
101 |
|
102 Assumes that the client's RFs and RFile handles have been sent to the server |
|
103 using TransferToServer(). |
|
104 |
|
105 |
|
106 This RFile will own it's RFs session so that when the sub-session (RFile) |
|
107 is closed so will the RFs session. |
|
108 |
|
109 @param aMsg The message received from the client |
|
110 @param aFsHandleIndex The index that identifies the message slot |
|
111 of a file server session (RFs) handle |
|
112 @param aFileHandleIndex The index that identifies the message slot |
|
113 of the sub-session (RFile) handle of the already opened file |
|
114 |
|
115 @return KErrNone if successful, otherwise one of the other system-wide |
|
116 error codes. |
|
117 */ |
|
118 { |
|
119 TInt fileHandle = NULL; |
|
120 |
|
121 TInt r = KErrNone; |
|
122 if (aFileHandleIndex == 0) |
|
123 fileHandle = aMsg.Int0(); |
|
124 else if (aFileHandleIndex == 1) |
|
125 fileHandle = aMsg.Int1(); |
|
126 else if (aFileHandleIndex == 2) |
|
127 fileHandle = aMsg.Int2(); |
|
128 else if (aFileHandleIndex == 3) |
|
129 fileHandle = aMsg.Int3(); |
|
130 else |
|
131 r = KErrArgument; |
|
132 |
|
133 #ifdef SYMBIAN_FTRACE_ENABLE |
|
134 TInt handle = NULL; |
|
135 if (aFsHandleIndex == 0) |
|
136 handle = aMsg.Int0(); |
|
137 else if (aFsHandleIndex == 1) |
|
138 handle = aMsg.Int1(); |
|
139 else if (aFsHandleIndex == 2) |
|
140 handle = aMsg.Int2(); |
|
141 else if (aFsHandleIndex == 3) |
|
142 handle = aMsg.Int3(); |
|
143 TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClient, MODULEUID, handle, fileHandle, aFsHandleIndex, aFileHandleIndex); |
|
144 #endif |
|
145 |
|
146 if (r != KErrNone) |
|
147 { |
|
148 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClientReturn, MODULEUID, r); |
|
149 return r; |
|
150 } |
|
151 |
|
152 // Duplicates the file server (RFs) session handle identified by an |
|
153 // existing handle contained in the message slot at index aFsHandleIndex |
|
154 RFs fs; |
|
155 r = fs.Open(aMsg, aFsHandleIndex, KFileServerPolicy); |
|
156 if (r != KErrNone) |
|
157 { |
|
158 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClientReturn, MODULEUID, r); |
|
159 return r; |
|
160 } |
|
161 |
|
162 r = CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(fileHandle, KFileAdopt32)); |
|
163 |
|
164 TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClientReturn, MODULEUID, r, Session().Handle(), SubSessionHandle()); |
|
165 |
|
166 return r; |
|
167 } |
|
168 |
|
169 |
|
170 EFSRV_EXPORT_C TInt RFile::AdoptFromCreator(TInt aFsHandleIndex, TInt aFileHandleIndex) |
|
171 /** |
|
172 Allows a server to adopt an already open file from a client process. |
|
173 The client's file-server (RFs) and file (RFile) handles are contained in |
|
174 this process's environment data slots. |
|
175 |
|
176 Assumes that the client's RFs and RFile handles have been sent to the server process |
|
177 using TransferToProcess(). |
|
178 |
|
179 This RFile will own it's RFs session so that when the sub-session (RFile) |
|
180 is closed so will the RFs session. |
|
181 |
|
182 @param aFsHandleIndex An index that identifies the slot in the process |
|
183 environment data that contains the file server session (RFs) handle |
|
184 @param aFileHandleIndex An index that identifies the slot in the process |
|
185 environment data that contains the sub-session (RFile) handle |
|
186 of the already opened file |
|
187 |
|
188 @return KErrNone if successful, otherwise one of the other system-wide |
|
189 error codes. |
|
190 */ |
|
191 { |
|
192 TInt fileHandle = NULL; |
|
193 |
|
194 TInt r = User::GetTIntParameter(aFileHandleIndex, fileHandle); |
|
195 |
|
196 TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreator, MODULEUID, fileHandle, aFsHandleIndex, aFileHandleIndex); |
|
197 |
|
198 if (r != KErrNone) |
|
199 { |
|
200 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreatorReturn, MODULEUID, r); |
|
201 return r; |
|
202 } |
|
203 |
|
204 |
|
205 // Duplicates the file server (RFs) session handle identified by an |
|
206 // existing handle contained in the environment slot at index aFsHandleIndex |
|
207 RFs fs; |
|
208 r = fs.Open(aFsHandleIndex, KFileServerPolicy); |
|
209 if (r != KErrNone) |
|
210 { |
|
211 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreatorReturn, MODULEUID, r); |
|
212 return r; |
|
213 } |
|
214 |
|
215 r = CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(fileHandle, KFileAdopt32)); |
|
216 |
|
217 TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreatorReturn, MODULEUID, r, Session().Handle(), SubSessionHandle()); |
|
218 |
|
219 return r; |
|
220 } |
|
221 |
|
222 |
|
223 |
|
224 /** |
|
225 Make a duplicate of the passed file handle in the same thread. |
|
226 |
|
227 By default, any thread in the process can use the duplicated handle to access the |
|
228 file. However, specifying EOwnerThread as the second parameter to this function, |
|
229 means that only the creating thread can use the handle. |
|
230 |
|
231 @param aFile The file handle to duplicate |
|
232 @param aType An enumeration whose enumerators define the ownership of this |
|
233 handle. If not explicitly specified, EOwnerProcess is taken |
|
234 as default. |
|
235 |
|
236 @return one of the other system-wide error codes. |
|
237 */ |
|
238 EFSRV_EXPORT_C TInt RFile::Duplicate(const RFile& aFile, TOwnerType aType) |
|
239 { |
|
240 TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileDuplicate, MODULEUID, aFile.Session().Handle(), aFile.SubSessionHandle(), aType); |
|
241 |
|
242 RFs fs; |
|
243 fs.SetHandle(aFile.Session().Handle()); |
|
244 |
|
245 // Need to make a duplicate of the session handle in the current thread, |
|
246 // otherwise closing one session will close both sub-sessions. |
|
247 TInt r = fs.Duplicate(RThread(), aType); |
|
248 if (r != KErrNone) |
|
249 { |
|
250 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileDuplicateReturn, MODULEUID, r); |
|
251 return r; |
|
252 } |
|
253 |
|
254 // duplicate the sub-session handle |
|
255 TInt dupSubSessionHandle; |
|
256 r = aFile.DuplicateHandle(dupSubSessionHandle); |
|
257 if (r != KErrNone) |
|
258 { |
|
259 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileDuplicateReturn, MODULEUID, r); |
|
260 return r; |
|
261 } |
|
262 |
|
263 // adopt the duplicated sub-session handle |
|
264 r = CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(dupSubSessionHandle, KFileDuplicate)); |
|
265 |
|
266 TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileDuplicateReturn, MODULEUID, r, Session().Handle(), SubSessionHandle()); |
|
267 |
|
268 return r; |
|
269 } |
|
270 |
|
271 |
|
272 // Makes a duplicate of this file (RFile) handle in the current thread and |
|
273 // returns it in aSubSessionHandle. |
|
274 // The duplicate file handle will effectively be in limbo (although still |
|
275 // owned by the session) until : |
|
276 // (1) the session handle is duplicated into another process - |
|
277 // this happens in one of : TransferToClient(), TransferToProcess() or |
|
278 // AdoptFromClient() and |
|
279 // (2) the sub-session handle is transferred to the other process - using AdoptXXX() |
|
280 // |
|
281 TInt RFile::DuplicateHandle(TInt& aSubSessionHandle) const |
|
282 { |
|
283 RFs fs; |
|
284 fs.SetHandle(Session().Handle()); |
|
285 RFile file; |
|
286 |
|
287 // duplicate the sub-session handle; panic if it's invalid. |
|
288 TInt r = file.CreateSubSession(fs, EFsFileDuplicate, TIpcArgs(SubSessionHandle(), ETrue)); |
|
289 |
|
290 // return the duplicated handle |
|
291 // Note that this handle needs to be adopted before it can be used |
|
292 aSubSessionHandle = file.SubSessionHandle(); |
|
293 |
|
294 return r; |
|
295 } |
|
296 |
|
297 |
|
298 /** |
|
299 Transfers an already open file to a server. |
|
300 |
|
301 Before this function can be called, the file server session which owns this file handle |
|
302 must first be marked as shareable by calling RFs::ShareProtected(). |
|
303 |
|
304 This function packages handle details for this file into 2 arguments of a TIpcArgs object. |
|
305 When these arguments are sent in an IPC message, the server which receives them may |
|
306 call AdoptFromClient() to open a new RFile object which refers to the same file as this. |
|
307 |
|
308 @param aIpcArgs The IPC message arguments. |
|
309 @param aFsHandleIndex An index that identifies an argument in aIpcArgs where the |
|
310 file server session handle will be stored. |
|
311 This argument must not be used for anything else otherwise the |
|
312 results will be unpredictable. |
|
313 @param aFileHandleIndex An index that identifies an argument in aIpcArgs where the |
|
314 file handle will be stored. |
|
315 This argument must not be used for anything else otherwise the |
|
316 results will be unpredictable. |
|
317 |
|
318 @return KErrNone if successful, otherwise one of the other system-wide |
|
319 error codes. |
|
320 |
|
321 */ |
|
322 EFSRV_EXPORT_C TInt RFile::TransferToServer(TIpcArgs& aIpcArgs, TInt aFsHandleIndex, TInt aFileHandleIndex) const |
|
323 { |
|
324 TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToServer, MODULEUID, Session().Handle(), SubSessionHandle(), aFsHandleIndex, aFileHandleIndex); |
|
325 |
|
326 if ((aFsHandleIndex < 0) || (aFsHandleIndex > (KMaxMessageArguments-2))) |
|
327 { |
|
328 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToServerReturn, MODULEUID, (TUint) KErrArgument); |
|
329 return KErrArgument; |
|
330 } |
|
331 |
|
332 TInt dupSubSessionHandle; |
|
333 TInt r = DuplicateHandle(dupSubSessionHandle); |
|
334 if (r == KErrNone) |
|
335 { |
|
336 aIpcArgs.Set(aFsHandleIndex, Session()); |
|
337 aIpcArgs.Set(aFileHandleIndex, dupSubSessionHandle); |
|
338 } |
|
339 |
|
340 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToServerReturn, MODULEUID, r); |
|
341 return r; |
|
342 } |
|
343 |
|
344 /** |
|
345 Transfers an already open file from a server to a client. |
|
346 |
|
347 Before this function can be called, the file server session which owns this file handle |
|
348 must first be marked as shareable by calling RFs::ShareProtected(). |
|
349 |
|
350 The file (RFile) handle is written to the client's address space to the package |
|
351 buffer in the message address slot in aMsg identified by aFileHandleIndex. |
|
352 |
|
353 If no error occurs, then the message is completed with the file-server (RFs) |
|
354 session handle. |
|
355 |
|
356 When the message completes, the client may call AdoptFromServer() to open |
|
357 a new RFile object which refers to the same file as this. |
|
358 |
|
359 Note that if an error occurs then the message is not completed. |
|
360 |
|
361 @param aMsg A message received from the client |
|
362 @param aFileHandleIndex Identifies the message slot that contains a package |
|
363 buffer pointing to an address in the client's address space |
|
364 to receive the file (RFile) handle |
|
365 |
|
366 @return KErrNone if successful, otherwise one of the other system-wide |
|
367 error codes. |
|
368 */ |
|
369 EFSRV_EXPORT_C TInt RFile::TransferToClient(const RMessage2& aMsg, TInt aFileHandleIndex) const |
|
370 { |
|
371 TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToClient, MODULEUID, Session().Handle(), SubSessionHandle(), aFileHandleIndex); |
|
372 |
|
373 if (TUint(aFileHandleIndex) >= TUint(KMaxMessageArguments)) |
|
374 { |
|
375 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToClientReturn, MODULEUID, (TUint) KErrArgument); |
|
376 return KErrArgument; |
|
377 } |
|
378 |
|
379 TInt dupSubSessionHandle; |
|
380 TInt r = DuplicateHandle(dupSubSessionHandle); |
|
381 if (r == KErrNone) |
|
382 r = aMsg.Write(aFileHandleIndex, TPckgC<TInt>(dupSubSessionHandle)); |
|
383 |
|
384 if (r != KErrNone) |
|
385 { |
|
386 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToClientReturn, MODULEUID, r); |
|
387 return r; |
|
388 } |
|
389 |
|
390 aMsg.Complete(Session()); |
|
391 |
|
392 TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToClientReturn, MODULEUID, r); |
|
393 |
|
394 return r; |
|
395 } |
|
396 |
|
397 |
|
398 /** |
|
399 Transfers an already open file to another process. |
|
400 |
|
401 Before this function can be called, the file server session which owns this file handle |
|
402 must first be marked as shareable by calling RFs::ShareProtected(). |
|
403 |
|
404 This function packages handle details for this file into 2 arguments in another |
|
405 process's environment data slots. |
|
406 When the other process runs, it may call AdoptFromCreator() to open a new RFile |
|
407 object which refers to the same file as this. |
|
408 |
|
409 @param aProcess A handle to another process. |
|
410 @param aFsHandleIndex An index that identifies a slot in the process's |
|
411 environment data which on exit will contain the file server |
|
412 session (RFs) handle |
|
413 This slot must not be used for anything else otherwise the |
|
414 results will be unpredictable. |
|
415 @param aFileHandleIndex An index that identifies a slot in the process's |
|
416 environment data which on exit will contain the file |
|
417 (RFile) handle. |
|
418 This slot must not be used for anything else otherwise the |
|
419 results will be unpredictable. |
|
420 @return KErrNone if successful, otherwise one of the other system-wide |
|
421 error codes. |
|
422 */ |
|
423 // NB slot 0 is reserved for the command line |
|
424 EFSRV_EXPORT_C TInt RFile::TransferToProcess(RProcess& aProcess, TInt aFsHandleIndex, TInt aFileHandleIndex) const |
|
425 { |
|
426 TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToProcess, MODULEUID, Session().Handle(), SubSessionHandle(), aFsHandleIndex, aFileHandleIndex); |
|
427 |
|
428 TInt dupSubSessionHandle; |
|
429 TInt r = DuplicateHandle(dupSubSessionHandle); |
|
430 |
|
431 if (r == KErrNone) |
|
432 r = aProcess.SetParameter(aFsHandleIndex, RHandleBase(Session())); |
|
433 |
|
434 if (r == KErrNone) |
|
435 r = aProcess.SetParameter(aFileHandleIndex, dupSubSessionHandle); |
|
436 |
|
437 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToProcessReturn, MODULEUID, r); |
|
438 |
|
439 return r; |
|
440 } |
|
441 |
|
442 |
|
443 EFSRV_EXPORT_C TInt RFile::Name(TDes& aName) const |
|
444 /** |
|
445 Gets the final part of a filename |
|
446 |
|
447 This is used to retrieve the name and extension of a file that has been |
|
448 passed from one process to another using the RFile::AdoptXXX() methods. |
|
449 |
|
450 @param aName On return, contains the name of the file, including the name and |
|
451 extension but excluding the drive letter and path. |
|
452 |
|
453 @return KErrNone if successful, otherwise one of the other |
|
454 system-wide error codes. |
|
455 |
|
456 */ |
|
457 { |
|
458 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileName, MODULEUID, Session().Handle(), SubSessionHandle()); |
|
459 |
|
460 TInt r = SendReceive(EFsFileName, TIpcArgs(&aName)); |
|
461 |
|
462 TRACERETMULT2(UTF::EBorder, UTraceModuleEfsrv::EFileNameReturn, MODULEUID, r, aName); |
|
463 |
|
464 return r; |
|
465 } |
|
466 |
|
467 |
|
468 EFSRV_EXPORT_C TInt RFile::FullName(TDes& aName) const |
|
469 /** |
|
470 Gets the full filename |
|
471 |
|
472 This is used to retrieve the full filename, including drive and path, |
|
473 of a file that has been passed from one process to another using the |
|
474 RFile::AdoptXXX() methods. |
|
475 |
|
476 @param aName On return, contains the full name of the file, including drive and path. |
|
477 |
|
478 @return KErrNone if successful, otherwise one of the other |
|
479 system-wide error codes. |
|
480 |
|
481 */ |
|
482 { |
|
483 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileFullName, MODULEUID, Session().Handle(), SubSessionHandle()); |
|
484 |
|
485 TInt r = SendReceive(EFsFileFullName, TIpcArgs(&aName)); |
|
486 |
|
487 TRACERETMULT2(UTF::EBorder, UTraceModuleEfsrv::EFileFullNameReturn, MODULEUID, r, aName); |
|
488 |
|
489 return r; |
|
490 } |
|
491 |
|
492 |
|
493 |
|
494 EFSRV_EXPORT_C TInt RFile::Open(RFs& aFs,const TDesC& aName,TUint aMode) |
|
495 /** |
|
496 Opens an existing file for reading or writing. |
|
497 |
|
498 If the file does not already exist, an error is returned. |
|
499 |
|
500 Notes: |
|
501 |
|
502 1. To close the file, use Close() |
|
503 |
|
504 2. Attempting to open a file with the read-only attribute using the EFileWrite |
|
505 access mode results in an error. |
|
506 |
|
507 3. Attempting to open a file which is greater than or equal to 2GByte (2,147,483,648 bytes) |
|
508 will fail with KErrTooBig |
|
509 |
|
510 4. After a file has been opened, the current write position is set to the start |
|
511 of the file. |
|
512 If necessary, use RFile::Seek() to move to a different position within |
|
513 the file. |
|
514 |
|
515 @param aFs The file server session. |
|
516 @param aName The name of the file. Any path components (i.e. drive letter |
|
517 or directory), which are not specified, are taken from |
|
518 the session path.The file name shall not contain wild cards |
|
519 ('?' or '*' characters) and illegal characters like |
|
520 '<', '>', ':', '"', '/', '|' and '\000'. Backslash '\\' character |
|
521 is allowed only as a path delimiter. The filename containing only |
|
522 white space characters (See TChar::IsSpace()) is also illegal. |
|
523 |
|
524 @param aMode The mode in which the file is opened. See TFileMode. |
|
525 |
|
526 @return KErrNone if successful, otherwise one of the other system-wide |
|
527 error codes. |
|
528 |
|
529 @see TFileMode |
|
530 |
|
531 @capability Dependent If the path for aName is /Sys and aMode is neither |
|
532 EFileShareReadersOnly nor EFileRead then Tcb capability is required. |
|
533 @capability Dependent If the path for aName is /Sys and aMode is either |
|
534 EFileShareReadersOnly or EFileRead then Allfiles capability is required. |
|
535 @capability Dependent If the path for aName begins with /Private and does not match this process' |
|
536 SID then AllFiles capability is required. |
|
537 @capability Dependent If the path for aName begins with /Resource and aMode is neither |
|
538 EFileShareReadersOrWriters|EFileRead nor EFileShareReadersOnly |
|
539 nor EFileRead then Tcb capability is required. |
|
540 |
|
541 */ |
|
542 { |
|
543 TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileOpen, MODULEUID, aFs.Handle(), aMode, aName); |
|
544 |
|
545 aMode &= ~EFileBigFile; |
|
546 TInt r = CreateSubSession(aFs,EFsFileOpen,TIpcArgs(&aName,aMode)); |
|
547 |
|
548 TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileOpenReturn, MODULEUID, r, SubSessionHandle()); |
|
549 |
|
550 return r; |
|
551 } |
|
552 |
|
553 |
|
554 EFSRV_EXPORT_C void RFile::Close() |
|
555 /** |
|
556 Closes the file. |
|
557 |
|
558 Any open files are closed when the file server session is closed. |
|
559 |
|
560 Close() is guaranteed to return, and provides no indication whether |
|
561 it completed successfully or not. When closing a file you have written to, |
|
562 you should ensure that data is committed to the file by invoking RFile::Flush() |
|
563 before closing. If Flush() completes successfully, Close() is essentially a |
|
564 no-operation. |
|
565 */ |
|
566 { |
|
567 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileClose, MODULEUID, Session().Handle(), SubSessionHandle()); |
|
568 |
|
569 #if defined (SYMBIAN_FTRACE_ENABLE) && defined(__DLL__) |
|
570 // Need to close the handle to the trace LDD if this is an auto-close subsession |
|
571 // as these close their parent session by calling RHandleBase::Close(), i.e. they |
|
572 // bypass RFs::Close() which would normally be responsible for closing the LDD |
|
573 TInt h = Session().Handle() ^ CObjectIx::ENoClose; |
|
574 if ( h != NULL && (!(h & CObjectIx::ENoClose)) ) |
|
575 { |
|
576 RFTRACE_CLOSE; |
|
577 } |
|
578 #endif |
|
579 |
|
580 CloseSubSession(EFsFileSubClose); |
|
581 |
|
582 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileCloseReturn, MODULEUID); |
|
583 } |
|
584 |
|
585 |
|
586 EFSRV_EXPORT_C TInt RFile::Create(RFs& aFs,const TDesC& aName,TUint aMode) |
|
587 /** |
|
588 Creates and opens a new file for writing. |
|
589 |
|
590 If the file already exists, an error is returned. |
|
591 |
|
592 If the resulting path does not exist, then the operation cannot proceed and |
|
593 the function returns an error code. |
|
594 |
|
595 Notes: |
|
596 |
|
597 1. To close the file, use Close() |
|
598 |
|
599 2. It automatically sets the file's archive attribute. |
|
600 |
|
601 @param aFs The file server session. |
|
602 @param aName The name of the file. Any path components (i.e. drive letter |
|
603 or directory), which are not specified, are taken from |
|
604 the session path. The file name shall not contain wild cards |
|
605 ('?' or '*' characters) and illegal characters like |
|
606 '<', '>', ':', '"', '/', '|' and '\000'. Backslash '\\' character |
|
607 is allowed only as a path delimiter. The filename containing only |
|
608 white space characters (See TChar::IsSpace()) is also illegal. |
|
609 |
|
610 @param aMode The mode in which the file is opened. The access mode is |
|
611 automatically set to EFileWrite. See TFileMode. |
|
612 |
|
613 @return KErrNone if successful, otherwise one of the other system-wide |
|
614 error codes. |
|
615 |
|
616 @see TFileMode |
|
617 |
|
618 @capability Dependent If the path in aName starts with /Sys then capability Tcb is required |
|
619 @capability Dependent If the path in aName starts with /Resource then capability Tcb is required |
|
620 @capability Dependent If the path in aName starts with /Private and does not match this process' |
|
621 SID then AllFiles capability is required. |
|
622 |
|
623 */ |
|
624 { |
|
625 aMode &= ~EFileBigFile; |
|
626 |
|
627 TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileCreate, MODULEUID, aFs.Handle(), aMode, aName); |
|
628 |
|
629 TInt r = CreateSubSession(aFs,EFsFileCreate,TIpcArgs(&aName,aMode)); |
|
630 |
|
631 TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileCreateReturn, MODULEUID, r, SubSessionHandle()); |
|
632 |
|
633 return r; |
|
634 } |
|
635 |
|
636 |
|
637 |
|
638 |
|
639 EFSRV_EXPORT_C TInt RFile::Replace(RFs& aFs,const TDesC& aName,TUint aMode) |
|
640 /** |
|
641 Opens a file for writing, replacing the content of any existing file of the |
|
642 same name if it exists, or creating a new file if it does not exist. |
|
643 |
|
644 If the resulting path exists, then: |
|
645 |
|
646 - the length of an existing file with the same filename is re-set to zero |
|
647 |
|
648 - a new file is created, if no existing file with the same filename can be found. |
|
649 |
|
650 If the resulting path does not exist, then the operation cannot proceed and |
|
651 the function returns an error code. |
|
652 |
|
653 Notes: |
|
654 |
|
655 - To close the file, use Close(), defined in the base class RFsBase. |
|
656 |
|
657 - It automatically sets the file's archive attribute. |
|
658 |
|
659 @param aFs The file server session. |
|
660 @param aName The name of the file. Any path components (i.e. drive letter |
|
661 or directory), which are not specified, are taken from |
|
662 the session path. The file name shall not contain wild cards |
|
663 ('?' or '*' characters) and illegal characters like |
|
664 '<', '>', ':', '"', '/', '|' and '\000'. Backslash '\\' character |
|
665 is allowed only as a path delimiter. The filename containing only |
|
666 white space characters (See TChar::IsSpace()) is also illegal. |
|
667 |
|
668 @param aMode The mode in which the file is opened. The access mode is |
|
669 automatically set to EFileWrite. See TFileMode. |
|
670 |
|
671 @return KErrNone if successful, otherwise one of the other system-wide |
|
672 error codes. |
|
673 |
|
674 @see TFileMode |
|
675 |
|
676 @capability Dependent If the path in aName starts with /Sys then capability Tcb is required |
|
677 @capability Dependent If the path in aName starts with /Resource then capability Tcb is required |
|
678 @capability Dependent If the path in aName starts with /Private and does not match this process' |
|
679 SID then AllFiles capability is required. |
|
680 |
|
681 */ |
|
682 { |
|
683 TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileReplace, MODULEUID, aFs.Handle(), aMode, aName); |
|
684 aMode &= ~EFileBigFile; |
|
685 TInt r = CreateSubSession(aFs,EFsFileReplace,TIpcArgs(&aName,aMode)); |
|
686 TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileReplaceReturn, MODULEUID, r, SubSessionHandle()); |
|
687 return r; |
|
688 } |
|
689 |
|
690 |
|
691 |
|
692 |
|
693 EFSRV_EXPORT_C TInt RFile::Temp(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aMode) |
|
694 /** |
|
695 Creates and opens a temporary file with a unique name for writing and reading. |
|
696 |
|
697 Notes: |
|
698 |
|
699 1. To close the file, use Close() |
|
700 |
|
701 @param aFs The file server session. |
|
702 @param aPath The directory in which the file is created. |
|
703 @param aName On return, contains the full path and file name of the file. |
|
704 The filename is guaranteed to be unique within the directory |
|
705 specified by aPath. |
|
706 @param aMode The mode in which the file is opened. The access mode is |
|
707 automatically set to EFileWrite. See TFileMode. |
|
708 |
|
709 @return KErrNone if successful, otherwise one of the other system-wide |
|
710 error codes. |
|
711 |
|
712 @see TFileMode |
|
713 |
|
714 @capability Dependent If aPath starts with /Sys then capability Tcb is required |
|
715 @capability Dependent If aPath starts with /Resource then capability Tcb is required |
|
716 @capability Dependent If aPath starts with /Private and does not match this process' |
|
717 SID then AllFiles capability is required. |
|
718 */ |
|
719 { |
|
720 TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileTemp, MODULEUID, aFs.Handle(), aPath, aMode); |
|
721 aMode &= ~EFileBigFile; |
|
722 TInt r = CreateSubSession(aFs,EFsFileTemp,TIpcArgs(&aPath,aMode,&aName)); |
|
723 TRACERETMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileTempReturn, MODULEUID, r, SubSessionHandle(), aName); |
|
724 return r; |
|
725 } |
|
726 |
|
727 |
|
728 |
|
729 |
|
730 EFSRV_EXPORT_C TInt RFile::Read(TDes8& aDes) const |
|
731 /** |
|
732 Reads from the file at the current position. |
|
733 |
|
734 This is a synchronous function. |
|
735 |
|
736 Note that when an attempt is made to read beyond the end of the file, |
|
737 no error is returned. |
|
738 The descriptor's length is set to the number of bytes read into |
|
739 it. Therefore, when reading through a file,the end of file has been reached |
|
740 when the descriptor length, as returned by TDesC8::Length(), is zero. |
|
741 |
|
742 @param aDes Descriptor into which binary data is read. Any existing contents |
|
743 are overwritten. On return, its length is set to the number of |
|
744 bytes read. |
|
745 @return KErrNone if successful, otherwise one of the other system-wide error |
|
746 codes. |
|
747 |
|
748 @see TDesC8::Length |
|
749 */ |
|
750 { |
|
751 TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileRead1, MODULEUID, Session().Handle(), SubSessionHandle(), aDes.MaxLength()); |
|
752 |
|
753 TInt r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),I64LOW(KCurrentPosition64))); |
|
754 |
|
755 TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead1Return, MODULEUID, r, aDes.Length()); |
|
756 |
|
757 return r; |
|
758 } |
|
759 |
|
760 |
|
761 |
|
762 |
|
763 EFSRV_EXPORT_C void RFile::Read(TDes8& aDes,TRequestStatus& aStatus) const |
|
764 /** |
|
765 Reads from the file at the current position. |
|
766 |
|
767 This is an asynchronous function. |
|
768 |
|
769 Note that when an attempt is made to read beyond the end of the file, |
|
770 no error is returned. |
|
771 The descriptor's length is set to the number of bytes read into |
|
772 it. Therefore, when reading through a file,the end of file has been reached |
|
773 when the descriptor length, as returned by TDesC8::Length(), is zero. |
|
774 |
|
775 @param aDes Descriptor into which binary data is read. Any existing contents |
|
776 are overwritten. On return, its length is set to the number of |
|
777 bytes read. |
|
778 NB: this function is asynchronous and the request that it |
|
779 represents may not complete until some time after the call |
|
780 to the function has returned. It is important, therefore, that |
|
781 this descriptor remain valid, or remain in scope, until you have |
|
782 been notified that the request is complete. |
|
783 |
|
784 @param aStatus Request status. On completion contains: |
|
785 KErrNone, if successful, otherwise one of the other system-wide error codes. |
|
786 |
|
787 @see TDesC8::Length |
|
788 */ |
|
789 { |
|
790 TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileRead2, MODULEUID, Session().Handle(), SubSessionHandle(), aDes.MaxLength(), &aStatus); |
|
791 |
|
792 RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),I64LOW(KCurrentPosition64)),aStatus); |
|
793 |
|
794 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead2Return, MODULEUID); |
|
795 } |
|
796 |
|
797 |
|
798 |
|
799 |
|
800 EFSRV_EXPORT_C TInt RFile::Read(TDes8& aDes,TInt aLength) const |
|
801 /** |
|
802 Reads the specified number of bytes of binary data from the file at the current position. |
|
803 |
|
804 This is a synchronous function. |
|
805 |
|
806 Note that when an attempt is made to read beyond the end of the file, |
|
807 no error is returned. |
|
808 The descriptor's length is set to the number of bytes read into |
|
809 it. Therefore, when reading through a file,the end of file has been reached |
|
810 when the descriptor length, as returned by TDesC8::Length(), is zero. |
|
811 Assuming aLength is less than the maximum length of the descriptor, the only circumstances |
|
812 in which Read() can return fewer bytes than requested, is when the end of |
|
813 file is reached or if an error occurs. |
|
814 |
|
815 @param aDes Descriptor into which binary data is read. Any existing |
|
816 contents are overwritten. On return, its length is set to |
|
817 the number of bytes read. |
|
818 |
|
819 @param aLength The number of bytes to be read from the file into the descriptor. |
|
820 If an attempt is made to read more bytes than the descriptor's |
|
821 maximum length, the function returns KErrOverflow. |
|
822 This value must not be negative, otherwise the function |
|
823 returns KErrArgument. |
|
824 |
|
825 @return KErrNone if successful, otherwise one of the other system-wide error |
|
826 codes. |
|
827 */ |
|
828 { |
|
829 TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileRead1, MODULEUID, Session().Handle(), SubSessionHandle(), aLength); |
|
830 |
|
831 if (aLength==0) |
|
832 { |
|
833 aDes.Zero(); |
|
834 return(KErrNone); |
|
835 } |
|
836 else if(aLength>aDes.MaxLength()) |
|
837 { |
|
838 return(KErrOverflow); |
|
839 } |
|
840 TInt r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,I64LOW(KCurrentPosition64))); |
|
841 |
|
842 TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead1Return, MODULEUID, r, aDes.Length()); |
|
843 |
|
844 return r; |
|
845 } |
|
846 |
|
847 |
|
848 |
|
849 |
|
850 EFSRV_EXPORT_C void RFile::Read(TDes8& aDes,TInt aLength,TRequestStatus& aStatus) const |
|
851 /** |
|
852 Reads a specified number of bytes of binary data from the file at the current position. |
|
853 |
|
854 This is an asynchronous function. |
|
855 |
|
856 Note that when an attempt is made to read beyond the end of the file, |
|
857 no error is returned. |
|
858 The descriptor's length is set to the number of bytes read into it. |
|
859 Therefore, when reading through a file, the end of file has been reached |
|
860 when the descriptor length, as returned by TDesC8::Length(), is zero. |
|
861 Assuming aLength is less than the maximum length of the descriptor, the only |
|
862 circumstances in which Read() can return fewer bytes than requested is when |
|
863 the end of file is reached or if an error has occurred. |
|
864 |
|
865 @param aDes Descriptor into which binary data is read. Any existing |
|
866 contents are overwritten. On return, its length is set to the |
|
867 number of bytes read. |
|
868 NB: this function is asynchronous and the request that it |
|
869 represents may not complete until some time after the call |
|
870 to the function has returned. It is important, therefore, that |
|
871 this descriptor remain valid, or remain in scope, until you have |
|
872 been notified that the request is complete. |
|
873 |
|
874 @param aLength The number of bytes to be read from the file into the descriptor. |
|
875 If an attempt is made to read more bytes than the descriptor's |
|
876 maximum length, then the function updates aStatus parameter with KErrOverflow. |
|
877 It must not be negative otherwise the function updates aStatus with KErrArgument. |
|
878 |
|
879 @param aStatus Request status. On completion contains KErrNone if successful, |
|
880 otherwise one of the other system-wide error codes. |
|
881 */ |
|
882 { |
|
883 TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileRead2, MODULEUID, Session().Handle(), SubSessionHandle(), aLength, &aStatus); |
|
884 |
|
885 if (aLength==0) |
|
886 { |
|
887 aDes.Zero(); |
|
888 TRequestStatus* req=(&aStatus); |
|
889 User::RequestComplete(req,KErrNone); |
|
890 return; |
|
891 } |
|
892 else if(aLength>aDes.MaxLength()) |
|
893 { |
|
894 TRequestStatus* req=(&aStatus); |
|
895 User::RequestComplete(req,KErrOverflow); |
|
896 return; |
|
897 } |
|
898 |
|
899 RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,I64LOW(KCurrentPosition64)),aStatus); |
|
900 |
|
901 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead2Return, MODULEUID); |
|
902 } |
|
903 |
|
904 |
|
905 |
|
906 |
|
907 EFSRV_EXPORT_C TInt RFile::Read(TInt aPos,TDes8& aDes) const |
|
908 /** |
|
909 Reads from the file at the specified offset within the file |
|
910 |
|
911 This is a synchronous function. |
|
912 |
|
913 Note that when an attempt is made to read beyond the end of the file, |
|
914 no error is returned. |
|
915 The descriptor's length is set to the number of bytes read into it. |
|
916 Therefore, when reading through a file, the end of file has been reached |
|
917 when the descriptor length, as returned by TDesC8::Length(), is zero. |
|
918 |
|
919 @param aPos Position of first byte to be read. This is an offset from |
|
920 the start of the file. If no position is specified, reading |
|
921 begins at the current file position. |
|
922 If aPos is beyond the end of the file, the function returns |
|
923 a zero length descriptor. |
|
924 |
|
925 @param aDes The descriptor into which binary data is read. Any existing content |
|
926 is overwritten. On return, its length is set to the number of |
|
927 bytes read. |
|
928 |
|
929 @return KErrNone if successful, otherwise one of the other system-wide error |
|
930 codes. |
|
931 |
|
932 @panic FSCLIENT 19 if aPos is negative. |
|
933 */ |
|
934 { |
|
935 TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileRead3, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.MaxLength()); |
|
936 |
|
937 __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); |
|
938 |
|
939 TInt r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),aPos)); |
|
940 |
|
941 TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead3Return, MODULEUID, r, aDes.Length()); |
|
942 |
|
943 return r; |
|
944 } |
|
945 |
|
946 |
|
947 |
|
948 |
|
949 EFSRV_EXPORT_C void RFile::Read(TInt aPos,TDes8& aDes,TRequestStatus& aStatus) const |
|
950 /** |
|
951 Reads from the file at the specified offset within the file. |
|
952 |
|
953 This is an asynchronous function. |
|
954 |
|
955 Note that when an attempt is made to read beyond the end of the file, |
|
956 no error is returned. |
|
957 The descriptor's length is set to the number of bytes read into it. |
|
958 Therefore, when reading through a file, the end of file has been reached |
|
959 when the descriptor length, as returned by TDesC8::Length(), is zero. |
|
960 |
|
961 @param aPos Position of first byte to be read. This is an offset from |
|
962 the start of the file. If no position is specified, |
|
963 reading begins at the current file position. |
|
964 If aPos is beyond the end of the file, the function returns |
|
965 a zero length descriptor. |
|
966 |
|
967 @param aDes The descriptor into which binary data is read. Any existing |
|
968 content is overwritten. On return, its length is set to |
|
969 the number of bytes read. |
|
970 NB: this function is asynchronous and the request that it |
|
971 represents may not complete until some time after the call |
|
972 to the function has returned. It is important, therefore, that |
|
973 this descriptor remain valid, or remain in scope, until you have |
|
974 been notified that the request is complete. |
|
975 |
|
976 @param aStatus The request status. On completion, contains an error code of KErrNone |
|
977 if successful, otherwise one of the other system-wide error codes. |
|
978 |
|
979 @panic FSCLIENT 19 if aPos is negative. |
|
980 */ |
|
981 { |
|
982 TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileRead4, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.MaxLength(), &aStatus); |
|
983 |
|
984 __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); |
|
985 RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),aPos),aStatus); |
|
986 |
|
987 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead4Return, MODULEUID); |
|
988 } |
|
989 |
|
990 |
|
991 |
|
992 |
|
993 EFSRV_EXPORT_C TInt RFile::Read(TInt aPos,TDes8& aDes,TInt aLength) const |
|
994 /** |
|
995 Reads the specified number of bytes of binary data from the file at a specified |
|
996 offset within the file. |
|
997 |
|
998 This is a synchronous function. |
|
999 |
|
1000 Note that when an attempt is made to read beyond the end of the file, |
|
1001 no error is returned. |
|
1002 The descriptor's length is set to the number of bytes read into it. |
|
1003 Therefore, when reading through a file, the end of file has been reached |
|
1004 when the descriptor length, as returned by TDesC8::Length(), is zero. |
|
1005 Assuming aLength is less than the maximum length of the descriptor, the only |
|
1006 circumstances in which Read() can return fewer bytes than requested is when |
|
1007 the end of file is reached or if an error has occurred. |
|
1008 |
|
1009 @param aPos Position of first byte to be read. This is an offset from |
|
1010 the start of the file. If no position is specified, |
|
1011 reading begins at the current file position. |
|
1012 If aPos is beyond the end of the file, the function returns |
|
1013 a zero length descriptor. |
|
1014 |
|
1015 @param aDes The descriptor into which binary data is read. Any existing |
|
1016 contents are overwritten. On return, its length is set to |
|
1017 the number of bytes read. |
|
1018 @param aLength The number of bytes to read from the file into the descriptor. |
|
1019 If an attempt is made to read more bytes than the descriptor's |
|
1020 maximum length, then the function updates aStatus parameter with KErrOverflow. |
|
1021 It must not be negative otherwise the function updates aStatus with KErrArgument. |
|
1022 |
|
1023 @return KErrNone if successful, otherwise one of the other system-wide |
|
1024 error codes. |
|
1025 |
|
1026 @panic FSCLIENT 19 if aPos is negative. |
|
1027 */ |
|
1028 { |
|
1029 TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileRead3, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength); |
|
1030 |
|
1031 __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); |
|
1032 if (aLength==0) |
|
1033 { |
|
1034 aDes.Zero(); |
|
1035 return(KErrNone); |
|
1036 } |
|
1037 else if(aLength>aDes.MaxLength()) |
|
1038 { |
|
1039 return(KErrOverflow); |
|
1040 } |
|
1041 |
|
1042 TInt r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,aPos)); |
|
1043 |
|
1044 TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead3Return, MODULEUID, r, aDes.Length()); |
|
1045 |
|
1046 return r; |
|
1047 } |
|
1048 |
|
1049 |
|
1050 |
|
1051 |
|
1052 EFSRV_EXPORT_C void RFile::Read(TInt aPos,TDes8& aDes,TInt aLength,TRequestStatus& aStatus) const |
|
1053 /** |
|
1054 Reads the specified number of bytes of binary data from the file at a specified |
|
1055 offset within the file. |
|
1056 |
|
1057 This is an asynchronous function. |
|
1058 |
|
1059 Note that when an attempt is made to read beyond the end of the file, |
|
1060 no error is returned. |
|
1061 The descriptor's length is set to the number of bytes read into it. |
|
1062 Therefore, when reading through a file, the end of file has been reached |
|
1063 when the descriptor length, as returned by TDesC8::Length(), is zero. |
|
1064 Assuming aLength is less than the maximum length of the descriptor, the only |
|
1065 circumstances in which Read() can return fewer bytes than requested is when |
|
1066 the end of file is reached or if an error has occurred. |
|
1067 |
|
1068 @param aPos Position of first byte to be read. This is an offset from |
|
1069 the start of the file. If no position is specified, |
|
1070 reading begins at the current file position. |
|
1071 If aPos is beyond the end of the file, the function returns |
|
1072 a zero length descriptor. |
|
1073 |
|
1074 @param aDes The descriptor into which binary data is read. Any existing |
|
1075 contents are overwritten. On return, its length is set to |
|
1076 the number of bytes read. |
|
1077 NB: this function is asynchronous and the request that it |
|
1078 represents may not complete until some time after the call |
|
1079 to the function has returned. It is important, therefore, that |
|
1080 this descriptor remain valid, or remain in scope, until you have |
|
1081 been notified that the request is complete. |
|
1082 |
|
1083 @param aLength The number of bytes to read from the file into the descriptor. |
|
1084 If an attempt is made to read more bytes than the descriptor's |
|
1085 maximum length, then the function returns KErrOverflow. |
|
1086 It must not be negative otherwise the function returns KErrArgument. |
|
1087 |
|
1088 @param aStatus Request status. On completion contains KErrNone if successful, |
|
1089 otherwise one of the other system-wide error codes. |
|
1090 |
|
1091 @panic FSCLIENT 19 if aPos is negative. |
|
1092 */ |
|
1093 { |
|
1094 TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileRead4, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength, &aStatus); |
|
1095 |
|
1096 __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); |
|
1097 if (aLength==0) |
|
1098 { |
|
1099 aDes.Zero(); |
|
1100 TRequestStatus* req=(&aStatus); |
|
1101 User::RequestComplete(req,KErrNone); |
|
1102 return; |
|
1103 } |
|
1104 else if(aLength>aDes.MaxLength()) |
|
1105 { |
|
1106 TRequestStatus* req=(&aStatus); |
|
1107 User::RequestComplete(req,KErrOverflow); |
|
1108 return; |
|
1109 } |
|
1110 |
|
1111 RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,aPos),aStatus); |
|
1112 |
|
1113 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead4Return, MODULEUID); |
|
1114 } |
|
1115 |
|
1116 |
|
1117 |
|
1118 |
|
1119 EFSRV_EXPORT_C void RFile::ReadCancel(TRequestStatus& aStatus) const |
|
1120 /** |
|
1121 Cancels a specific outstanding asynchronous read request. |
|
1122 |
|
1123 The outstanding request completes with KErrCancel. |
|
1124 |
|
1125 @param aStat The request status object identified with the original |
|
1126 asynchronous read. |
|
1127 */ |
|
1128 { |
|
1129 if(aStatus != KRequestPending) |
|
1130 return; |
|
1131 SendReceive(EFsFileReadCancel, TIpcArgs(&aStatus)); |
|
1132 } |
|
1133 |
|
1134 |
|
1135 |
|
1136 |
|
1137 EFSRV_EXPORT_C void RFile::ReadCancel() const |
|
1138 /** |
|
1139 Cancels all outstanding asynchronous read requests for this subsession. |
|
1140 |
|
1141 All outstanding requests complete with KErrCancel. |
|
1142 */ |
|
1143 { |
|
1144 SendReceive(EFsFileReadCancel, TIpcArgs(NULL)); |
|
1145 } |
|
1146 |
|
1147 |
|
1148 |
|
1149 |
|
1150 EFSRV_EXPORT_C TInt RFile::Write(const TDesC8& aDes) |
|
1151 /** |
|
1152 Writes to the file at the current offset within the file. |
|
1153 |
|
1154 This is a synchronous function. |
|
1155 |
|
1156 NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig |
|
1157 |
|
1158 @param aDes The descriptor from which binary data is written. |
|
1159 The function writes the entire contents of aDes to the file. |
|
1160 |
|
1161 @return KErrNone if successful, otherwise one of the other system-wide error |
|
1162 codes. |
|
1163 */ |
|
1164 { |
|
1165 TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1, MODULEUID, Session().Handle(), SubSessionHandle(), aDes.Length()); |
|
1166 TInt r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),I64LOW(KCurrentPosition64))); |
|
1167 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1Return, MODULEUID, r); |
|
1168 return r; |
|
1169 } |
|
1170 |
|
1171 |
|
1172 EFSRV_EXPORT_C void RFile::Write(const TDesC8& aDes,TRequestStatus& aStatus) |
|
1173 /** |
|
1174 Writes to the file at the current offset within the file. |
|
1175 |
|
1176 This is an asynchronous function. |
|
1177 |
|
1178 NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig |
|
1179 |
|
1180 @param aDes The descriptor from which binary data is written. |
|
1181 The function writes the entire contents of aDes to the file. |
|
1182 NB: this function is asynchronous and the request that it |
|
1183 represents may not complete until some time after the call |
|
1184 to the function has returned. It is important, therefore, that |
|
1185 this descriptor remain valid, or remain in scope, until you have |
|
1186 been notified that the request is complete. |
|
1187 |
|
1188 @param aStatus Request status. On completion contains KErrNone if successful, |
|
1189 otherwise one of the other system-wide error codes. |
|
1190 */ |
|
1191 { |
|
1192 TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2, MODULEUID, Session().Handle(), SubSessionHandle(), aDes.Length(), &aStatus); |
|
1193 |
|
1194 RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),I64LOW(KCurrentPosition64)),aStatus); |
|
1195 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2Return, MODULEUID); |
|
1196 } |
|
1197 |
|
1198 |
|
1199 |
|
1200 |
|
1201 EFSRV_EXPORT_C TInt RFile::Write(const TDesC8& aDes,TInt aLength) |
|
1202 /** |
|
1203 Writes a portion of a descriptor to the file at the current offset within |
|
1204 the file. |
|
1205 |
|
1206 This is a synchronous function. |
|
1207 |
|
1208 NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig |
|
1209 |
|
1210 @param aDes The descriptor from which binary data is written. |
|
1211 @param aLength The number of bytes to be written from the descriptor. |
|
1212 This must not be greater than the length of the descriptor. |
|
1213 It must not be negative. |
|
1214 |
|
1215 @return KErrNone if successful; KErrArgument if aLength is negative; |
|
1216 otherwise one of the other system-wide error codes. |
|
1217 |
|
1218 @panic FSCLIENT 27 in debug mode, if aLength is greater than the length |
|
1219 of the descriptor aDes. |
|
1220 */ |
|
1221 { |
|
1222 TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1, MODULEUID, Session().Handle(), SubSessionHandle(), aLength); |
|
1223 |
|
1224 __ASSERT_DEBUG(aDes.Length()>=aLength,Panic(EBadLength)); |
|
1225 TInt r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,I64LOW(KCurrentPosition64))); |
|
1226 |
|
1227 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1Return, MODULEUID, r); |
|
1228 return r; |
|
1229 } |
|
1230 |
|
1231 |
|
1232 |
|
1233 |
|
1234 EFSRV_EXPORT_C void RFile::Write(const TDesC8& aDes,TInt aLength,TRequestStatus& aStatus) |
|
1235 /** |
|
1236 Writes a portion of a descriptor to the file at the current offset |
|
1237 within the file. |
|
1238 |
|
1239 This is an asynchronous function. |
|
1240 |
|
1241 NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig |
|
1242 |
|
1243 @param aDes The descriptor from which binary data is written. |
|
1244 NB: this function is asynchronous and the request that it |
|
1245 represents may not complete until some time after the call |
|
1246 to the function has returned. It is important, therefore, that |
|
1247 this descriptor remain valid, or remain in scope, until you have |
|
1248 been notified that the request is complete. |
|
1249 |
|
1250 @param aLength The number of bytes to be written from the descriptor. |
|
1251 This must not be greater than the length of the descriptor. |
|
1252 It must not be negative. |
|
1253 |
|
1254 @param aStatus Request status. On completion contains KErrNone if successful; |
|
1255 KErrArgument if aLength is negative; |
|
1256 otherwise one of the other system-wide error codes. |
|
1257 |
|
1258 */ |
|
1259 { |
|
1260 TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2, MODULEUID, Session().Handle(), SubSessionHandle(), aLength, &aStatus); |
|
1261 |
|
1262 RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,I64LOW(KCurrentPosition64)),aStatus); |
|
1263 |
|
1264 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2Return, MODULEUID); |
|
1265 } |
|
1266 |
|
1267 |
|
1268 |
|
1269 |
|
1270 |
|
1271 EFSRV_EXPORT_C TInt RFile::Write(TInt aPos,const TDesC8& aDes) |
|
1272 /** |
|
1273 Writes to the file at the specified offset within the file |
|
1274 |
|
1275 This is a synchronous function. |
|
1276 |
|
1277 NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig |
|
1278 |
|
1279 @param aPos The offset from the start of the file at which the first |
|
1280 byte is written. |
|
1281 If a position beyond the end of the file is specified, then |
|
1282 the write operation begins at the end of the file. |
|
1283 If the position has been locked, then the write fails. |
|
1284 |
|
1285 @param aDes The descriptor from which binary data is written. The function writes |
|
1286 the entire contents of aDes to the file. |
|
1287 |
|
1288 @return KErrNone if successful, otherwise one of the other system-wide error |
|
1289 codes. |
|
1290 |
|
1291 @panic FSCLIENT 19 if aPos is negative. |
|
1292 */ |
|
1293 { |
|
1294 TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileWrite3, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.Length()); |
|
1295 |
|
1296 __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); |
|
1297 TInt r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),aPos)); |
|
1298 |
|
1299 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite3Return, MODULEUID, r); |
|
1300 return r; |
|
1301 } |
|
1302 |
|
1303 |
|
1304 |
|
1305 |
|
1306 EFSRV_EXPORT_C void RFile::Write(TInt aPos,const TDesC8& aDes,TRequestStatus& aStatus) |
|
1307 /** |
|
1308 Writes to the file at the specified offset within the file |
|
1309 |
|
1310 This is an asynchronous function. |
|
1311 |
|
1312 NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig |
|
1313 |
|
1314 @param aPos The offset from the start of the file at which the first |
|
1315 byte is written. |
|
1316 If a position beyond the end of the file is specified, then |
|
1317 the write operation begins at the end of the file. |
|
1318 If the position has been locked, then the write fails. |
|
1319 |
|
1320 @param aDes The descriptor from which binary data is written. The function |
|
1321 writes the entire contents of aDes to the file. |
|
1322 NB: this function is asynchronous and the request that it |
|
1323 represents may not complete until some time after the call |
|
1324 to the function has returned. It is important, therefore, that |
|
1325 this descriptor remain valid, or remain in scope, until you have |
|
1326 been notified that the request is complete. |
|
1327 |
|
1328 @param aStatus Request status. On completion contains KErrNone if successful, |
|
1329 otherwise one of the other system-wide error codes. |
|
1330 |
|
1331 @panic FSCLIENT 19 if aPos is negative. |
|
1332 */ |
|
1333 { |
|
1334 TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileWrite4, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.Length(), &aStatus); |
|
1335 |
|
1336 __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); |
|
1337 RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),aPos),aStatus); |
|
1338 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite4Return, MODULEUID); |
|
1339 } |
|
1340 |
|
1341 |
|
1342 |
|
1343 |
|
1344 EFSRV_EXPORT_C TInt RFile::Write(TInt aPos,const TDesC8& aDes,TInt aLength) |
|
1345 /** |
|
1346 Writes the specified number of bytes to the file at the specified offset within the file. |
|
1347 |
|
1348 This is a synchronous function. |
|
1349 |
|
1350 NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig |
|
1351 |
|
1352 @param aPos The offset from the start of the file at which the first |
|
1353 byte is written. |
|
1354 If a position beyond the end of the file is specified, then |
|
1355 the write operation begins at the end of the file. |
|
1356 If the position has been locked, then the write fails. |
|
1357 |
|
1358 @param aDes The descriptor from which binary data is written. |
|
1359 @param aLength The number of bytes to be written from aDes . |
|
1360 It must not be negative. |
|
1361 |
|
1362 @return KErrNone if successful; KErrArgument if aLength is negative; |
|
1363 otherwise one of the other system-wide error codes. |
|
1364 |
|
1365 @panic FSCLIENT 19 if aPos is negative. |
|
1366 */ |
|
1367 { |
|
1368 TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1, MODULEUID, Session().Handle(), SubSessionHandle(), aLength); |
|
1369 |
|
1370 __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); |
|
1371 TInt r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,aPos)); |
|
1372 |
|
1373 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1Return, MODULEUID, r); |
|
1374 return r; |
|
1375 } |
|
1376 |
|
1377 |
|
1378 |
|
1379 |
|
1380 EFSRV_EXPORT_C void RFile::Write(TInt aPos,const TDesC8& aDes,TInt aLength,TRequestStatus& aStatus) |
|
1381 /** |
|
1382 Writes the specified number of bytes to the file at the specified offset within the file. |
|
1383 |
|
1384 This is an asynchronous function. |
|
1385 |
|
1386 NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig |
|
1387 |
|
1388 @param aPos The offset from the start of the file at which the first |
|
1389 byte is written. |
|
1390 If a position beyond the end of the file is specified, then |
|
1391 the write operation begins at the end of the file. |
|
1392 If the position has been locked, then the write fails. |
|
1393 |
|
1394 @param aDes The descriptor from which binary data is written. |
|
1395 NB: this function is asynchronous and the request that it |
|
1396 represents may not complete until some time after the call |
|
1397 to the function has returned. It is important, therefore, that |
|
1398 this descriptor remain valid, or remain in scope, until you have |
|
1399 been notified that the request is complete. |
|
1400 |
|
1401 @param aLength The number of bytes to be written from aDes. |
|
1402 It must not be negative. |
|
1403 |
|
1404 @param aStatus Request status. On completion contains KErrNone if successful; |
|
1405 KErrArgument if aLength is negative; |
|
1406 otherwise one of the other system-wide error codes. |
|
1407 |
|
1408 @panic FSCLIENT 19 if aPos is negative. |
|
1409 */ |
|
1410 { |
|
1411 TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength, &aStatus); |
|
1412 |
|
1413 __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); |
|
1414 RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,aPos),aStatus); |
|
1415 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2Return, MODULEUID); |
|
1416 } |
|
1417 |
|
1418 |
|
1419 |
|
1420 |
|
1421 EFSRV_EXPORT_C TInt RFile::Lock(TInt aPos,TInt aLength) const |
|
1422 /** |
|
1423 Locks a region within the file as defined by a range of bytes. |
|
1424 |
|
1425 This ensures that those bytes are accessible |
|
1426 only through the RFile object which claims the lock. To re-allow access by |
|
1427 other programs to the locked region, it must either be unlocked or the file |
|
1428 closed. Locking can be used to synchronize operations on a file when more |
|
1429 than one program has access to the file in EFileShareAny mode. |
|
1430 |
|
1431 More than one distinct region of a file can be locked, but an error is returned |
|
1432 if more than one lock is placed on the same region. Different RFile objects |
|
1433 can lock different parts of the same file as long as the file is opened in |
|
1434 EFileShareAny mode. The locked region may extend beyond the end of a file; |
|
1435 this prevents the file from being extended by other programs. |
|
1436 |
|
1437 @param aPos Position in file from which to lock; this is the offset from |
|
1438 the beginning of the file. |
|
1439 @param aLength Number of bytes to lock. |
|
1440 |
|
1441 @return KErrNone if successful; KErrArgument if aPos+aLength>2G-1 boundary; |
|
1442 otherwise one of the other system-wide error codes. |
|
1443 |
|
1444 @panic FSCLIENT 17 if aLength is not greater than zero, |
|
1445 @panic FSCLIENT 19 if aPos is negative. |
|
1446 |
|
1447 */ |
|
1448 { |
|
1449 TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileLock, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength); |
|
1450 |
|
1451 __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); |
|
1452 |
|
1453 TInt r = SendReceive(EFsFileLock,TIpcArgs(aPos,aLength)); |
|
1454 |
|
1455 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileLockReturn, MODULEUID, r); |
|
1456 return r; |
|
1457 } |
|
1458 |
|
1459 |
|
1460 |
|
1461 |
|
1462 EFSRV_EXPORT_C TInt RFile::UnLock(TInt aPos,TInt aLength) const |
|
1463 /** |
|
1464 Unlocks a region within the file as defined by a range of bytes. |
|
1465 |
|
1466 A lock can only be removed by the RFile object which claimed the lock. |
|
1467 |
|
1468 A portion of a locked region cannot be unlocked. The entire locked region |
|
1469 must be unlocked otherwise an error is returned. If any byte within |
|
1470 the specified range of bytes to unlock is not locked, an error is returned. |
|
1471 |
|
1472 @param aPos Position in file from which to unlock; this is the offset from |
|
1473 the beginning of the file. |
|
1474 @param aLength Number of bytes to unlock. |
|
1475 |
|
1476 @return KErrNone if successful; KErrArgument if aPos+aLength>2G-1 boundary; |
|
1477 otherwise one of the other system-wide error codes. |
|
1478 |
|
1479 @panic FSCLIENT 18 if aLength is not greater than zero, |
|
1480 @panic FSCLIENT 19 if aPos is negative. |
|
1481 */ |
|
1482 { |
|
1483 TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileUnLock, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength); |
|
1484 |
|
1485 __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); |
|
1486 TInt r = SendReceive(EFsFileUnLock,TIpcArgs(aPos,aLength)); |
|
1487 |
|
1488 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileUnLockReturn, MODULEUID, r); |
|
1489 return r; |
|
1490 } |
|
1491 |
|
1492 |
|
1493 |
|
1494 |
|
1495 EFSRV_EXPORT_C TInt RFile::Seek(TSeek aMode,TInt& aPos) const |
|
1496 /** |
|
1497 Sets the the current file position. |
|
1498 |
|
1499 The function can also be used to get the current file |
|
1500 position without changing it. The file position is the position at which |
|
1501 reading and writing takes place. The start of the file is position zero. |
|
1502 |
|
1503 To retrieve the current file position without changing it, specify ESeekCurrent |
|
1504 for the seek mode, and zero for the offset. |
|
1505 |
|
1506 If the seek mode is ESeekStart, then: |
|
1507 |
|
1508 1. the function does not modify the aPos argument, |
|
1509 |
|
1510 2. the function returns an error if the offset specified is negative. |
|
1511 |
|
1512 If the seek mode is ESeekAddress, an error is returned if: |
|
1513 |
|
1514 1. the file is not in ROM, |
|
1515 |
|
1516 2. the offset specified is greater than the size of the file. |
|
1517 |
|
1518 @param aMode Seek mode. Controls the destination of the seek operation. |
|
1519 @param aPos Offset from location specified in aMode. Can be negative. |
|
1520 On return contains the new file position. |
|
1521 If the seek mode is either ESeekCurrent or ESeekEnd and the offset |
|
1522 specifies a position before the start of the file |
|
1523 or beyond the end of the file, then on return, aPos is set to |
|
1524 the new file position (either the start or the end of the file). |
|
1525 If the seek mode is ESeekAddress, aPos returns the address of |
|
1526 the byte at the specified offset within the file. |
|
1527 |
|
1528 @return KErrNone if successful, otherwise one of the other system-wide error |
|
1529 codes. |
|
1530 */ |
|
1531 { |
|
1532 TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileSeek, MODULEUID, Session().Handle(), SubSessionHandle(), aMode, aPos, 0); |
|
1533 |
|
1534 TInt64 newPos = aPos; |
|
1535 TPckg<TInt64> pkNewPos(newPos); |
|
1536 TInt r = SendReceive(EFsFileSeek|KIpcArgSlot2Desc,TIpcArgs(aPos,aMode,&pkNewPos)); |
|
1537 if(KErrNone == r) |
|
1538 aPos = I64LOW(newPos); |
|
1539 |
|
1540 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileSeekReturn, MODULEUID, r); |
|
1541 return r; |
|
1542 } |
|
1543 |
|
1544 |
|
1545 |
|
1546 |
|
1547 EFSRV_EXPORT_C TInt RFile::Flush() |
|
1548 /** |
|
1549 Commits data to the storage device and flushes internal buffers without closing |
|
1550 the file. |
|
1551 |
|
1552 Although RFile::Close() also flushes internal buffers, it is often useful |
|
1553 to call Flush() before a file is closed. This is because Close() returns no |
|
1554 error information, so there is no way of telling whether the final data was |
|
1555 written to the file successfully or not. Once data has been flushed, Close() |
|
1556 is effectively a no-operation. |
|
1557 |
|
1558 @return KErrNone if successful, otherwise one of the other system-wide error |
|
1559 codes. |
|
1560 */ |
|
1561 { |
|
1562 TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileFlush, MODULEUID, Session().Handle(), SubSessionHandle(), NULL); |
|
1563 |
|
1564 TInt r = RSubSessionBase::SendReceive(EFsFileFlush); |
|
1565 |
|
1566 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileFlushReturn, MODULEUID, r); |
|
1567 return r; |
|
1568 } |
|
1569 |
|
1570 |
|
1571 |
|
1572 |
|
1573 EFSRV_EXPORT_C void RFile::Flush(TRequestStatus& aStatus) |
|
1574 /** |
|
1575 Commits data to the storage device and flushes internal buffers without closing |
|
1576 the file. |
|
1577 |
|
1578 Although RFile::Close() also flushes internal buffers, it is often useful |
|
1579 to call Flush() before a file is closed. This is because Close() returns no |
|
1580 error information, so there is no way of telling whether the final data was |
|
1581 written to the file successfully or not. Once data has been flushed, Close() |
|
1582 is effectively a no-operation. |
|
1583 |
|
1584 @param aStatus Request status. On completion contains KErrNone if successful, |
|
1585 otherwise one of the other system-wide error codes. |
|
1586 */ |
|
1587 { |
|
1588 TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileFlush, MODULEUID, Session().Handle(), SubSessionHandle(), &aStatus); |
|
1589 |
|
1590 RSubSessionBase::SendReceive(EFsFileFlush, aStatus); |
|
1591 |
|
1592 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileFlushReturn, MODULEUID); |
|
1593 } |
|
1594 |
|
1595 |
|
1596 |
|
1597 |
|
1598 EFSRV_EXPORT_C TInt RFile::Size(TInt& aSize) const |
|
1599 /** |
|
1600 Gets the current file size. |
|
1601 |
|
1602 @param aSize On return, the size of the file in bytes. |
|
1603 |
|
1604 @return KErrNone if successful, otherwise one of the other system-wide error |
|
1605 codes. |
|
1606 */ |
|
1607 { |
|
1608 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileSize, MODULEUID, Session().Handle(), SubSessionHandle()); |
|
1609 |
|
1610 TInt64 size = aSize; |
|
1611 TPckg<TInt64> pkSize(size); |
|
1612 TInt r = SendReceive(EFsFileSize|KIpcArgSlot0Desc,TIpcArgs(&pkSize)); |
|
1613 if(KErrNone != r) |
|
1614 return r; |
|
1615 aSize = I64LOW(size); |
|
1616 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
1617 if (size > KMaxTInt) |
|
1618 return (KErrTooBig); |
|
1619 #endif |
|
1620 |
|
1621 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileSizeReturn, MODULEUID, r, aSize); |
|
1622 return r; |
|
1623 } |
|
1624 |
|
1625 |
|
1626 |
|
1627 |
|
1628 EFSRV_EXPORT_C TInt RFile::SetSize(TInt aSize) |
|
1629 /** |
|
1630 Sets the file size. |
|
1631 |
|
1632 If the size of the file is reduced, data may be lost from |
|
1633 the end of the file. |
|
1634 |
|
1635 Note: |
|
1636 |
|
1637 1. The current file position remains unchanged unless SetSize() reduces the size |
|
1638 of the file in such a way that the current file position is now beyond |
|
1639 the end of the file. In this case, the current file position is set to |
|
1640 the end of file. |
|
1641 |
|
1642 2. If the file was not opened for writing, an error is returned. |
|
1643 |
|
1644 @param aSize The new size of the file, in bytes. This value must not be negative, otherwise the function raises a panic. |
|
1645 |
|
1646 @return KErrNone if successful, otherwise one of the other system-wide error |
|
1647 codes. |
|
1648 |
|
1649 @panic FSCLIENT 20 If aSize is negative. |
|
1650 |
|
1651 */ |
|
1652 { |
|
1653 TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileSetSize, MODULEUID, Session().Handle(), SubSessionHandle(), aSize, 0); |
|
1654 |
|
1655 TInt r = SendReceive(EFsFileSetSize,TIpcArgs(aSize)); |
|
1656 |
|
1657 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileSetSizeReturn, MODULEUID, r); |
|
1658 return r; |
|
1659 } |
|
1660 |
|
1661 |
|
1662 |
|
1663 |
|
1664 EFSRV_EXPORT_C TInt RFile::Att(TUint& aVal) const |
|
1665 /** |
|
1666 Gets the file's attributes. |
|
1667 |
|
1668 @param aVal A bitmask which, on return, contains the file’s attributes. |
|
1669 For more information, see KEntryAttNormal and the other |
|
1670 file/directory attributes. |
|
1671 |
|
1672 @return KErrNone if successful, otherwise one of the other system-wide error |
|
1673 codes. |
|
1674 |
|
1675 @see KEntryAttNormal |
|
1676 */ |
|
1677 { |
|
1678 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileAtt, MODULEUID, Session().Handle(), SubSessionHandle()); |
|
1679 |
|
1680 TPtr8 a((TUint8*)&aVal,sizeof(TUint)); |
|
1681 |
|
1682 TInt r = SendReceive(EFsFileAtt,TIpcArgs(&a)); |
|
1683 |
|
1684 TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileAttReturn, MODULEUID, r, aVal); |
|
1685 return r; |
|
1686 } |
|
1687 |
|
1688 |
|
1689 |
|
1690 |
|
1691 EFSRV_EXPORT_C TInt RFile::SetAtt(TUint aSetAttMask,TUint aClearAttMask) |
|
1692 /** |
|
1693 Sets or clears file attributes using two bitmasks. |
|
1694 |
|
1695 The first mask controls which attributes are set. |
|
1696 The second controls which attributes are cleared. |
|
1697 |
|
1698 Notes: |
|
1699 |
|
1700 1. The file must have been opened for writing, or an error is returned. |
|
1701 |
|
1702 2. A panic is raised if any attribute is specified in both bitmasks. |
|
1703 |
|
1704 3. An attempt to set or clear the KEntryAttDir, KEntryAttVolume or KEntryAttRemote |
|
1705 attributes have no effect. |
|
1706 |
|
1707 4. The new attribute values take effect when the file is flushed or closed (which |
|
1708 implies a flush). |
|
1709 |
|
1710 @param aSetAttMask A bitmask indicating the file attributes to be set |
|
1711 @param aClearAttMask A bitmask indicating the attributes to be cleared. For |
|
1712 more information see KEntryAttNormal, and the other |
|
1713 file/directory attributes. |
|
1714 |
|
1715 @return KErrNone if successful, otherwise one of the other system-wide error |
|
1716 codes. |
|
1717 |
|
1718 @panic FSCLIENT 21 if the same attribute bit is set in both bitmasks. |
|
1719 */ |
|
1720 { |
|
1721 TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileSetAtt, MODULEUID, Session().Handle(), SubSessionHandle(), aSetAttMask, aClearAttMask); |
|
1722 |
|
1723 __ASSERT_ALWAYS((aSetAttMask&aClearAttMask)==0,Panic(EAttributesIllegal)); |
|
1724 |
|
1725 TInt r = SendReceive(EFsFileSetAtt,TIpcArgs(aSetAttMask,aClearAttMask)); |
|
1726 |
|
1727 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileSetAttReturn, MODULEUID, r); |
|
1728 return r; |
|
1729 } |
|
1730 |
|
1731 |
|
1732 |
|
1733 |
|
1734 EFSRV_EXPORT_C TInt RFile::Modified(TTime& aTime) const |
|
1735 /** |
|
1736 Gets local date and time the file was last modified, in universal time. |
|
1737 |
|
1738 @param aTime On return, contains the date and time the file was last modified in UTC. |
|
1739 |
|
1740 @return KErrNone if successful, otherwise one of the other system-wide error |
|
1741 codes. |
|
1742 */ |
|
1743 { |
|
1744 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileModified, MODULEUID, Session().Handle(), SubSessionHandle()); |
|
1745 |
|
1746 TPtr8 t((TUint8*)&aTime,sizeof(TTime)); |
|
1747 TInt r = SendReceive(EFsFileModified,TIpcArgs(&t)); |
|
1748 |
|
1749 TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileModifiedReturn, MODULEUID, r, I64LOW(aTime.Int64()), I64HIGH(aTime.Int64())); |
|
1750 return r; |
|
1751 } |
|
1752 |
|
1753 |
|
1754 |
|
1755 |
|
1756 EFSRV_EXPORT_C TInt RFile::SetModified(const TTime& aTime) |
|
1757 /** |
|
1758 Sets the date and time the file was last modified. UTC date and time should be used. |
|
1759 |
|
1760 Notes: |
|
1761 |
|
1762 1. The file must have been opened for writing, or an error is returned. |
|
1763 |
|
1764 2. The new modified time takes effect when the file is flushed or closed (which |
|
1765 implies a flush). |
|
1766 |
|
1767 @param aTime The new date and time the file was last modified, in universal time. |
|
1768 |
|
1769 @return KErrNone if successful, otherwise one of the other system-wide error |
|
1770 codes. |
|
1771 */ |
|
1772 { |
|
1773 TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileSetModified, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aTime.Int64()), I64HIGH(aTime.Int64())); |
|
1774 |
|
1775 TPtrC8 t((TUint8*)&aTime,sizeof(TTime)); |
|
1776 TInt r = SendReceive(EFsFileSetModified,TIpcArgs(&t)); |
|
1777 |
|
1778 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileSetModifiedReturn, MODULEUID, r); |
|
1779 return r; |
|
1780 } |
|
1781 |
|
1782 |
|
1783 |
|
1784 |
|
1785 EFSRV_EXPORT_C TInt RFile::Set(const TTime& aTime,TUint aMask,TUint aVal) |
|
1786 /** |
|
1787 Sets the file’s attributes, and the date and time it was last modified. |
|
1788 |
|
1789 It combines the functionality of SetAtt() and SetModified() |
|
1790 |
|
1791 An attempt to set or clear the KEntryAttDir, KEntryAttVolume or KEntryAttRemote |
|
1792 attributes have no effect. |
|
1793 |
|
1794 @param aTime The new date and time the file was last modified. UTC date and time should be used. |
|
1795 @param aMask A bitmask indicating the file attributes to be set |
|
1796 @param aVal A bitmask indicating the attributes to be cleared. For |
|
1797 more information see KEntryAttNormal, and the other |
|
1798 file/directory attributes. |
|
1799 |
|
1800 @return KErrNone if successful, otherwise one of the other system-wide error |
|
1801 codes. |
|
1802 |
|
1803 @panic FSCLIENT 21 if the same attribute bit is set in both bitmasks. |
|
1804 |
|
1805 @see RFile::SetModified |
|
1806 @see RFile::SetAtt |
|
1807 */ |
|
1808 { |
|
1809 TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileSet, MODULEUID, |
|
1810 Session().Handle(), SubSessionHandle(), I64LOW(aTime.Int64()), I64HIGH(aTime.Int64()), aMask, aVal); |
|
1811 |
|
1812 __ASSERT_ALWAYS((aVal&aMask)==0,Panic(EAttributesIllegal)); |
|
1813 TPtrC8 t((TUint8*)&aTime,sizeof(TTime)); |
|
1814 TInt r = SendReceive(EFsFileSet,TIpcArgs(&t,aMask,aVal)); |
|
1815 |
|
1816 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileSetReturn, MODULEUID, r); |
|
1817 return r; |
|
1818 } |
|
1819 |
|
1820 |
|
1821 |
|
1822 |
|
1823 EFSRV_EXPORT_C TInt RFile::ChangeMode(TFileMode aNewMode) |
|
1824 /** |
|
1825 Switches an open file's access mode between EFileShareExclusive and EFileShareReadersOnly. |
|
1826 |
|
1827 This allows or disallows read-only access without having to close and re-open the file. |
|
1828 |
|
1829 @param aNewMode The new access mode. |
|
1830 |
|
1831 @return KErrNone, if successful; |
|
1832 KErrArgument, if aNewMode has any value other than the two specified; |
|
1833 KErrAccessDenied, if: |
|
1834 a) the function is called when the current file share |
|
1835 mode is EFileShareAny; |
|
1836 b) the file has multiple readers, and an attempt is made |
|
1837 to change the share mode to EFileShareExclusive; |
|
1838 c) the file has been opened for writing in EFileShareExclusive mode, and an |
|
1839 attempt is made to change the access mode to EFileShareReadersOnly. |
|
1840 |
|
1841 @capability Dependent If the path starts with /Resource then capability DiskAdmin is required |
|
1842 |
|
1843 */ |
|
1844 { |
|
1845 TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileChangeMode, MODULEUID, Session().Handle(), SubSessionHandle(), aNewMode); |
|
1846 |
|
1847 if (aNewMode!=EFileShareExclusive && aNewMode!=EFileShareReadersOnly) |
|
1848 return(KErrArgument); |
|
1849 TInt r = SendReceive(EFsFileChangeMode,TIpcArgs(aNewMode)); |
|
1850 |
|
1851 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileChangeModeReturn, MODULEUID, r); |
|
1852 return r; |
|
1853 } |
|
1854 |
|
1855 |
|
1856 |
|
1857 |
|
1858 EFSRV_EXPORT_C TInt RFile::Rename(const TDesC& aNewName) |
|
1859 /** |
|
1860 Renames a file. |
|
1861 |
|
1862 If aNewName specifies a different directory to the one in which |
|
1863 the file is currently located, then the file is moved. |
|
1864 |
|
1865 No other process may have access to the file, that is, the file must have |
|
1866 been opened in EFileShareExclusive share mode, or an error is returned. The |
|
1867 file must have been opened for writing (using EFileWrite access mode). An |
|
1868 error is returned if a file with the new filename already exists in the target |
|
1869 directory. |
|
1870 |
|
1871 The file or directory may not be moved to another device by this means, either |
|
1872 explicitly (by another drive specified in the name) or implicitly (because |
|
1873 the directory has been mapped to another device with RFs::SetSubst()). |
|
1874 |
|
1875 Note that the function builds up the new file specification by using all |
|
1876 of the path components specified |
|
1877 in aNewName (directory path, filename and extension), |
|
1878 then adding any missing components from the current file specification, and |
|
1879 finally adding any missing components from the session path. A consequence |
|
1880 of this is that you cannot rename a file to remove its extension. An alternative |
|
1881 to this function is RFs::Rename() which renames the file using the new name |
|
1882 as provided. |
|
1883 |
|
1884 @param aNewName The new file name and/or directory path. No part may contain |
|
1885 wildcard characters or an error is returned. |
|
1886 |
|
1887 @return KErrNone if successful, otherwise one of the other system-wide error |
|
1888 codes. |
|
1889 |
|
1890 @capability Dependent If aNewName starts with /Sys then capability Tcb is required |
|
1891 @capability Dependent If aNewName starts with /Resource then capability Tcb is required |
|
1892 @capability Dependent If aNewName starts with /Private and does not match this process' |
|
1893 SID then AllFiles capability is required. |
|
1894 |
|
1895 */ |
|
1896 { |
|
1897 TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileRename, MODULEUID, Session().Handle(), SubSessionHandle(), aNewName); |
|
1898 |
|
1899 TInt r = SendReceive(EFsFileRename,TIpcArgs(&aNewName)); |
|
1900 |
|
1901 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileRenameReturn, MODULEUID, r); |
|
1902 return r; |
|
1903 } |
|
1904 |
|
1905 |
|
1906 |
|
1907 |
|
1908 EFSRV_EXPORT_C TInt RFile::Drive(TInt &aDriveNumber, TDriveInfo &aDriveInfo) const |
|
1909 /** |
|
1910 Gets information about the drive on which this file resides. |
|
1911 |
|
1912 @param aDriveNumber On return, the drive number. |
|
1913 |
|
1914 @param aDriveInfo On return, contains information describing the drive |
|
1915 and the medium mounted on it. The value of TDriveInfo::iType |
|
1916 shows whether the drive contains media. |
|
1917 |
|
1918 @return KErrNone, if successful, otherwise one of the other |
|
1919 system-wide error codes |
|
1920 |
|
1921 @see RFs::Drive |
|
1922 */ |
|
1923 { |
|
1924 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileDrive, MODULEUID, Session().Handle(), SubSessionHandle()); |
|
1925 |
|
1926 TPckg<TInt> pki(aDriveNumber); |
|
1927 TPckg<TDriveInfo> pkdi(aDriveInfo); |
|
1928 TInt r = SendReceive(EFsFileDrive,TIpcArgs(&pki,&pkdi)); |
|
1929 |
|
1930 TRACERET4(UTF::EBorder, UTraceModuleEfsrv::EFileDriveReturn, MODULEUID, r, aDriveInfo.iDriveAtt, aDriveInfo.iMediaAtt, aDriveInfo.iType); |
|
1931 return r; |
|
1932 } |
|
1933 |
|
1934 |
|
1935 TInt RFile::Clamp(RFileClamp& aHandle) |
|
1936 /** |
|
1937 Instructs the File Server that the file is not to be modified on storage media. |
|
1938 |
|
1939 @param aHandle On return, a handle to the file. |
|
1940 |
|
1941 @return KErrNone, if successful, otherwise one of the other |
|
1942 system-wide error codes |
|
1943 |
|
1944 @see RFs::Unclamp |
|
1945 */ |
|
1946 { |
|
1947 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileClamp, MODULEUID, Session().Handle(), SubSessionHandle()); |
|
1948 |
|
1949 TPckg<RFileClamp> pkHandle(aHandle); |
|
1950 TInt r = SendReceive(EFsFileClamp,TIpcArgs(& pkHandle)); |
|
1951 |
|
1952 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileClampReturn, MODULEUID, r); |
|
1953 return r; |
|
1954 } |
|
1955 |
|
1956 /** |
|
1957 Fetches the Block Map of a file. Each file in the file system will consist of |
|
1958 a number of groups of blocks. Each group represents a number of contiguous blocks. |
|
1959 Such a group is represented by the TBlockMapEntry class. The full Block Map representing |
|
1960 the file may be determined by repeatedly calling RFile::BlockMap until KErrCompletion is |
|
1961 returned. |
|
1962 |
|
1963 Note: |
|
1964 |
|
1965 1. If the Block Map for the whole file is not required, then a start and end position |
|
1966 for a section of the file can be specified. Both of these parameters specify offsets |
|
1967 from the start of the file in bytes. |
|
1968 |
|
1969 @param aInfo A structure describing a group of block maps. |
|
1970 |
|
1971 @param aStartPos A start position for a desired section of the file. |
|
1972 |
|
1973 @param aEndPos An end position for a desired section of the file. If not passed, then the end of the |
|
1974 file is assumed. |
|
1975 |
|
1976 @return KErrNone until the end of the file or the file section is successfully reached; |
|
1977 KErrCompletion if the end of the file is reached; |
|
1978 KErrNotSupported if the file system does not support Block Mapping or the media is either removable or not pageable. |
|
1979 */ |
|
1980 EFSRV_EXPORT_C TInt RFile::BlockMap(SBlockMapInfo& aInfo, TInt64& aStartPos, TInt64 aEndPos, TInt aBlockMapUsage) const |
|
1981 { |
|
1982 TRACE7(UTF::EBorder, UTraceModuleEfsrv::EFileBlockMap, MODULEUID, |
|
1983 Session().Handle(), SubSessionHandle(), I64LOW(aStartPos), I64HIGH(aEndPos), I64LOW(aEndPos), I64HIGH(aEndPos), aBlockMapUsage); |
|
1984 |
|
1985 SBlockMapArgs args; |
|
1986 args.iStartPos = aStartPos; |
|
1987 args.iEndPos = aEndPos; |
|
1988 TPckg<SBlockMapInfo> pkInfo(aInfo); |
|
1989 TPckg<SBlockMapArgs> pkArgs(args); |
|
1990 TInt r = SendReceive(EFsBlockMap, TIpcArgs(&pkInfo, &pkArgs, aBlockMapUsage)); |
|
1991 if(r==KErrNone) |
|
1992 aStartPos = args.iStartPos; |
|
1993 |
|
1994 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileBlockMapReturn, MODULEUID, r); |
|
1995 return r; |
|
1996 } |
|
1997 |
|
1998 |
|
1999 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
2000 /** |
|
2001 Opens an existing file for reading or writing. |
|
2002 |
|
2003 If the file does not already exist, an error is returned. |
|
2004 |
|
2005 This is equivalent to calling RFile::Open except that this function |
|
2006 can open files of size greater than 2GB - 1 also. |
|
2007 |
|
2008 Notes: |
|
2009 |
|
2010 1. To close the file, use Close() |
|
2011 |
|
2012 2. Attempting to open a file with the read-only attribute using the EFileWrite |
|
2013 access mode results in an error. |
|
2014 |
|
2015 3. After a file has been opened, the current write position is set to the start |
|
2016 of the file. |
|
2017 If necessary, use RFile64::Seek() to move to a different position within |
|
2018 the file. |
|
2019 |
|
2020 4. It enables big file support to handle files whose size are greater then 2GB-1 |
|
2021 |
|
2022 @param aFs The file server session. |
|
2023 @param aName The name of the file. Any path components (i.e. drive letter |
|
2024 or directory), which are not specified, are taken from |
|
2025 the session path. |
|
2026 @param aMode The mode in which the file is opened. See TFileMode. |
|
2027 |
|
2028 @return KErrNone if successful, otherwise one of the other system-wide |
|
2029 error codes. |
|
2030 |
|
2031 @see TFileMode |
|
2032 @see RFile::Open() |
|
2033 |
|
2034 @capability Dependent If the path for aName is /Sys and aMode is neither |
|
2035 EFileShareReadersOnly nor EFileRead then Tcb capability is required. |
|
2036 @capability Dependent If the path for aName is /Sys and aMode is either |
|
2037 EFileShareReadersOnly or EFileRead then Allfiles capability is required. |
|
2038 @capability Dependent If the path for aName begins with /Private and does not match this process' |
|
2039 SID then AllFiles capability is required. |
|
2040 @capability Dependent If the path for aName begins with /Resource and aMode is neither |
|
2041 EFileShareReadersOrWriters|EFileRead nor EFileShareReadersOnly |
|
2042 nor EFileRead then Tcb capability is required. |
|
2043 |
|
2044 */ |
|
2045 EFSRV_EXPORT_C TInt RFile64::Open(RFs& aFs,const TDesC& aName,TUint aFileMode) |
|
2046 { |
|
2047 TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileOpen, MODULEUID, aFs.Handle(), aFileMode, aName); |
|
2048 |
|
2049 TInt r = CreateSubSession(aFs,EFsFileOpen,TIpcArgs(&aName,aFileMode|EFileBigFile)); |
|
2050 |
|
2051 TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileOpenReturn, MODULEUID, r, SubSessionHandle()); |
|
2052 return r; |
|
2053 } |
|
2054 |
|
2055 /** |
|
2056 Creates and opens a new file for writing. |
|
2057 |
|
2058 If the file already exists, an error is returned. |
|
2059 |
|
2060 If the resulting path does not exist, then the operation cannot proceed and |
|
2061 the function returns an error code. |
|
2062 |
|
2063 This is equivalent to calling RFile::Create except that the file created with |
|
2064 this function can grow beyond 2GB - 1 also. |
|
2065 |
|
2066 Notes: |
|
2067 |
|
2068 1. To close the file, use Close() |
|
2069 |
|
2070 2. It automatically sets the file's archive attribute. |
|
2071 |
|
2072 3. It enables big file support to handle files whose size are greater then 2GB-1 |
|
2073 |
|
2074 |
|
2075 @param aFs The file server session. |
|
2076 @param aName The name of the file. Any path components (i.e. drive letter |
|
2077 or directory), which are not specified, are taken from |
|
2078 the session path. |
|
2079 @param aMode The mode in which the file is opened. The access mode is |
|
2080 automatically set to EFileWrite. See TFileMode. |
|
2081 |
|
2082 @return KErrNone if successful, otherwise one of the other system-wide |
|
2083 error codes. |
|
2084 |
|
2085 @see RFile::Create() |
|
2086 @see TFileMode |
|
2087 |
|
2088 @capability Dependent If the path in aName starts with /Sys then capability Tcb is required |
|
2089 @capability Dependent If the path in aName starts with /Resource then capability Tcb is required |
|
2090 @capability Dependent If the path in aName starts with /Private and does not match this process' |
|
2091 SID then AllFiles capability is required. |
|
2092 |
|
2093 */ |
|
2094 EFSRV_EXPORT_C TInt RFile64::Create(RFs& aFs,const TDesC& aName,TUint aFileMode) |
|
2095 { |
|
2096 TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileCreate, MODULEUID, aFs.Handle(), aFileMode, aName); |
|
2097 |
|
2098 TInt r = CreateSubSession(aFs,EFsFileCreate,TIpcArgs(&aName,aFileMode|EFileBigFile)); |
|
2099 |
|
2100 TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileCreateReturn, MODULEUID, r, SubSessionHandle()); |
|
2101 return r; |
|
2102 } |
|
2103 |
|
2104 /** |
|
2105 Opens a file for writing, replacing the content of any existing file of the |
|
2106 same name if it exists, or creating a new file if it does not exist. |
|
2107 |
|
2108 This is equivalent to calling RFile::Replace except that the file created or replaced |
|
2109 with this function can grow beyond 2GB - 1 also. |
|
2110 |
|
2111 |
|
2112 If the resulting path exists, then: |
|
2113 |
|
2114 - the length of an existing file with the same filename is re-set to zero |
|
2115 |
|
2116 - a new file is created, if no existing file with the same filename can be found. |
|
2117 |
|
2118 If the resulting path does not exist, then the operation cannot proceed and |
|
2119 the function returns an error code. |
|
2120 |
|
2121 Notes: |
|
2122 |
|
2123 - To close the file, use Close(), defined in the base class RFsBase. |
|
2124 |
|
2125 - It automatically sets the file's archive attribute. |
|
2126 |
|
2127 - It enables big file support to handle files whose size are greater then 2GB-1 |
|
2128 |
|
2129 |
|
2130 @param aFs The file server session. |
|
2131 @param aName The name of the file. Any path components (i.e. drive letter |
|
2132 or directory), which are not specified, are taken from |
|
2133 the session path. |
|
2134 @param aMode The mode in which the file is opened. The access mode is |
|
2135 automatically set to EFileWrite. See TFileMode. |
|
2136 |
|
2137 @return KErrNone if successful, otherwise one of the other system-wide |
|
2138 error codes. |
|
2139 |
|
2140 @see TFileMode |
|
2141 @see RFile::Replace() |
|
2142 |
|
2143 @capability Dependent If the path in aName starts with /Sys then capability Tcb is required |
|
2144 @capability Dependent If the path in aName starts with /Resource then capability Tcb is required |
|
2145 @capability Dependent If the path in aName starts with /Private and does not match this process' |
|
2146 SID then AllFiles capability is required. |
|
2147 |
|
2148 */ |
|
2149 EFSRV_EXPORT_C TInt RFile64::Replace(RFs& aFs,const TDesC& aName,TUint aFileMode) |
|
2150 { |
|
2151 TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileReplace, MODULEUID, aFs.Handle(), aFileMode, aName); |
|
2152 |
|
2153 TInt r = CreateSubSession(aFs,EFsFileReplace,TIpcArgs(&aName,aFileMode|EFileBigFile)); |
|
2154 |
|
2155 TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileReplaceReturn, MODULEUID, r, SubSessionHandle()); |
|
2156 return r; |
|
2157 } |
|
2158 |
|
2159 |
|
2160 /** |
|
2161 Creates and opens a temporary file with a unique name for writing and reading. |
|
2162 This is equivalent to calling RFile::Temp except that the file created |
|
2163 with this function can grow beyond 2GB - 1 also. |
|
2164 |
|
2165 |
|
2166 Notes: |
|
2167 |
|
2168 1. To close the file, use Close() |
|
2169 2. It enables big file support to handle files whose size are greater then 2GB-1 |
|
2170 |
|
2171 @param aFs The file server session. |
|
2172 @param aPath The directory in which the file is created. |
|
2173 @param aName On return, contains the full path and file name of the file. |
|
2174 The filename is guaranteed to be unique within the directory |
|
2175 specified by aPath. |
|
2176 @param aMode The mode in which the file is opened. The access mode is |
|
2177 automatically set to EFileWrite. See TFileMode. |
|
2178 |
|
2179 @return KErrNone if successful, otherwise one of the other system-wide |
|
2180 error codes. |
|
2181 |
|
2182 @see TFileMode |
|
2183 @see RFile::Temp() |
|
2184 |
|
2185 @capability Dependent If aPath starts with /Sys then capability Tcb is required |
|
2186 @capability Dependent If aPath starts with /Resource then capability Tcb is required |
|
2187 @capability Dependent If aPath starts with /Private and does not match this process' |
|
2188 SID then AllFiles capability is required. |
|
2189 */ |
|
2190 EFSRV_EXPORT_C TInt RFile64::Temp(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode) |
|
2191 { |
|
2192 TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileTemp, MODULEUID, aFs.Handle(), aPath, aFileMode); |
|
2193 TInt r = CreateSubSession(aFs,EFsFileTemp,TIpcArgs(&aPath,aFileMode|EFileBigFile,&aName)); |
|
2194 TRACERETMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileTempReturn, MODULEUID, r, SubSessionHandle(), aName); |
|
2195 return r; |
|
2196 } |
|
2197 |
|
2198 |
|
2199 /** |
|
2200 Allows a server to adopt an already open file from a client. |
|
2201 The client's RFs and RFile or RFile64 handles are contained in message slots within aMsg. |
|
2202 |
|
2203 Assumes that the client's RFs and RFile or RFile64 handles have been sent to the server |
|
2204 using TransferToServer(). |
|
2205 |
|
2206 This is equivalent to calling RFile::AdoptFromClient |
|
2207 except that the file adopted can be enlarged to sizes beyond 2GB-1. |
|
2208 |
|
2209 Note: |
|
2210 If a RFile handle is received from the client then enlarging the file beyond |
|
2211 2GB-1 might result in inconsistent behaviour by the client, since it(client) would |
|
2212 not be able to handle files of size greater than 2GB-1. |
|
2213 |
|
2214 If a RFile64 handle is received from the client then enlarging the file beyond |
|
2215 2GB-1 should not cause any issues since the client would be |
|
2216 capable of handling files of size greater than 2GB-1. |
|
2217 |
|
2218 This RFile or RFile64 will own it's RFs session so that when the sub-session (RFile or RFile64) |
|
2219 is closed so will the RFs session. |
|
2220 |
|
2221 @param aMsg The message received from the client |
|
2222 @param aFsHandleIndex The index that identifies the message slot |
|
2223 of a file server session (RFs) handle |
|
2224 @param aFileHandleIndex The index that identifies the message slot |
|
2225 of the sub-session (RFile or RFile64) handle of the already opened file |
|
2226 |
|
2227 @return KErrNone if successful, otherwise one of the other system-wide |
|
2228 error codes. |
|
2229 */ |
|
2230 EFSRV_EXPORT_C TInt RFile64::AdoptFromClient(const RMessage2& aMsg, TInt aFsHandleIndex, TInt aFileHandleIndex) |
|
2231 { |
|
2232 TInt fileHandle = NULL; |
|
2233 |
|
2234 TInt r = KErrNone; |
|
2235 if (aFileHandleIndex == 0) |
|
2236 fileHandle = aMsg.Int0(); |
|
2237 else if (aFileHandleIndex == 1) |
|
2238 fileHandle = aMsg.Int1(); |
|
2239 else if (aFileHandleIndex == 2) |
|
2240 fileHandle = aMsg.Int2(); |
|
2241 else if (aFileHandleIndex == 3) |
|
2242 fileHandle = aMsg.Int3(); |
|
2243 else |
|
2244 r = KErrArgument; |
|
2245 |
|
2246 #ifdef SYMBIAN_FTRACE_ENABLE |
|
2247 TInt handle = NULL; |
|
2248 if (aFsHandleIndex == 0) |
|
2249 handle = aMsg.Int0(); |
|
2250 else if (aFsHandleIndex == 1) |
|
2251 handle = aMsg.Int1(); |
|
2252 else if (aFsHandleIndex == 2) |
|
2253 handle = aMsg.Int2(); |
|
2254 else if (aFsHandleIndex == 3) |
|
2255 handle = aMsg.Int3(); |
|
2256 TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClient, MODULEUID, handle, fileHandle, aFsHandleIndex, aFileHandleIndex); |
|
2257 #endif |
|
2258 |
|
2259 if (r != KErrNone) |
|
2260 { |
|
2261 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClientReturn, MODULEUID, r); |
|
2262 return r; |
|
2263 } |
|
2264 |
|
2265 // Duplicates the file server (RFs) session handle identified by an |
|
2266 // existing handle contained in the message slot at index aFsHandleIndex |
|
2267 RFs fs; |
|
2268 r = fs.Open(aMsg, aFsHandleIndex, KFileServerPolicy); |
|
2269 if (r != KErrNone) |
|
2270 { |
|
2271 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClientReturn, MODULEUID, r); |
|
2272 return r; |
|
2273 } |
|
2274 |
|
2275 //return CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(fileHandle)); |
|
2276 // Slot 1: Indicate Large File Supportis required. |
|
2277 r = CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(fileHandle, KFileAdopt64)); |
|
2278 |
|
2279 TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClientReturn, MODULEUID, r, Session().Handle(), SubSessionHandle()); |
|
2280 |
|
2281 return r; |
|
2282 } |
|
2283 |
|
2284 |
|
2285 /** |
|
2286 Allows a client to adopt an already open file from a server. |
|
2287 |
|
2288 Assumes that the server's RFs and RFile or RFile64 handles have been sent to the |
|
2289 client using TransferToClient(). |
|
2290 |
|
2291 This is equivalent to calling RFile::AdoptFromServer |
|
2292 except that the file adopted can be enlarged to sizes beyond 2GB-1. |
|
2293 |
|
2294 Note: |
|
2295 If a RFile handle is received from the server then enlarging the file beyond |
|
2296 2GB-1 might result in inconsistent behaviour by the server, since it(server) would |
|
2297 not be able to handle files of size greater than 2GB-1. |
|
2298 |
|
2299 If a RFile64 handle is received from the server then enlarging the file beyond |
|
2300 2GB-1 should not cause any issues since the server would be capable of |
|
2301 handling files of size greater than 2GB-1. |
|
2302 |
|
2303 This RFile or RFile64 will own it's RFs session so that when the sub-session (RFile or RFile64) |
|
2304 is closed so will the RFs session. |
|
2305 |
|
2306 @param aFsHandle The file server session (RFs) handle |
|
2307 @param aFileHandle The file (RFile or RFile64) handle of the already opened file |
|
2308 |
|
2309 @return KErrNone if successful, otherwise one of the other system-wide |
|
2310 error codes. |
|
2311 */ |
|
2312 EFSRV_EXPORT_C TInt RFile64::AdoptFromServer(TInt aFsHandle, TInt aFileHandle) |
|
2313 { |
|
2314 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromServer, MODULEUID, aFsHandle, aFileHandle); |
|
2315 |
|
2316 RFs fs; |
|
2317 TInt r = fs.SetReturnedHandle(aFsHandle, KFileServerPolicy); |
|
2318 if (r != KErrNone) |
|
2319 { |
|
2320 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromServerReturn, MODULEUID, r); |
|
2321 return r; |
|
2322 } |
|
2323 |
|
2324 //return(CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(aFileHandle))); |
|
2325 // Slot 1: Indicate Large File Supportis required. |
|
2326 r = CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(aFileHandle, KFileAdopt64)); |
|
2327 |
|
2328 TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromServerReturn, MODULEUID, r, Session().Handle(), SubSessionHandle()); |
|
2329 |
|
2330 return r; |
|
2331 } |
|
2332 |
|
2333 |
|
2334 /** |
|
2335 Allows a server to adopt an already open file from a client process. |
|
2336 The client's file-server (RFs) and file (RFile or RFile64) handles are contained in |
|
2337 this process's environment data slots. |
|
2338 |
|
2339 Assumes that the client's RFs and RFile or RFile64 handles have been sent to the server process |
|
2340 using TransferToProcess(). |
|
2341 |
|
2342 This is equivalent to calling RFile::AdoptFromCreator |
|
2343 except that the file adopted can be enlarged to sizes beyond 2GB-1. |
|
2344 |
|
2345 Note: |
|
2346 If a RFile handle is received from the client then enlarging the file beyond |
|
2347 2GB-1 might result in inconsistent behaviour by the client, since it(client) would |
|
2348 not be able to handle files of size greater than 2GB-1. |
|
2349 |
|
2350 If a RFile64 handle is received from the client then enlarging the file beyond |
|
2351 2GB-1 should not cause any issues since the client would be capable of |
|
2352 handling files of size greater than 2GB-1. |
|
2353 |
|
2354 This RFile or RFile64 will own it's RFs session so that when the sub-session (RFile or RFile64) |
|
2355 is closed so will the RFs session. |
|
2356 |
|
2357 @param aFsHandleIndex An index that identifies the slot in the process |
|
2358 environment data that contains the file server session (RFs) handle |
|
2359 @param aFileHandleIndex An index that identifies the slot in the process |
|
2360 environment data that contains the sub-session (RFile or RFile64) handle |
|
2361 of the already opened file |
|
2362 |
|
2363 @return KErrNone if successful, otherwise one of the other system-wide |
|
2364 error codes. |
|
2365 */ |
|
2366 EFSRV_EXPORT_C TInt RFile64::AdoptFromCreator(TInt aFsHandleIndex, TInt aFileHandleIndex) |
|
2367 { |
|
2368 TInt fileHandle; |
|
2369 TInt r = User::GetTIntParameter(aFileHandleIndex, fileHandle); |
|
2370 |
|
2371 TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreator, MODULEUID, fileHandle, aFsHandleIndex, aFileHandleIndex); |
|
2372 |
|
2373 if (r != KErrNone) |
|
2374 { |
|
2375 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreatorReturn, MODULEUID, r); |
|
2376 return r; |
|
2377 } |
|
2378 |
|
2379 |
|
2380 // Duplicates the file server (RFs) session handle identified by an |
|
2381 // existing handle contained in the environment slot at index aFsHandleIndex |
|
2382 RFs fs; |
|
2383 r = fs.Open(aFsHandleIndex, KFileServerPolicy); |
|
2384 if (r != KErrNone) |
|
2385 { |
|
2386 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreatorReturn, MODULEUID, r); |
|
2387 return r; |
|
2388 } |
|
2389 |
|
2390 //return(CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(fileHandle))); |
|
2391 // Slot 1: Indicate Large File Supportis required. |
|
2392 r = CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(fileHandle, KFileAdopt64)); |
|
2393 |
|
2394 TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreatorReturn, MODULEUID, r, Session().Handle(), SubSessionHandle()); |
|
2395 |
|
2396 return r; |
|
2397 } |
|
2398 |
|
2399 |
|
2400 /** |
|
2401 Reads from the file at the specified offset within the file |
|
2402 |
|
2403 This is a synchronous function. |
|
2404 |
|
2405 This is equivalent to calling RFile::Read(TInt, TDes8&) except that this function |
|
2406 accepts TInt64, instead of TInt, as its first parameter. This allows to specify |
|
2407 the read position beyond 2GB-1. |
|
2408 |
|
2409 @see RFile::Read(TInt aPos, TDes8& aDes) |
|
2410 |
|
2411 Note that when an attempt is made to read beyond the end of the file, |
|
2412 no error is returned. |
|
2413 The descriptor's length is set to the number of bytes read into it. |
|
2414 Therefore, when reading through a file, the end of file has been reached |
|
2415 when the descriptor length, as returned by TDesC8::Length(), is zero. |
|
2416 |
|
2417 @param aPos Position of first byte to be read. This is an offset from |
|
2418 the start of the file. If no position is specified, reading |
|
2419 begins at the current file position. |
|
2420 If aPos is beyond the end of the file, the function returns |
|
2421 a zero length descriptor. |
|
2422 |
|
2423 @param aDes The descriptor into which binary data is read. Any existing content |
|
2424 is overwritten. On return, its length is set to the number of |
|
2425 bytes read. |
|
2426 |
|
2427 @return KErrNone if successful, otherwise one of the other system-wide error |
|
2428 codes. |
|
2429 |
|
2430 @panic FSCLIENT 19 if aPos is negative. |
|
2431 */ |
|
2432 EFSRV_EXPORT_C TInt RFile64::Read(TInt64 aPos, TDes8& aDes) const |
|
2433 { |
|
2434 TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileRead3, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aDes.MaxLength()); |
|
2435 |
|
2436 __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); |
|
2437 |
|
2438 TInt r; |
|
2439 if (!(I64HIGH(aPos+1))) |
|
2440 { |
|
2441 r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),I64LOW(aPos))); |
|
2442 } |
|
2443 else |
|
2444 { |
|
2445 TPckgC<TInt64> pkPos(aPos); |
|
2446 r = SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.MaxLength(),&pkPos)); |
|
2447 } |
|
2448 |
|
2449 TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead3Return, MODULEUID, r, aDes.Length()); |
|
2450 |
|
2451 return r; |
|
2452 } |
|
2453 |
|
2454 |
|
2455 /** |
|
2456 Reads from the file at the specified offset within the file. |
|
2457 |
|
2458 This is an asynchronous function. |
|
2459 |
|
2460 This is equivalent to calling RFile::Read(TInt, TDes8&, TRequestStatus&) except |
|
2461 that this function accepts TInt64, instead of TInt, as its first parameter. |
|
2462 This allows to specify the read position beyond 2GB-1. |
|
2463 |
|
2464 @see RFile::Read(TInt aPos, TDes8& aDes, TRequestStatus& aStatus) |
|
2465 |
|
2466 Note that when an attempt is made to read beyond the end of the file, |
|
2467 no error is returned. |
|
2468 The descriptor's length is set to the number of bytes read into it. |
|
2469 Therefore, when reading through a file, the end of file has been reached |
|
2470 when the descriptor length, as returned by TDesC8::Length(), is zero. |
|
2471 |
|
2472 @param aPos Position of first byte to be read. This is an offset from |
|
2473 the start of the file. If no position is specified, |
|
2474 reading begins at the current file position. |
|
2475 If aPos is beyond the end of the file, the function returns |
|
2476 a zero length descriptor. |
|
2477 |
|
2478 @param aDes The descriptor into which binary data is read. Any existing |
|
2479 content is overwritten. On return, its length is set to |
|
2480 the number of bytes read. |
|
2481 NB: this function is asynchronous and the request that it |
|
2482 represents may not complete until some time after the call |
|
2483 to the function has returned. It is important, therefore, that |
|
2484 this descriptor remain valid, or remain in scope, until you have |
|
2485 been notified that the request is complete. |
|
2486 |
|
2487 @param aStatus The request status. On completion, contains an error code of KErrNone |
|
2488 if successful, otherwise one of the other system-wide error codes. |
|
2489 |
|
2490 @panic FSCLIENT 19 if aPos is negative. |
|
2491 */ |
|
2492 EFSRV_EXPORT_C void RFile64::Read(TInt64 aPos, TDes8& aDes, TRequestStatus& aStatus) const |
|
2493 { |
|
2494 TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileRead4, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aDes.MaxLength(), &aStatus); |
|
2495 |
|
2496 __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); |
|
2497 if (!(I64HIGH(aPos+1))) |
|
2498 { |
|
2499 RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),I64LOW(aPos)),aStatus); |
|
2500 } |
|
2501 else |
|
2502 { |
|
2503 TPckgC<TInt64> pkPos(aPos); |
|
2504 RSubSessionBase::SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.MaxLength(),&pkPos),aStatus); |
|
2505 } |
|
2506 |
|
2507 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead4Return, MODULEUID); |
|
2508 } |
|
2509 |
|
2510 |
|
2511 /** |
|
2512 Reads the specified number of bytes of binary data from the file at a specified |
|
2513 offset within the file. |
|
2514 |
|
2515 This is a synchronous function. |
|
2516 |
|
2517 This is equivalent to calling RFile::Read(TInt, TDes8&, TInt) except |
|
2518 that this function accepts TInt64, instead of TInt, as its first parameter. |
|
2519 This allows to specify the read position beyond 2GB-1. |
|
2520 |
|
2521 @see RFile::Read(TInt aPos, TDes8& aDes, TInt aLength) |
|
2522 |
|
2523 Note that when an attempt is made to read beyond the end of the file, |
|
2524 no error is returned. |
|
2525 The descriptor's length is set to the number of bytes read into it. |
|
2526 Therefore, when reading through a file, the end of file has been reached |
|
2527 when the descriptor length, as returned by TDesC8::Length(), is zero. |
|
2528 Assuming aLength is less than the maximum length of the descriptor, the only |
|
2529 circumstances in which Read() can return fewer bytes than requested is when |
|
2530 the end of file is reached or if an error has occurred. |
|
2531 |
|
2532 @param aPos Position of first byte to be read. This is an offset from |
|
2533 the start of the file. If no position is specified, |
|
2534 reading begins at the current file position. |
|
2535 If aPos is beyond the end of the file, the function returns |
|
2536 a zero length descriptor. |
|
2537 |
|
2538 @param aDes The descriptor into which binary data is read. Any existing |
|
2539 contents are overwritten. On return, its length is set to |
|
2540 the number of bytes read. |
|
2541 @param aLength The number of bytes to read from the file into the descriptor. |
|
2542 If an attempt is made to read more bytes than the descriptor's |
|
2543 maximum length, then the function updates aStatus parameter with KErrOverflow. |
|
2544 It must not be negative otherwise the function updates aStatus with KErrArgument. |
|
2545 |
|
2546 @return KErrNone if successful, otherwise one of the other system-wide |
|
2547 error codes. |
|
2548 |
|
2549 @panic FSCLIENT 19 if aPos is negative. |
|
2550 */ |
|
2551 EFSRV_EXPORT_C TInt RFile64::Read(TInt64 aPos, TDes8& aDes, TInt aLength) const |
|
2552 { |
|
2553 TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileRead3, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aLength); |
|
2554 |
|
2555 __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); |
|
2556 if (aLength==0) |
|
2557 { |
|
2558 aDes.Zero(); |
|
2559 return(KErrNone); |
|
2560 } |
|
2561 else if(aLength>aDes.MaxLength()) |
|
2562 { |
|
2563 return(KErrOverflow); |
|
2564 } |
|
2565 |
|
2566 TInt r; |
|
2567 if (!(I64HIGH(aPos+1))) |
|
2568 { |
|
2569 r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,I64LOW(aPos))); |
|
2570 } |
|
2571 else |
|
2572 { |
|
2573 TPckgC<TInt64> pkPos(aPos); |
|
2574 r = SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos)); |
|
2575 } |
|
2576 |
|
2577 TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead3Return, MODULEUID, r, aDes.Length()); |
|
2578 |
|
2579 return r; |
|
2580 } |
|
2581 |
|
2582 |
|
2583 /** |
|
2584 Reads the specified number of bytes of binary data from the file at a specified |
|
2585 offset within the file. |
|
2586 |
|
2587 This is an asynchronous function. |
|
2588 |
|
2589 This is equivalent to calling RFile::Read(TInt, TDes8&, TInt, TRequestStatus&) except |
|
2590 that this function accepts TInt64, instead of TInt, as its first parameter. |
|
2591 This allows to specify the read position beyond 2GB-1. |
|
2592 |
|
2593 @see RFile::Read(TInt aPos, TDes8& aDes,TInt aLength,TRequestStatus& aStatus) |
|
2594 |
|
2595 Note that when an attempt is made to read beyond the end of the file, |
|
2596 no error is returned. |
|
2597 The descriptor's length is set to the number of bytes read into it. |
|
2598 Therefore, when reading through a file, the end of file has been reached |
|
2599 when the descriptor length, as returned by TDesC8::Length(), is zero. |
|
2600 Assuming aLength is less than the maximum length of the descriptor, the only |
|
2601 circumstances in which Read() can return fewer bytes than requested is when |
|
2602 the end of file is reached or if an error has occurred. |
|
2603 |
|
2604 @param aPos Position of first byte to be read. This is an offset from |
|
2605 the start of the file. If no position is specified, |
|
2606 reading begins at the current file position. |
|
2607 If aPos is beyond the end of the file, the function returns |
|
2608 a zero length descriptor. |
|
2609 |
|
2610 @param aDes The descriptor into which binary data is read. Any existing |
|
2611 contents are overwritten. On return, its length is set to |
|
2612 the number of bytes read. |
|
2613 NB: this function is asynchronous and the request that it |
|
2614 represents may not complete until some time after the call |
|
2615 to the function has returned. It is important, therefore, that |
|
2616 this descriptor remain valid, or remain in scope, until you have |
|
2617 been notified that the request is complete. |
|
2618 |
|
2619 @param aLength The number of bytes to read from the file into the descriptor. |
|
2620 If an attempt is made to read more bytes than the descriptor's |
|
2621 maximum length, then the function returns KErrOverflow. |
|
2622 It must not be negative otherwise the function returns KErrArgument. |
|
2623 |
|
2624 @param aStatus Request status. On completion contains KErrNone if successful, |
|
2625 otherwise one of the other system-wide error codes. |
|
2626 |
|
2627 @panic FSCLIENT 19 if aPos is negative. |
|
2628 */ |
|
2629 EFSRV_EXPORT_C void RFile64::Read(TInt64 aPos, TDes8& aDes, TInt aLength,TRequestStatus& aStatus) const |
|
2630 { |
|
2631 TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileRead4, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aLength, &aStatus); |
|
2632 |
|
2633 __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); |
|
2634 if (aLength==0) |
|
2635 { |
|
2636 aDes.Zero(); |
|
2637 TRequestStatus* req=(&aStatus); |
|
2638 User::RequestComplete(req,KErrNone); |
|
2639 return; |
|
2640 } |
|
2641 else if(aLength>aDes.MaxLength()) |
|
2642 { |
|
2643 TRequestStatus* req=(&aStatus); |
|
2644 User::RequestComplete(req,KErrOverflow); |
|
2645 return; |
|
2646 } |
|
2647 |
|
2648 if (!(I64HIGH(aPos+1))) |
|
2649 { |
|
2650 RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,I64LOW(aPos)),aStatus); |
|
2651 } |
|
2652 else |
|
2653 { |
|
2654 TPckgC<TInt64> pkPos(aPos); |
|
2655 RSubSessionBase::SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos),aStatus); |
|
2656 } |
|
2657 |
|
2658 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead4Return, MODULEUID); |
|
2659 } |
|
2660 |
|
2661 |
|
2662 /** |
|
2663 Writes to the file at the specified offset within the file |
|
2664 |
|
2665 This is a synchronous function. |
|
2666 |
|
2667 This is equivalent to calling RFile::Write(TInt, TDes8&) except |
|
2668 that this function accepts TInt64, instead of TInt, as its first parameter. |
|
2669 This allows to specify the write position beyond 2GB-1. |
|
2670 |
|
2671 @see RFile::Write(TInt aPos, TDes8& aDes) |
|
2672 |
|
2673 |
|
2674 @param aPos The offset from the start of the file at which the first |
|
2675 byte is written. |
|
2676 If a position beyond the end of the file is specified, then |
|
2677 the write operation begins at the end of the file. |
|
2678 If the position has been locked, then the write fails. |
|
2679 |
|
2680 @param aDes The descriptor from which binary data is written. The function writes |
|
2681 the entire contents of aDes to the file. |
|
2682 |
|
2683 @return KErrNone if successful, otherwise one of the other system-wide error |
|
2684 codes. |
|
2685 |
|
2686 @panic FSCLIENT 19 if aPos is negative. |
|
2687 */ |
|
2688 EFSRV_EXPORT_C TInt RFile64::Write(TInt64 aPos, const TDesC8& aDes) |
|
2689 { |
|
2690 TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileWrite3, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aDes.Length()); |
|
2691 |
|
2692 __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); |
|
2693 |
|
2694 TInt r; |
|
2695 if (!(I64HIGH(aPos+1))) |
|
2696 { |
|
2697 r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),I64LOW(aPos))); |
|
2698 } |
|
2699 else |
|
2700 { |
|
2701 TPckgC<TInt64> pkPos(aPos); |
|
2702 r = SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.Length(),&pkPos)); |
|
2703 } |
|
2704 |
|
2705 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite3Return, MODULEUID, r); |
|
2706 return r; |
|
2707 } |
|
2708 |
|
2709 |
|
2710 /** |
|
2711 Writes to the file at the specified offset within the file |
|
2712 |
|
2713 This is an asynchronous function. |
|
2714 |
|
2715 This is equivalent to calling RFile::Write(TInt, TDes8&, TRequestStatus&) except |
|
2716 that this function accepts TInt64, instead of TInt, as its first parameter. |
|
2717 This allows to specify the write position beyond 2GB-1. |
|
2718 |
|
2719 @see RFile::Write(TInt aPos, TDes8& aDes, TRequestStatus& aStatus) |
|
2720 |
|
2721 |
|
2722 @param aPos The offset from the start of the file at which the first |
|
2723 byte is written. |
|
2724 If a position beyond the end of the file is specified, then |
|
2725 the write operation begins at the end of the file. |
|
2726 If the position has been locked, then the write fails. |
|
2727 |
|
2728 @param aDes The descriptor from which binary data is written. The function |
|
2729 writes the entire contents of aDes to the file. |
|
2730 NB: this function is asynchronous and the request that it |
|
2731 represents may not complete until some time after the call |
|
2732 to the function has returned. It is important, therefore, that |
|
2733 this descriptor remain valid, or remain in scope, until you have |
|
2734 been notified that the request is complete. |
|
2735 |
|
2736 @param aStatus Request status. On completion contains KErrNone if successful, |
|
2737 otherwise one of the other system-wide error codes. |
|
2738 |
|
2739 @panic FSCLIENT 19 if aPos is negative. |
|
2740 */ |
|
2741 EFSRV_EXPORT_C void RFile64::Write(TInt64 aPos, const TDesC8& aDes,TRequestStatus& aStatus) |
|
2742 { |
|
2743 TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileWrite4, MODULEUID, Session().Handle(), SubSessionHandle(), aDes.Length(), &aStatus); |
|
2744 |
|
2745 __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); |
|
2746 |
|
2747 if (!(I64HIGH(aPos+1))) |
|
2748 { |
|
2749 RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),I64LOW(aPos)),aStatus); |
|
2750 } |
|
2751 else |
|
2752 { |
|
2753 TPckgC<TInt64> pkPos(aPos); |
|
2754 RSubSessionBase::SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.Length(),&pkPos),aStatus); |
|
2755 } |
|
2756 |
|
2757 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite4Return, MODULEUID); |
|
2758 } |
|
2759 |
|
2760 |
|
2761 /** |
|
2762 Writes the specified number of bytes to the file at the specified offset within the file. |
|
2763 |
|
2764 This is a synchronous function. |
|
2765 |
|
2766 This is equivalent to calling RFile::Write(TInt, TDes8&, TInt) except |
|
2767 that this function accepts TInt64, instead of TInt, as its first parameter. |
|
2768 This allows to specify the write position beyond 2GB-1. |
|
2769 |
|
2770 @see RFile::Write(TInt aPos, TDes8& aDes, TInt aLength) |
|
2771 |
|
2772 @param aPos The offset from the start of the file at which the first |
|
2773 byte is written. |
|
2774 If a position beyond the end of the file is specified, then |
|
2775 the write operation begins at the end of the file. |
|
2776 If the position has been locked, then the write fails. |
|
2777 |
|
2778 @param aDes The descriptor from which binary data is written. |
|
2779 @param aLength The number of bytes to be written from aDes . |
|
2780 It must not be negative. |
|
2781 |
|
2782 @return KErrNone if successful; KErrArgument if aLength is negative; |
|
2783 otherwise one of the other system-wide error codes. |
|
2784 |
|
2785 @panic FSCLIENT 19 if aPos is negative. |
|
2786 */ |
|
2787 EFSRV_EXPORT_C TInt RFile64::Write(TInt64 aPos, const TDesC8& aDes,TInt aLength) |
|
2788 { |
|
2789 TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1, MODULEUID, Session().Handle(), SubSessionHandle(), aLength); |
|
2790 |
|
2791 __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); |
|
2792 |
|
2793 TInt r; |
|
2794 if (!(I64HIGH(aPos+1))) |
|
2795 { |
|
2796 r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,I64LOW(aPos))); |
|
2797 } |
|
2798 else |
|
2799 { |
|
2800 TPckgC<TInt64> pkPos(aPos); |
|
2801 r = SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos)); |
|
2802 } |
|
2803 |
|
2804 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1Return, MODULEUID, r); |
|
2805 return r; |
|
2806 } |
|
2807 |
|
2808 |
|
2809 /** |
|
2810 Writes the specified number of bytes to the file at the specified offset within the file. |
|
2811 |
|
2812 This is an asynchronous function. |
|
2813 |
|
2814 This is equivalent to calling RFile::Write(TInt, TDes8&, TInt, TRequestStatus&) except |
|
2815 that this function accepts TInt64, instead of TInt, as its first parameter. |
|
2816 This allows to specify the write position beyond 2GB-1. |
|
2817 |
|
2818 @see RFile::Write(TInt aPos, TDes8& aDes, TInt aLength, TRequestStatus &aStatus) |
|
2819 |
|
2820 @param aPos The offset from the start of the file at which the first |
|
2821 byte is written. |
|
2822 If a position beyond the end of the file is specified, then |
|
2823 the write operation begins at the end of the file. |
|
2824 If the position has been locked, then the write fails. |
|
2825 |
|
2826 @param aDes The descriptor from which binary data is written. |
|
2827 NB: this function is asynchronous and the request that it |
|
2828 represents may not complete until some time after the call |
|
2829 to the function has returned. It is important, therefore, that |
|
2830 this descriptor remain valid, or remain in scope, until you have |
|
2831 been notified that the request is complete. |
|
2832 |
|
2833 @param aLength The number of bytes to be written from aDes. |
|
2834 It must not be negative. |
|
2835 |
|
2836 @param aStatus Request status. On completion contains KErrNone if successful; |
|
2837 KErrArgument if aLength is negative; |
|
2838 otherwise one of the other system-wide error codes. |
|
2839 |
|
2840 @panic FSCLIENT 19 if aPos is negative. |
|
2841 */ |
|
2842 EFSRV_EXPORT_C void RFile64::Write(TInt64 aPos, const TDesC8& aDes,TInt aLength,TRequestStatus& aStatus) |
|
2843 { |
|
2844 TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aLength, &aStatus); |
|
2845 |
|
2846 __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); |
|
2847 |
|
2848 if (!(I64HIGH(aPos+1))) |
|
2849 { |
|
2850 RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,I64LOW(aPos)),aStatus); |
|
2851 } |
|
2852 else |
|
2853 { |
|
2854 TPckgC<TInt64> pkPos(aPos); |
|
2855 RSubSessionBase::SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos),aStatus); |
|
2856 } |
|
2857 |
|
2858 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2Return, MODULEUID); |
|
2859 } |
|
2860 |
|
2861 |
|
2862 /** |
|
2863 Sets the the current file position. |
|
2864 |
|
2865 The function can also be used to get the current file |
|
2866 position without changing it. The file position is the position at which |
|
2867 reading and writing takes place. The start of the file is position zero. |
|
2868 |
|
2869 To retrieve the current file position without changing it, specify ESeekCurrent |
|
2870 for the seek mode, and zero for the offset. |
|
2871 |
|
2872 This is equivalent to calling RFile::Seek except that this function accepts |
|
2873 a reference to TInt64, instead of TInt, as its second parameter. |
|
2874 This allows to seek to positions beyond 2GB-1. |
|
2875 |
|
2876 @see RFile::Seek() |
|
2877 |
|
2878 If the seek mode is ESeekStart, then: |
|
2879 |
|
2880 1. the function does not modify the aPos argument, |
|
2881 |
|
2882 2. the function returns an error if the offset specified is negative. |
|
2883 |
|
2884 If the seek mode is ESeekAddress, an error is returned if: |
|
2885 |
|
2886 1. the file is not in ROM, |
|
2887 |
|
2888 2. the offset specified is greater than the size of the file. |
|
2889 |
|
2890 @param aMode Seek mode. Controls the destination of the seek operation. |
|
2891 @param aPos Offset from location specified in aMode. Can be negative. |
|
2892 On return contains the new file position. |
|
2893 If the seek mode is either ESeekCurrent or ESeekEnd and the offset |
|
2894 specifies a position before the start of the file |
|
2895 or beyond the end of the file, then on return, aPos is set to |
|
2896 the new file position (either the start or the end of the file). |
|
2897 If the seek mode is ESeekAddress, aPos returns the address of |
|
2898 the byte at the specified offset within the file. |
|
2899 |
|
2900 @return KErrNone if successful, otherwise one of the other system-wide error |
|
2901 codes. |
|
2902 */ |
|
2903 EFSRV_EXPORT_C TInt RFile64::Seek(TSeek aMode, TInt64& aPos) const |
|
2904 { |
|
2905 TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileSeek, MODULEUID, Session().Handle(), SubSessionHandle(), aMode, aPos, 0); |
|
2906 |
|
2907 TPckgC<TInt64> pkOffset(aPos); |
|
2908 TPckg<TInt64> pkNewPos(aPos); |
|
2909 TInt r = SendReceive(EFsFileSeek|KIpcArgSlot0Desc|KIpcArgSlot2Desc,TIpcArgs(&pkOffset,aMode,&pkNewPos)); |
|
2910 |
|
2911 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileSeekReturn, MODULEUID, r); |
|
2912 return r; |
|
2913 } |
|
2914 |
|
2915 |
|
2916 /** |
|
2917 Gets the current file size. |
|
2918 |
|
2919 This is equivalent to calling RFile::Size except that this function accepts |
|
2920 a reference to TInt64, instead of TInt, as its first parameter. |
|
2921 This allows to query file sizes, which are greater than 2GB-1 |
|
2922 |
|
2923 @see RFile::Size() |
|
2924 |
|
2925 |
|
2926 @param aSize On return, the size of the file in bytes. |
|
2927 |
|
2928 @return KErrNone if successful, otherwise one of the other system-wide error |
|
2929 codes. |
|
2930 */ |
|
2931 EFSRV_EXPORT_C TInt RFile64::Size(TInt64& aSize) const |
|
2932 { |
|
2933 TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileSize2, MODULEUID, Session().Handle(), SubSessionHandle()); |
|
2934 |
|
2935 TPckg<TInt64> pkSize(aSize); |
|
2936 TInt r = SendReceive(EFsFileSize|KIpcArgSlot0Desc,TIpcArgs(&pkSize)); |
|
2937 |
|
2938 TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileSize2Return, MODULEUID, r, I64LOW(aSize), I64HIGH(aSize)); |
|
2939 return r; |
|
2940 } |
|
2941 |
|
2942 |
|
2943 /** |
|
2944 Sets the file size. |
|
2945 |
|
2946 If the size of the file is reduced, data may be lost from |
|
2947 the end of the file. |
|
2948 |
|
2949 This is equivalent to calling RFile::SetSize except that this function accepts |
|
2950 a reference to TInt64, instead of TInt, as its first parameter. |
|
2951 This allows to set file sizes to greater than 2GB-1 |
|
2952 |
|
2953 @see RFile::SetSize() |
|
2954 |
|
2955 |
|
2956 Note: |
|
2957 |
|
2958 1. The current file position remains unchanged unless SetSize() reduces the size |
|
2959 of the file in such a way that the current file position is now beyond |
|
2960 the end of the file. In this case, the current file position is set to |
|
2961 the end of file. |
|
2962 |
|
2963 2. If the file was not opened for writing, an error is returned. |
|
2964 |
|
2965 @param aSize The new size of the file, in bytes. This value must not be negative, otherwise the function raises a panic. |
|
2966 |
|
2967 @return KErrNone if successful, otherwise one of the other system-wide error |
|
2968 codes. |
|
2969 |
|
2970 @panic FSCLIENT 20 If aSize is negative. |
|
2971 */ |
|
2972 EFSRV_EXPORT_C TInt RFile64::SetSize(TInt64 aSize) |
|
2973 { |
|
2974 TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileSetSize, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aSize), I64HIGH(aSize)); |
|
2975 |
|
2976 TPckgC<TInt64> pkSize(aSize); |
|
2977 TInt r = SendReceive(EFsFileSetSize|KIpcArgSlot0Desc, TIpcArgs(&pkSize)); |
|
2978 |
|
2979 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileSetSizeReturn, MODULEUID, r); |
|
2980 return r; |
|
2981 } |
|
2982 |
|
2983 |
|
2984 /** |
|
2985 Locks a region within the file as defined by a range of bytes. |
|
2986 |
|
2987 This ensures that those bytes are accessible |
|
2988 only through the RFile object which claims the lock. To re-allow access by |
|
2989 other programs to the locked region, it must either be unlocked or the file |
|
2990 closed. Locking can be used to synchronize operations on a file when more |
|
2991 than one program has access to the file in EFileShareAny mode. |
|
2992 |
|
2993 More than one distinct region of a file can be locked, but an error is returned |
|
2994 if more than one lock is placed on the same region. Different RFile objects |
|
2995 can lock different parts of the same file as long as the file is opened in |
|
2996 EFileShareAny mode. The locked region may extend beyond the end of a file; |
|
2997 this prevents the file from being extended by other programs. |
|
2998 |
|
2999 This is equivalent to calling RFile::Lock except that this function accepts |
|
3000 TInt64 parameters instead of TInt parameters. |
|
3001 This allows to to lock positions in file beyond 2GB-1. |
|
3002 |
|
3003 @see RFile::Lock() |
|
3004 |
|
3005 @param aPos Position in file from which to lock; this is the offset from |
|
3006 the beginning of the file. |
|
3007 @param aLength Number of bytes to lock. |
|
3008 |
|
3009 @return KErrNone if successful, otherwise one of the other system-wide error |
|
3010 codes. |
|
3011 |
|
3012 @panic FSCLIENT 17 if aLength is not greater than zero, |
|
3013 */ |
|
3014 EFSRV_EXPORT_C TInt RFile64::Lock(TInt64 aPos, TInt64 aLength) const |
|
3015 { |
|
3016 TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileLock, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aLength); |
|
3017 |
|
3018 __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); |
|
3019 TPckgC<TInt64> pkPos(aPos); |
|
3020 TPckgC<TInt64> pkLength(aLength); |
|
3021 |
|
3022 TInt r; |
|
3023 |
|
3024 if(aPos <= KMaxTInt && aLength <= KMaxTInt) |
|
3025 r = SendReceive(EFsFileLock,TIpcArgs(I64LOW(aPos), I64LOW(aLength))); |
|
3026 else if(aPos <= KMaxTInt) |
|
3027 r = SendReceive(EFsFileLock|KIpcArgSlot1Desc,TIpcArgs(I64LOW(aPos), &pkLength)); |
|
3028 else if(aLength <= KMaxTInt) |
|
3029 r = SendReceive(EFsFileLock|KIpcArgSlot0Desc,TIpcArgs(&pkPos, I64LOW(aLength))); |
|
3030 else |
|
3031 r = SendReceive(EFsFileLock|KIpcArgSlot0Desc|KIpcArgSlot1Desc,TIpcArgs(&pkPos, &pkLength)); |
|
3032 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileLockReturn, MODULEUID, r); |
|
3033 return r; |
|
3034 } |
|
3035 |
|
3036 |
|
3037 /** |
|
3038 Unlocks a region within the file as defined by a range of bytes. |
|
3039 |
|
3040 A lock can only be removed by the RFile object which claimed the lock. |
|
3041 |
|
3042 A portion of a locked region cannot be unlocked. The entire locked region |
|
3043 must be unlocked otherwise an error is returned. If any byte within |
|
3044 the specified range of bytes to unlock is not locked, an error is returned. |
|
3045 |
|
3046 This is equivalent to calling RFile::UnLock except that this function accepts |
|
3047 TInt64 parameters instead of TInt parameters. |
|
3048 This allows to to unlock positions in file beyond 2GB-1. |
|
3049 |
|
3050 @see RFile::UnLock() |
|
3051 |
|
3052 @param aPos Position in file from which to unlock; this is the offset from |
|
3053 the beginning of the file. |
|
3054 @param aLength Number of bytes to unlock. |
|
3055 |
|
3056 @return KErrNone if successful, otherwise one of the other system-wide error |
|
3057 codes. |
|
3058 |
|
3059 @panic FSCLIENT 18 if aLength is not greater than zero, |
|
3060 */ |
|
3061 EFSRV_EXPORT_C TInt RFile64::UnLock(TInt64 aPos, TInt64 aLength) const |
|
3062 { |
|
3063 TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileUnLock, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aLength); |
|
3064 |
|
3065 __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); |
|
3066 |
|
3067 TPckgC<TInt64> pkPos(aPos); |
|
3068 TPckgC<TInt64> pkLength(aLength); |
|
3069 |
|
3070 TInt r; |
|
3071 |
|
3072 if(aPos <= KMaxTInt && aLength <= KMaxTInt) |
|
3073 r = SendReceive(EFsFileUnLock,TIpcArgs(I64LOW(aPos), I64LOW(aLength))); |
|
3074 else if(aPos <= KMaxTInt) |
|
3075 r = SendReceive(EFsFileUnLock|KIpcArgSlot1Desc,TIpcArgs(I64LOW(aPos), &pkLength)); |
|
3076 else if(aLength <= KMaxTInt) |
|
3077 r = SendReceive(EFsFileUnLock|KIpcArgSlot0Desc,TIpcArgs(&pkPos, I64LOW(aLength))); |
|
3078 else |
|
3079 r = SendReceive(EFsFileUnLock|KIpcArgSlot0Desc|KIpcArgSlot1Desc,TIpcArgs(&pkPos, &pkLength)); |
|
3080 |
|
3081 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileUnLockReturn, MODULEUID, r); |
|
3082 return r; |
|
3083 } |
|
3084 |
|
3085 |
|
3086 /** |
|
3087 Reads from the file at the specified offset within the file |
|
3088 |
|
3089 This is a synchronous function. |
|
3090 |
|
3091 This is equivalent to calling RFile::Read(TInt, TDes8&) or RFile64::Read(TInt64, TDes8&) |
|
3092 except that this function accepts TUint, instead of TInt or TInt64, as its first parameter. |
|
3093 |
|
3094 This function is provided for gradual migration of a client from 32-bit RFile APIs |
|
3095 to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION |
|
3096 macro. If the macro is defined, then it hides this overload, which would then throw |
|
3097 compile-time errors for any user code that uses TUint parameter for RFile64::Read. |
|
3098 |
|
3099 |
|
3100 @see RFile::Read(TInt aPos, TDes8& aDes) |
|
3101 @see RFile64::Read(TInt aPos, TDes8& aDes) |
|
3102 |
|
3103 Note that when an attempt is made to read beyond the end of the file, |
|
3104 no error is returned. |
|
3105 The descriptor's length is set to the number of bytes read into it. |
|
3106 Therefore, when reading through a file, the end of file has been reached |
|
3107 when the descriptor length, as returned by TDesC8::Length(), is zero. |
|
3108 |
|
3109 @param aPos Position of first byte to be read. This is an offset from |
|
3110 the start of the file. If no position is specified, reading |
|
3111 begins at the current file position. |
|
3112 If aPos is beyond the end of the file, the function returns |
|
3113 a zero length descriptor. |
|
3114 |
|
3115 @param aDes The descriptor into which binary data is read. Any existing content |
|
3116 is overwritten. On return, its length is set to the number of |
|
3117 bytes read. |
|
3118 |
|
3119 @return KErrNone if successful, otherwise one of the other system-wide error |
|
3120 codes. |
|
3121 |
|
3122 */ |
|
3123 EFSRV_EXPORT_C TInt RFile64::Read(TUint aPos,TDes8& aDes) const |
|
3124 { |
|
3125 TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileRead3, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.MaxLength()); |
|
3126 |
|
3127 TInt r; |
|
3128 if(!(aPos + 1)) |
|
3129 { |
|
3130 r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),aPos)); |
|
3131 } |
|
3132 else |
|
3133 { |
|
3134 TInt64 pos = aPos; |
|
3135 TPckgC<TInt64> pkPos(pos); |
|
3136 r = SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.MaxLength(),&pkPos)); |
|
3137 } |
|
3138 |
|
3139 TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead3Return, MODULEUID, r, aDes.Length()); |
|
3140 |
|
3141 return r; |
|
3142 } |
|
3143 |
|
3144 |
|
3145 /** |
|
3146 Reads from the file at the specified offset within the file. |
|
3147 |
|
3148 This is an asynchronous function. |
|
3149 |
|
3150 This is equivalent to calling RFile::Read(TInt, TDes8&, TRequestStatus&) or |
|
3151 RFile64::Read(TInt64, TDes8&, TRequestStatus&) except that this function |
|
3152 accepts TUint, instead of TInt or TInt64, as its first parameter. |
|
3153 |
|
3154 This function is provided for gradual migration of a client from 32-bit RFile APIs |
|
3155 to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION |
|
3156 macro. If the macro is defined, then it hides this overload, which would then throw |
|
3157 compile-time errors for any user code that uses TUint parameter for RFile64::Read. |
|
3158 |
|
3159 @see RFile::Read(TInt aPos, TDes8& aDes, TRequestStatus& aStatus) |
|
3160 @see RFile64::Read(TInt aPos, TDes8& aDes, TRequestStatus& aStatus) |
|
3161 |
|
3162 Note that when an attempt is made to read beyond the end of the file, |
|
3163 no error is returned. |
|
3164 The descriptor's length is set to the number of bytes read into it. |
|
3165 Therefore, when reading through a file, the end of file has been reached |
|
3166 when the descriptor length, as returned by TDesC8::Length(), is zero. |
|
3167 |
|
3168 @param aPos Position of first byte to be read. This is an offset from |
|
3169 the start of the file. If no position is specified, |
|
3170 reading begins at the current file position. |
|
3171 If aPos is beyond the end of the file, the function returns |
|
3172 a zero length descriptor. |
|
3173 |
|
3174 @param aDes The descriptor into which binary data is read. Any existing |
|
3175 content is overwritten. On return, its length is set to |
|
3176 the number of bytes read. |
|
3177 NB: this function is asynchronous and the request that it |
|
3178 represents may not complete until some time after the call |
|
3179 to the function has returned. It is important, therefore, that |
|
3180 this descriptor remain valid, or remain in scope, until you have |
|
3181 been notified that the request is complete. |
|
3182 |
|
3183 @param aStatus The request status. On completion, contains an error code of KErrNone |
|
3184 if successful, otherwise one of the other system-wide error codes. |
|
3185 |
|
3186 */ |
|
3187 EFSRV_EXPORT_C void RFile64::Read(TUint aPos,TDes8& aDes,TRequestStatus& aStatus) const |
|
3188 { |
|
3189 TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileRead4, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.MaxLength(), &aStatus); |
|
3190 |
|
3191 if(!(aPos + 1)) |
|
3192 { |
|
3193 RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),aPos),aStatus); |
|
3194 } |
|
3195 else |
|
3196 { |
|
3197 TInt64 pos = aPos; |
|
3198 TPckgC<TInt64> pkPos(pos); |
|
3199 RSubSessionBase::SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.MaxLength(),&pkPos),aStatus); |
|
3200 } |
|
3201 |
|
3202 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead4Return, MODULEUID); |
|
3203 } |
|
3204 |
|
3205 |
|
3206 /** |
|
3207 Reads the specified number of bytes of binary data from the file at a specified |
|
3208 offset within the file. |
|
3209 |
|
3210 This is a synchronous function. |
|
3211 |
|
3212 This is equivalent to calling RFile::Read(TInt, TDes8&, TInt) or |
|
3213 RFile64::Read(TInt64, TDes8&, TInt) except that this function |
|
3214 accepts TUint, instead of TInt or TInt64, as its first parameter. |
|
3215 |
|
3216 This function is provided for gradual migration of a client from 32-bit RFile APIs |
|
3217 to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION |
|
3218 macro. If the macro is defined, then it hides this overload, which would then throw |
|
3219 compile-time errors for any user code that uses TUint parameter for RFile64::Read. |
|
3220 |
|
3221 |
|
3222 @see RFile::Read(TInt aPos, TDes8& aDes,TInt aLength) |
|
3223 @see RFile64::Read(TInt aPos, TDes8& aDes,TInt aLength) |
|
3224 |
|
3225 Note that when an attempt is made to read beyond the end of the file, |
|
3226 no error is returned. |
|
3227 The descriptor's length is set to the number of bytes read into it. |
|
3228 Therefore, when reading through a file, the end of file has been reached |
|
3229 when the descriptor length, as returned by TDesC8::Length(), is zero. |
|
3230 Assuming aLength is less than the maximum length of the descriptor, the only |
|
3231 circumstances in which Read() can return fewer bytes than requested is when |
|
3232 the end of file is reached or if an error has occurred. |
|
3233 |
|
3234 @param aPos Position of first byte to be read. This is an offset from |
|
3235 the start of the file. If no position is specified, |
|
3236 reading begins at the current file position. |
|
3237 If aPos is beyond the end of the file, the function returns |
|
3238 a zero length descriptor. |
|
3239 |
|
3240 @param aDes The descriptor into which binary data is read. Any existing |
|
3241 contents are overwritten. On return, its length is set to |
|
3242 the number of bytes read. |
|
3243 @param aLength The number of bytes to read from the file into the descriptor. |
|
3244 If an attempt is made to read more bytes than the descriptor's |
|
3245 maximum length, then the function updates aStatus parameter with KErrOverflow. |
|
3246 It must not be negative otherwise the function updates aStatus with KErrArgument. |
|
3247 |
|
3248 @return KErrNone if successful, otherwise one of the other system-wide |
|
3249 error codes. |
|
3250 |
|
3251 */ |
|
3252 EFSRV_EXPORT_C TInt RFile64::Read(TUint aPos,TDes8& aDes,TInt aLength) const |
|
3253 { |
|
3254 TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileRead3, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength); |
|
3255 |
|
3256 if (aLength==0) |
|
3257 { |
|
3258 aDes.Zero(); |
|
3259 return(KErrNone); |
|
3260 } |
|
3261 else if(aLength>aDes.MaxLength()) |
|
3262 { |
|
3263 return(KErrOverflow); |
|
3264 } |
|
3265 |
|
3266 TInt r; |
|
3267 if(!(aPos + 1)) |
|
3268 { |
|
3269 r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,aPos)); |
|
3270 } |
|
3271 else |
|
3272 { |
|
3273 TInt64 pos = aPos; |
|
3274 TPckgC<TInt64> pkPos(pos); |
|
3275 r = SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos)); |
|
3276 } |
|
3277 |
|
3278 TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead3Return, MODULEUID, r, aDes.Length()); |
|
3279 |
|
3280 return r; |
|
3281 } |
|
3282 |
|
3283 |
|
3284 /** |
|
3285 Reads the specified number of bytes of binary data from the file at a specified |
|
3286 offset within the file. |
|
3287 |
|
3288 This is an asynchronous function. |
|
3289 |
|
3290 This is equivalent to calling RFile::Read(TInt, TDes8&, TInt,TRequestStatus&) or |
|
3291 RFile64::Read(TInt64, TDes8&, TInt, TRequestStatus&) except that this function |
|
3292 accepts TUint, instead of TInt or TInt64, as its first parameter. |
|
3293 |
|
3294 This function is provided for gradual migration of a client from 32-bit RFile APIs |
|
3295 to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION |
|
3296 macro. If the macro is defined, then it hides this overload, which would then throw |
|
3297 compile-time errors for any user code that uses TUint parameter for RFile64::Read. |
|
3298 |
|
3299 |
|
3300 @see RFile::Read(TInt aPos, TDes8& aDes,TInt aLength,TRequestStatus& aStatus) |
|
3301 @see RFile64::Read(TInt aPos, TDes8& aDes,TInt aLength,TRequestStatus& aStatus) |
|
3302 |
|
3303 Note that when an attempt is made to read beyond the end of the file, |
|
3304 no error is returned. |
|
3305 The descriptor's length is set to the number of bytes read into it. |
|
3306 Therefore, when reading through a file, the end of file has been reached |
|
3307 when the descriptor length, as returned by TDesC8::Length(), is zero. |
|
3308 Assuming aLength is less than the maximum length of the descriptor, the only |
|
3309 circumstances in which Read() can return fewer bytes than requested is when |
|
3310 the end of file is reached or if an error has occurred. |
|
3311 |
|
3312 @param aPos Position of first byte to be read. This is an offset from |
|
3313 the start of the file. If no position is specified, |
|
3314 reading begins at the current file position. |
|
3315 If aPos is beyond the end of the file, the function returns |
|
3316 a zero length descriptor. |
|
3317 |
|
3318 @param aDes The descriptor into which binary data is read. Any existing |
|
3319 contents are overwritten. On return, its length is set to |
|
3320 the number of bytes read. |
|
3321 NB: this function is asynchronous and the request that it |
|
3322 represents may not complete until some time after the call |
|
3323 to the function has returned. It is important, therefore, that |
|
3324 this descriptor remain valid, or remain in scope, until you have |
|
3325 been notified that the request is complete. |
|
3326 |
|
3327 @param aLength The number of bytes to read from the file into the descriptor. |
|
3328 If an attempt is made to read more bytes than the descriptor's |
|
3329 maximum length, then the function returns KErrOverflow. |
|
3330 It must not be negative otherwise the function returns KErrArgument. |
|
3331 |
|
3332 @param aStatus Request status. On completion contains KErrNone if successful, |
|
3333 otherwise one of the other system-wide error codes. |
|
3334 |
|
3335 */ |
|
3336 EFSRV_EXPORT_C void RFile64::Read(TUint aPos,TDes8& aDes,TInt aLength,TRequestStatus& aStatus) const |
|
3337 { |
|
3338 TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileRead4, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength, &aStatus); |
|
3339 |
|
3340 if (aLength==0) |
|
3341 { |
|
3342 aDes.Zero(); |
|
3343 TRequestStatus* req=(&aStatus); |
|
3344 User::RequestComplete(req,KErrNone); |
|
3345 return; |
|
3346 } |
|
3347 else if(aLength>aDes.MaxLength()) |
|
3348 { |
|
3349 TRequestStatus* req=(&aStatus); |
|
3350 User::RequestComplete(req,KErrOverflow); |
|
3351 return; |
|
3352 } |
|
3353 |
|
3354 if(!(aPos + 1)) |
|
3355 { |
|
3356 RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,aPos),aStatus); |
|
3357 } |
|
3358 else |
|
3359 { |
|
3360 TInt64 pos = aPos; |
|
3361 TPckgC<TInt64> pkPos(pos); |
|
3362 RSubSessionBase::SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos),aStatus); |
|
3363 } |
|
3364 |
|
3365 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead4Return, MODULEUID); |
|
3366 } |
|
3367 |
|
3368 |
|
3369 /** |
|
3370 Writes to the file at the specified offset within the file |
|
3371 |
|
3372 This is a synchronous function. |
|
3373 |
|
3374 This is equivalent to calling RFile::Write(TInt, TDes8&) or |
|
3375 RFile64::Write(TInt64, TDes8&) except that this function |
|
3376 accepts TUint, instead of TInt or TInt64, as its first parameter. |
|
3377 |
|
3378 This function is provided for gradual migration of a client from 32-bit RFile APIs |
|
3379 to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION |
|
3380 macro. If the macro is defined, then it hides this overload, which would then throw |
|
3381 compile-time errors for any user code that uses TUint parameter for RFile64::Read. |
|
3382 |
|
3383 |
|
3384 @see RFile::Write(TInt aPos, TDes8& aDes) |
|
3385 @see RFile64::Write(TInt aPos, TDes8& aDes) |
|
3386 |
|
3387 |
|
3388 @param aPos The offset from the start of the file at which the first |
|
3389 byte is written. |
|
3390 If a position beyond the end of the file is specified, then |
|
3391 the write operation begins at the end of the file. |
|
3392 If the position has been locked, then the write fails. |
|
3393 |
|
3394 @param aDes The descriptor from which binary data is written. The function writes |
|
3395 the entire contents of aDes to the file. |
|
3396 |
|
3397 @return KErrNone if successful, otherwise one of the other system-wide error |
|
3398 codes. |
|
3399 |
|
3400 */ |
|
3401 EFSRV_EXPORT_C TInt RFile64::Write(TUint aPos,const TDesC8& aDes) |
|
3402 { |
|
3403 TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileWrite3, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.Length()); |
|
3404 |
|
3405 TInt r; |
|
3406 if(!(aPos + 1)) |
|
3407 { |
|
3408 r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),aPos)); |
|
3409 } |
|
3410 else |
|
3411 { |
|
3412 TInt64 pos = aPos; |
|
3413 TPckgC<TInt64> pkPos(pos); |
|
3414 r = SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.Length(),&pkPos)); |
|
3415 } |
|
3416 |
|
3417 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite3Return, MODULEUID, r); |
|
3418 return r; |
|
3419 } |
|
3420 |
|
3421 |
|
3422 /** |
|
3423 Writes to the file at the specified offset within the file |
|
3424 |
|
3425 This is an asynchronous function. |
|
3426 |
|
3427 This is equivalent to calling RFile::Write(TInt, TDes8&,TRequestStatus&) or |
|
3428 RFile64::Write(TInt64, TDes8&,TRequestStatus&) except that this function |
|
3429 accepts TUint, instead of TInt or TInt64, as its first parameter. |
|
3430 |
|
3431 This function is provided for gradual migration of a client from 32-bit RFile APIs |
|
3432 to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION |
|
3433 macro. If the macro is defined, then it hides this overload, which would then throw |
|
3434 compile-time errors for any user code that uses TUint parameter for RFile64::Read. |
|
3435 |
|
3436 |
|
3437 @see RFile::Write(TInt aPos, TDes8& aDes,TRequestStatus& aStatus) |
|
3438 @see RFile64::Write(TInt aPos, TDes8& aDes,TRequestStatus& aStatus) |
|
3439 |
|
3440 |
|
3441 @param aPos The offset from the start of the file at which the first |
|
3442 byte is written. |
|
3443 If a position beyond the end of the file is specified, then |
|
3444 the write operation begins at the end of the file. |
|
3445 If the position has been locked, then the write fails. |
|
3446 |
|
3447 @param aDes The descriptor from which binary data is written. The function |
|
3448 writes the entire contents of aDes to the file. |
|
3449 NB: this function is asynchronous and the request that it |
|
3450 represents may not complete until some time after the call |
|
3451 to the function has returned. It is important, therefore, that |
|
3452 this descriptor remain valid, or remain in scope, until you have |
|
3453 been notified that the request is complete. |
|
3454 |
|
3455 @param aStatus Request status. On completion contains KErrNone if successful, |
|
3456 otherwise one of the other system-wide error codes. |
|
3457 |
|
3458 */ |
|
3459 EFSRV_EXPORT_C void RFile64::Write(TUint aPos,const TDesC8& aDes,TRequestStatus& aStatus) |
|
3460 { |
|
3461 TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileWrite4, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.Length(), &aStatus); |
|
3462 |
|
3463 if(!(aPos + 1)) |
|
3464 { |
|
3465 RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),aPos),aStatus); |
|
3466 } |
|
3467 else |
|
3468 { |
|
3469 TInt64 pos = aPos; |
|
3470 TPckgC<TInt64> pkPos(pos); |
|
3471 RSubSessionBase::SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.Length(),&pkPos),aStatus); |
|
3472 } |
|
3473 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite4Return, MODULEUID); |
|
3474 } |
|
3475 |
|
3476 |
|
3477 /** |
|
3478 Writes the specified number of bytes to the file at the specified offset within the file. |
|
3479 |
|
3480 This is a synchronous function. |
|
3481 |
|
3482 This is equivalent to calling RFile::Write(TInt, TDes8&,TInt) or |
|
3483 RFile64::Write(TInt64, TDes8&,TInt) except that this function |
|
3484 accepts TUint, instead of TInt or TInt64, as its first parameter. |
|
3485 |
|
3486 This function is provided for gradual migration of a client from 32-bit RFile APIs |
|
3487 to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION |
|
3488 macro. If the macro is defined, then it hides this overload, which would then throw |
|
3489 compile-time errors for any user code that uses TUint parameter for RFile64::Read. |
|
3490 |
|
3491 |
|
3492 @see RFile::Write(TInt aPos, TDes8& aDes,TInt aLength) |
|
3493 @see RFile64::Write(TInt aPos, TDes8& aDes,TInt aLength) |
|
3494 |
|
3495 @param aPos The offset from the start of the file at which the first |
|
3496 byte is written. |
|
3497 If a position beyond the end of the file is specified, then |
|
3498 the write operation begins at the end of the file. |
|
3499 If the position has been locked, then the write fails. |
|
3500 |
|
3501 @param aDes The descriptor from which binary data is written. |
|
3502 @param aLength The number of bytes to be written from aDes . |
|
3503 It must not be negative. |
|
3504 |
|
3505 @return KErrNone if successful; KErrArgument if aLength is negative; |
|
3506 otherwise one of the other system-wide error codes. |
|
3507 |
|
3508 */ |
|
3509 EFSRV_EXPORT_C TInt RFile64::Write(TUint aPos,const TDesC8& aDes,TInt aLength) |
|
3510 { |
|
3511 TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1, MODULEUID, Session().Handle(), SubSessionHandle(), aLength); |
|
3512 |
|
3513 TInt r; |
|
3514 if(!(aPos + 1)) |
|
3515 { |
|
3516 r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,aPos)); |
|
3517 } |
|
3518 else |
|
3519 { |
|
3520 TInt64 pos = aPos; |
|
3521 TPckgC<TInt64> pkPos(pos); |
|
3522 r = SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos)); |
|
3523 } |
|
3524 |
|
3525 TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1Return, MODULEUID, r); |
|
3526 return r; |
|
3527 } |
|
3528 |
|
3529 |
|
3530 /** |
|
3531 Writes the specified number of bytes to the file at the specified offset within the file. |
|
3532 |
|
3533 This is an asynchronous function. |
|
3534 |
|
3535 This is equivalent to calling RFile::Write(TInt, TDes8&,TInt,TRequestStatus&) or |
|
3536 RFile64::Write(TInt64, TDes8&,TInt,TRequestStatus&) except that this function |
|
3537 accepts TUint, instead of TInt or TInt64, as its first parameter. |
|
3538 |
|
3539 This function is provided for gradual migration of a client from 32-bit RFile APIs |
|
3540 to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION |
|
3541 macro. If the macro is defined, then it hides this overload, which would then throw |
|
3542 compile-time errors for any user code that uses TUint parameter for RFile64::Read. |
|
3543 |
|
3544 |
|
3545 @see RFile::Write(TInt aPos, TDes8& aDes, TInt aLength, TRequestStatus& aStatus) |
|
3546 @see RFile64::Write(TInt aPos, TDes8& aDes,TInt aLength, TRequestStatus& aStatus) |
|
3547 |
|
3548 |
|
3549 @param aPos The offset from the start of the file at which the first |
|
3550 byte is written. |
|
3551 If a position beyond the end of the file is specified, then |
|
3552 the write operation begins at the end of the file. |
|
3553 If the position has been locked, then the write fails. |
|
3554 |
|
3555 @param aDes The descriptor from which binary data is written. |
|
3556 NB: this function is asynchronous and the request that it |
|
3557 represents may not complete until some time after the call |
|
3558 to the function has returned. It is important, therefore, that |
|
3559 this descriptor remain valid, or remain in scope, until you have |
|
3560 been notified that the request is complete. |
|
3561 |
|
3562 @param aLength The number of bytes to be written from aDes. |
|
3563 It must not be negative. |
|
3564 |
|
3565 @param aStatus Request status. On completion contains KErrNone if successful; |
|
3566 KErrArgument if aLength is negative; |
|
3567 otherwise one of the other system-wide error codes. |
|
3568 |
|
3569 */ |
|
3570 EFSRV_EXPORT_C void RFile64::Write(TUint aPos,const TDesC8& aDes,TInt aLength,TRequestStatus& aStatus) |
|
3571 { |
|
3572 TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength, &aStatus); |
|
3573 |
|
3574 if(!(aPos + 1)) |
|
3575 { |
|
3576 RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,aPos),aStatus); |
|
3577 } |
|
3578 else |
|
3579 { |
|
3580 TInt64 pos = aPos; |
|
3581 TPckgC<TInt64> pkPos(pos); |
|
3582 RSubSessionBase::SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos),aStatus); |
|
3583 } |
|
3584 TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2Return, MODULEUID); |
|
3585 } |
|
3586 #else |
|
3587 EFSRV_EXPORT_C TInt RFile64::Open(RFs& /*aFs*/,const TDesC& /*aName*/,TUint /*aFileMode*/) |
|
3588 {Panic(ENotImplemented);return (KErrNotSupported);} |
|
3589 EFSRV_EXPORT_C TInt RFile64::Create(RFs& /*aFs*/,const TDesC& /*aName*/,TUint /*aFileMode*/) |
|
3590 {Panic(ENotImplemented);return (KErrNotSupported);} |
|
3591 EFSRV_EXPORT_C TInt RFile64::Replace(RFs& /*aFs*/,const TDesC& /*aName*/,TUint /*aFileMode*/) |
|
3592 {Panic(ENotImplemented);return (KErrNotSupported);} |
|
3593 EFSRV_EXPORT_C TInt RFile64::Temp(RFs& /*aFs*/,const TDesC& /*aPath*/,TFileName& /*aName*/,TUint /*aFileMode*/) |
|
3594 {Panic(ENotImplemented);return (KErrNotSupported);} |
|
3595 EFSRV_EXPORT_C TInt RFile64::AdoptFromClient(const RMessage2& /*aMsg*/, TInt /*aFsHandleIndex*/, TInt /*aFileHandleIndex*/) |
|
3596 {Panic(ENotImplemented);return (KErrNotSupported);} |
|
3597 EFSRV_EXPORT_C TInt RFile64::AdoptFromServer(TInt /*aFsHandle*/, TInt /*aFileHandle*/) |
|
3598 {Panic(ENotImplemented);return (KErrNotSupported);} |
|
3599 EFSRV_EXPORT_C TInt RFile64::AdoptFromCreator(TInt /*aFsHandleIndex*/, TInt /*aFileHandleIndex*/) |
|
3600 {Panic(ENotImplemented);return (KErrNotSupported);} |
|
3601 EFSRV_EXPORT_C TInt RFile64::Read(TInt64 /*aPos*/, TDes8& /*aDes*/) const |
|
3602 {Panic(ENotImplemented);return (KErrNotSupported);} |
|
3603 EFSRV_EXPORT_C void RFile64::Read(TInt64 /*aPos*/, TDes8& /*aDes*/, TRequestStatus& /*aStatus*/) const |
|
3604 {Panic(ENotImplemented);} |
|
3605 EFSRV_EXPORT_C TInt RFile64::Read(TInt64 /*aPos*/, TDes8& /*aDes*/, TInt /*aLength*/) const |
|
3606 {Panic(ENotImplemented);return (KErrNotSupported);} |
|
3607 EFSRV_EXPORT_C void RFile64::Read(TInt64 /*aPos*/, TDes8& /*aDes*/, TInt /*aLength*/,TRequestStatus& /*aStatus*/) const |
|
3608 {Panic(ENotImplemented);} |
|
3609 EFSRV_EXPORT_C TInt RFile64::Write(TInt64 /*aPos*/, const TDesC8& /*aDes*/) |
|
3610 {Panic(ENotImplemented);return (KErrNotSupported);} |
|
3611 EFSRV_EXPORT_C void RFile64::Write(TInt64 /*aPos*/, const TDesC8& /*aDes*/,TRequestStatus& /*aStatus*/) |
|
3612 {Panic(ENotImplemented);} |
|
3613 EFSRV_EXPORT_C TInt RFile64::Write(TInt64 /*aPos*/, const TDesC8& /*aDes*/, TInt /*aLength*/) |
|
3614 {Panic(ENotImplemented);return (KErrNotSupported);} |
|
3615 EFSRV_EXPORT_C void RFile64::Write(TInt64 /*aPos*/, const TDesC8& /*aDes*/,TInt /*aLength*/,TRequestStatus& /*aStatus*/) |
|
3616 {Panic(ENotImplemented);} |
|
3617 EFSRV_EXPORT_C TInt RFile64::Seek(TSeek /*aMode*/, TInt64& /*aPos*/) const |
|
3618 {Panic(ENotImplemented);return (KErrNotSupported);} |
|
3619 EFSRV_EXPORT_C TInt RFile64::Size(TInt64& /*aSize*/) const |
|
3620 {Panic(ENotImplemented);return (KErrNotSupported);} |
|
3621 EFSRV_EXPORT_C TInt RFile64::SetSize(TInt64 /*aSize*/) |
|
3622 {Panic(ENotImplemented);return (KErrNotSupported);} |
|
3623 EFSRV_EXPORT_C TInt RFile64::Lock(TInt64 /*aPos*/, TInt64 /*aLength*/) const |
|
3624 {Panic(ENotImplemented);return (KErrNotSupported);} |
|
3625 EFSRV_EXPORT_C TInt RFile64::UnLock(TInt64 /*aPos*/, TInt64 /*aLength*/) const |
|
3626 {Panic(ENotImplemented);return (KErrNotSupported);} |
|
3627 EFSRV_EXPORT_C TInt RFile64::Read(TUint /*aPos*/,TDes8& /*aDes*/) const |
|
3628 {Panic(ENotImplemented);return (KErrNotSupported);} |
|
3629 EFSRV_EXPORT_C void RFile64::Read(TUint /*aPos*/,TDes8& /*aDes*/,TRequestStatus& /*aStatus*/) const |
|
3630 {Panic(ENotImplemented);} |
|
3631 EFSRV_EXPORT_C TInt RFile64::Read(TUint /*aPos*/,TDes8& /*aDes*/,TInt /*aLength*/) const |
|
3632 {Panic(ENotImplemented);return (KErrNotSupported);} |
|
3633 EFSRV_EXPORT_C void RFile64::Read(TUint /*aPos*/,TDes8& /*aDes*/,TInt /*aLength*/,TRequestStatus& /*aStatus*/) const |
|
3634 {Panic(ENotImplemented);} |
|
3635 EFSRV_EXPORT_C TInt RFile64::Write(TUint /*aPos*/,const TDesC8& /*aDes*/) |
|
3636 {Panic(ENotImplemented);return (KErrNotSupported);} |
|
3637 EFSRV_EXPORT_C void RFile64::Write(TUint /*aPos*/,const TDesC8& /*aDes*/,TRequestStatus& /*aStatus*/) |
|
3638 {Panic(ENotImplemented);} |
|
3639 EFSRV_EXPORT_C TInt RFile64::Write(TUint /*aPos*/,const TDesC8& /*aDes*/,TInt /*aLength*/) |
|
3640 {Panic(ENotImplemented);return (KErrNotSupported);} |
|
3641 EFSRV_EXPORT_C void RFile64::Write(TUint /*aPos*/, const TDesC8& /*aDes*/,TInt /*aLength*/,TRequestStatus& /*aStatus*/) |
|
3642 {Panic(ENotImplemented);} |
|
3643 #endif |