1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/sfsrv/cl_file.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,3643 @@
1.4 +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// f32\sfsrv\cl_file.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +#include "cl_std.h"
1.22 +
1.23 +static _LIT_SECURITY_POLICY_S1(KFileServerPolicy,KFileServerUidValue,ECapabilityTCB);
1.24 +
1.25 +EFSRV_EXPORT_C TInt RFile::Adopt(RFs& aFs, TInt aHandle)
1.26 +/**
1.27 +Adopts an already open file.
1.28 +
1.29 +@param aFs The file server session.
1.30 +@param aHandle The handle number of the already opened file
1.31 +
1.32 +@return KErrNone if successful,
1.33 + KErrBadHandle if the sub-session handle is invalid,
1.34 + otherwise one of the other system-wide error codes.
1.35 +
1.36 +@deprecated
1.37 +*/
1.38 + {
1.39 +
1.40 + TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileAdopt, MODULEUID, aFs.Handle(), aHandle);
1.41 +
1.42 + // duplicate the sub-session handle; don't panic if it's invalid.
1.43 + RFile file;
1.44 + TInt r = file.CreateSubSession(aFs, EFsFileDuplicate, TIpcArgs(aHandle, EFalse));
1.45 + if (r == KErrArgument)
1.46 + {
1.47 + TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptReturn, MODULEUID, KErrBadHandle);
1.48 + return KErrBadHandle;
1.49 + }
1.50 + else if (r != KErrNone)
1.51 + {
1.52 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptReturn, MODULEUID, r);
1.53 + return r;
1.54 + }
1.55 + // adopt the duplicated handle
1.56 + r = CreateAutoCloseSubSession(aFs, EFsFileAdopt, TIpcArgs(file.SubSessionHandle(), KFileAdopt32));
1.57 +
1.58 + TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptReturn, MODULEUID, r, Session().Handle(), SubSessionHandle());
1.59 +
1.60 + return r;
1.61 + }
1.62 +
1.63 +
1.64 +
1.65 +
1.66 +EFSRV_EXPORT_C TInt RFile::AdoptFromServer(TInt aFsHandle, TInt aFileHandle)
1.67 +/**
1.68 +Allows a client to adopt an already open file from a server.
1.69 +
1.70 +Assumes that the server's RFs and RFile handles have been sent to the
1.71 +client using TransferToClient().
1.72 +
1.73 +This RFile will own it's RFs session so that when the sub-session (RFile)
1.74 +is closed so will the RFs session.
1.75 +
1.76 +@param aFsHandle The file server session (RFs) handle
1.77 +@param aFileHandle The file (RFile) handle of the already opened file
1.78 +
1.79 +@return KErrNone if successful, otherwise one of the other system-wide
1.80 + error codes.
1.81 +*/
1.82 + {
1.83 + TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromServer, MODULEUID, aFsHandle, aFileHandle);
1.84 +
1.85 + RFs fs;
1.86 + TInt r = fs.SetReturnedHandle(aFsHandle, KFileServerPolicy);
1.87 + if (r != KErrNone)
1.88 + {
1.89 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromServerReturn, MODULEUID, r);
1.90 + return r;
1.91 + }
1.92 + r = CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(aFileHandle, KFileAdopt32));
1.93 +
1.94 + TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromServerReturn, MODULEUID, r, Session().Handle(), SubSessionHandle());
1.95 +
1.96 + return r;
1.97 + }
1.98 +
1.99 +
1.100 +EFSRV_EXPORT_C TInt RFile::AdoptFromClient(const RMessage2& aMsg, TInt aFsHandleIndex, TInt aFileHandleIndex)
1.101 +/**
1.102 +Allows a server to adopt an already open file from a client.
1.103 +The client's RFs and RFile handles are contained in message slots within aMsg.
1.104 +
1.105 +Assumes that the client's RFs and RFile handles have been sent to the server
1.106 +using TransferToServer().
1.107 +
1.108 +
1.109 +This RFile will own it's RFs session so that when the sub-session (RFile)
1.110 +is closed so will the RFs session.
1.111 +
1.112 +@param aMsg The message received from the client
1.113 +@param aFsHandleIndex The index that identifies the message slot
1.114 + of a file server session (RFs) handle
1.115 +@param aFileHandleIndex The index that identifies the message slot
1.116 + of the sub-session (RFile) handle of the already opened file
1.117 +
1.118 +@return KErrNone if successful, otherwise one of the other system-wide
1.119 + error codes.
1.120 +*/
1.121 + {
1.122 + TInt fileHandle = NULL;
1.123 +
1.124 + TInt r = KErrNone;
1.125 + if (aFileHandleIndex == 0)
1.126 + fileHandle = aMsg.Int0();
1.127 + else if (aFileHandleIndex == 1)
1.128 + fileHandle = aMsg.Int1();
1.129 + else if (aFileHandleIndex == 2)
1.130 + fileHandle = aMsg.Int2();
1.131 + else if (aFileHandleIndex == 3)
1.132 + fileHandle = aMsg.Int3();
1.133 + else
1.134 + r = KErrArgument;
1.135 +
1.136 +#ifdef SYMBIAN_FTRACE_ENABLE
1.137 + TInt handle = NULL;
1.138 + if (aFsHandleIndex == 0)
1.139 + handle = aMsg.Int0();
1.140 + else if (aFsHandleIndex == 1)
1.141 + handle = aMsg.Int1();
1.142 + else if (aFsHandleIndex == 2)
1.143 + handle = aMsg.Int2();
1.144 + else if (aFsHandleIndex == 3)
1.145 + handle = aMsg.Int3();
1.146 + TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClient, MODULEUID, handle, fileHandle, aFsHandleIndex, aFileHandleIndex);
1.147 +#endif
1.148 +
1.149 + if (r != KErrNone)
1.150 + {
1.151 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClientReturn, MODULEUID, r);
1.152 + return r;
1.153 + }
1.154 +
1.155 + // Duplicates the file server (RFs) session handle identified by an
1.156 + // existing handle contained in the message slot at index aFsHandleIndex
1.157 + RFs fs;
1.158 + r = fs.Open(aMsg, aFsHandleIndex, KFileServerPolicy);
1.159 + if (r != KErrNone)
1.160 + {
1.161 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClientReturn, MODULEUID, r);
1.162 + return r;
1.163 + }
1.164 +
1.165 + r = CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(fileHandle, KFileAdopt32));
1.166 +
1.167 + TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClientReturn, MODULEUID, r, Session().Handle(), SubSessionHandle());
1.168 +
1.169 + return r;
1.170 + }
1.171 +
1.172 +
1.173 +EFSRV_EXPORT_C TInt RFile::AdoptFromCreator(TInt aFsHandleIndex, TInt aFileHandleIndex)
1.174 +/**
1.175 +Allows a server to adopt an already open file from a client process.
1.176 +The client's file-server (RFs) and file (RFile) handles are contained in
1.177 +this process's environment data slots.
1.178 +
1.179 +Assumes that the client's RFs and RFile handles have been sent to the server process
1.180 +using TransferToProcess().
1.181 +
1.182 +This RFile will own it's RFs session so that when the sub-session (RFile)
1.183 +is closed so will the RFs session.
1.184 +
1.185 +@param aFsHandleIndex An index that identifies the slot in the process
1.186 + environment data that contains the file server session (RFs) handle
1.187 +@param aFileHandleIndex An index that identifies the slot in the process
1.188 + environment data that contains the sub-session (RFile) handle
1.189 + of the already opened file
1.190 +
1.191 +@return KErrNone if successful, otherwise one of the other system-wide
1.192 + error codes.
1.193 +*/
1.194 + {
1.195 + TInt fileHandle = NULL;
1.196 +
1.197 + TInt r = User::GetTIntParameter(aFileHandleIndex, fileHandle);
1.198 +
1.199 + TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreator, MODULEUID, fileHandle, aFsHandleIndex, aFileHandleIndex);
1.200 +
1.201 + if (r != KErrNone)
1.202 + {
1.203 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreatorReturn, MODULEUID, r);
1.204 + return r;
1.205 + }
1.206 +
1.207 +
1.208 + // Duplicates the file server (RFs) session handle identified by an
1.209 + // existing handle contained in the environment slot at index aFsHandleIndex
1.210 + RFs fs;
1.211 + r = fs.Open(aFsHandleIndex, KFileServerPolicy);
1.212 + if (r != KErrNone)
1.213 + {
1.214 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreatorReturn, MODULEUID, r);
1.215 + return r;
1.216 + }
1.217 +
1.218 + r = CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(fileHandle, KFileAdopt32));
1.219 +
1.220 + TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreatorReturn, MODULEUID, r, Session().Handle(), SubSessionHandle());
1.221 +
1.222 + return r;
1.223 + }
1.224 +
1.225 +
1.226 +
1.227 +/**
1.228 +Make a duplicate of the passed file handle in the same thread.
1.229 +
1.230 +By default, any thread in the process can use the duplicated handle to access the
1.231 +file. However, specifying EOwnerThread as the second parameter to this function,
1.232 +means that only the creating thread can use the handle.
1.233 +
1.234 +@param aFile The file handle to duplicate
1.235 +@param aType An enumeration whose enumerators define the ownership of this
1.236 + handle. If not explicitly specified, EOwnerProcess is taken
1.237 + as default.
1.238 +
1.239 +@return one of the other system-wide error codes.
1.240 +*/
1.241 +EFSRV_EXPORT_C TInt RFile::Duplicate(const RFile& aFile, TOwnerType aType)
1.242 + {
1.243 + TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileDuplicate, MODULEUID, aFile.Session().Handle(), aFile.SubSessionHandle(), aType);
1.244 +
1.245 + RFs fs;
1.246 + fs.SetHandle(aFile.Session().Handle());
1.247 +
1.248 + // Need to make a duplicate of the session handle in the current thread,
1.249 + // otherwise closing one session will close both sub-sessions.
1.250 + TInt r = fs.Duplicate(RThread(), aType);
1.251 + if (r != KErrNone)
1.252 + {
1.253 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileDuplicateReturn, MODULEUID, r);
1.254 + return r;
1.255 + }
1.256 +
1.257 + // duplicate the sub-session handle
1.258 + TInt dupSubSessionHandle;
1.259 + r = aFile.DuplicateHandle(dupSubSessionHandle);
1.260 + if (r != KErrNone)
1.261 + {
1.262 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileDuplicateReturn, MODULEUID, r);
1.263 + return r;
1.264 + }
1.265 +
1.266 + // adopt the duplicated sub-session handle
1.267 + r = CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(dupSubSessionHandle, KFileDuplicate));
1.268 +
1.269 + TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileDuplicateReturn, MODULEUID, r, Session().Handle(), SubSessionHandle());
1.270 +
1.271 + return r;
1.272 + }
1.273 +
1.274 +
1.275 +// Makes a duplicate of this file (RFile) handle in the current thread and
1.276 +// returns it in aSubSessionHandle.
1.277 +// The duplicate file handle will effectively be in limbo (although still
1.278 +// owned by the session) until :
1.279 +// (1) the session handle is duplicated into another process -
1.280 +// this happens in one of : TransferToClient(), TransferToProcess() or
1.281 +// AdoptFromClient() and
1.282 +// (2) the sub-session handle is transferred to the other process - using AdoptXXX()
1.283 +//
1.284 +TInt RFile::DuplicateHandle(TInt& aSubSessionHandle) const
1.285 + {
1.286 + RFs fs;
1.287 + fs.SetHandle(Session().Handle());
1.288 + RFile file;
1.289 +
1.290 + // duplicate the sub-session handle; panic if it's invalid.
1.291 + TInt r = file.CreateSubSession(fs, EFsFileDuplicate, TIpcArgs(SubSessionHandle(), ETrue));
1.292 +
1.293 + // return the duplicated handle
1.294 + // Note that this handle needs to be adopted before it can be used
1.295 + aSubSessionHandle = file.SubSessionHandle();
1.296 +
1.297 + return r;
1.298 + }
1.299 +
1.300 +
1.301 +/**
1.302 +Transfers an already open file to a server.
1.303 +
1.304 +Before this function can be called, the file server session which owns this file handle
1.305 +must first be marked as shareable by calling RFs::ShareProtected().
1.306 +
1.307 +This function packages handle details for this file into 2 arguments of a TIpcArgs object.
1.308 +When these arguments are sent in an IPC message, the server which receives them may
1.309 +call AdoptFromClient() to open a new RFile object which refers to the same file as this.
1.310 +
1.311 +@param aIpcArgs The IPC message arguments.
1.312 +@param aFsHandleIndex An index that identifies an argument in aIpcArgs where the
1.313 + file server session handle will be stored.
1.314 + This argument must not be used for anything else otherwise the
1.315 + results will be unpredictable.
1.316 +@param aFileHandleIndex An index that identifies an argument in aIpcArgs where the
1.317 + file handle will be stored.
1.318 + This argument must not be used for anything else otherwise the
1.319 + results will be unpredictable.
1.320 +
1.321 +@return KErrNone if successful, otherwise one of the other system-wide
1.322 + error codes.
1.323 +
1.324 +*/
1.325 +EFSRV_EXPORT_C TInt RFile::TransferToServer(TIpcArgs& aIpcArgs, TInt aFsHandleIndex, TInt aFileHandleIndex) const
1.326 + {
1.327 + TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToServer, MODULEUID, Session().Handle(), SubSessionHandle(), aFsHandleIndex, aFileHandleIndex);
1.328 +
1.329 + if ((aFsHandleIndex < 0) || (aFsHandleIndex > (KMaxMessageArguments-2)))
1.330 + {
1.331 + TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToServerReturn, MODULEUID, (TUint) KErrArgument);
1.332 + return KErrArgument;
1.333 + }
1.334 +
1.335 + TInt dupSubSessionHandle;
1.336 + TInt r = DuplicateHandle(dupSubSessionHandle);
1.337 + if (r == KErrNone)
1.338 + {
1.339 + aIpcArgs.Set(aFsHandleIndex, Session());
1.340 + aIpcArgs.Set(aFileHandleIndex, dupSubSessionHandle);
1.341 + }
1.342 +
1.343 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToServerReturn, MODULEUID, r);
1.344 + return r;
1.345 + }
1.346 +
1.347 +/**
1.348 +Transfers an already open file from a server to a client.
1.349 +
1.350 +Before this function can be called, the file server session which owns this file handle
1.351 +must first be marked as shareable by calling RFs::ShareProtected().
1.352 +
1.353 +The file (RFile) handle is written to the client's address space to the package
1.354 +buffer in the message address slot in aMsg identified by aFileHandleIndex.
1.355 +
1.356 +If no error occurs, then the message is completed with the file-server (RFs)
1.357 +session handle.
1.358 +
1.359 +When the message completes, the client may call AdoptFromServer() to open
1.360 +a new RFile object which refers to the same file as this.
1.361 +
1.362 +Note that if an error occurs then the message is not completed.
1.363 +
1.364 +@param aMsg A message received from the client
1.365 +@param aFileHandleIndex Identifies the message slot that contains a package
1.366 + buffer pointing to an address in the client's address space
1.367 + to receive the file (RFile) handle
1.368 +
1.369 +@return KErrNone if successful, otherwise one of the other system-wide
1.370 + error codes.
1.371 +*/
1.372 +EFSRV_EXPORT_C TInt RFile::TransferToClient(const RMessage2& aMsg, TInt aFileHandleIndex) const
1.373 + {
1.374 + TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToClient, MODULEUID, Session().Handle(), SubSessionHandle(), aFileHandleIndex);
1.375 +
1.376 + if (TUint(aFileHandleIndex) >= TUint(KMaxMessageArguments))
1.377 + {
1.378 + TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToClientReturn, MODULEUID, (TUint) KErrArgument);
1.379 + return KErrArgument;
1.380 + }
1.381 +
1.382 + TInt dupSubSessionHandle;
1.383 + TInt r = DuplicateHandle(dupSubSessionHandle);
1.384 + if (r == KErrNone)
1.385 + r = aMsg.Write(aFileHandleIndex, TPckgC<TInt>(dupSubSessionHandle));
1.386 +
1.387 + if (r != KErrNone)
1.388 + {
1.389 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToClientReturn, MODULEUID, r);
1.390 + return r;
1.391 + }
1.392 +
1.393 + aMsg.Complete(Session());
1.394 +
1.395 + TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToClientReturn, MODULEUID, r);
1.396 +
1.397 + return r;
1.398 + }
1.399 +
1.400 +
1.401 +/**
1.402 +Transfers an already open file to another process.
1.403 +
1.404 +Before this function can be called, the file server session which owns this file handle
1.405 +must first be marked as shareable by calling RFs::ShareProtected().
1.406 +
1.407 +This function packages handle details for this file into 2 arguments in another
1.408 +process's environment data slots.
1.409 +When the other process runs, it may call AdoptFromCreator() to open a new RFile
1.410 +object which refers to the same file as this.
1.411 +
1.412 +@param aProcess A handle to another process.
1.413 +@param aFsHandleIndex An index that identifies a slot in the process's
1.414 + environment data which on exit will contain the file server
1.415 + session (RFs) handle
1.416 + This slot must not be used for anything else otherwise the
1.417 + results will be unpredictable.
1.418 +@param aFileHandleIndex An index that identifies a slot in the process's
1.419 + environment data which on exit will contain the file
1.420 + (RFile) handle.
1.421 + This slot must not be used for anything else otherwise the
1.422 + results will be unpredictable.
1.423 +@return KErrNone if successful, otherwise one of the other system-wide
1.424 + error codes.
1.425 +*/
1.426 +// NB slot 0 is reserved for the command line
1.427 +EFSRV_EXPORT_C TInt RFile::TransferToProcess(RProcess& aProcess, TInt aFsHandleIndex, TInt aFileHandleIndex) const
1.428 + {
1.429 + TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToProcess, MODULEUID, Session().Handle(), SubSessionHandle(), aFsHandleIndex, aFileHandleIndex);
1.430 +
1.431 + TInt dupSubSessionHandle;
1.432 + TInt r = DuplicateHandle(dupSubSessionHandle);
1.433 +
1.434 + if (r == KErrNone)
1.435 + r = aProcess.SetParameter(aFsHandleIndex, RHandleBase(Session()));
1.436 +
1.437 + if (r == KErrNone)
1.438 + r = aProcess.SetParameter(aFileHandleIndex, dupSubSessionHandle);
1.439 +
1.440 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToProcessReturn, MODULEUID, r);
1.441 +
1.442 + return r;
1.443 + }
1.444 +
1.445 +
1.446 +EFSRV_EXPORT_C TInt RFile::Name(TDes& aName) const
1.447 +/**
1.448 +Gets the final part of a filename
1.449 +
1.450 +This is used to retrieve the name and extension of a file that has been
1.451 +passed from one process to another using the RFile::AdoptXXX() methods.
1.452 +
1.453 +@param aName On return, contains the name of the file, including the name and
1.454 + extension but excluding the drive letter and path.
1.455 +
1.456 +@return KErrNone if successful, otherwise one of the other
1.457 + system-wide error codes.
1.458 +
1.459 +*/
1.460 + {
1.461 + TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileName, MODULEUID, Session().Handle(), SubSessionHandle());
1.462 +
1.463 + TInt r = SendReceive(EFsFileName, TIpcArgs(&aName));
1.464 +
1.465 + TRACERETMULT2(UTF::EBorder, UTraceModuleEfsrv::EFileNameReturn, MODULEUID, r, aName);
1.466 +
1.467 + return r;
1.468 + }
1.469 +
1.470 +
1.471 +EFSRV_EXPORT_C TInt RFile::FullName(TDes& aName) const
1.472 +/**
1.473 +Gets the full filename
1.474 +
1.475 +This is used to retrieve the full filename, including drive and path,
1.476 +of a file that has been passed from one process to another using the
1.477 +RFile::AdoptXXX() methods.
1.478 +
1.479 +@param aName On return, contains the full name of the file, including drive and path.
1.480 +
1.481 +@return KErrNone if successful, otherwise one of the other
1.482 + system-wide error codes.
1.483 +
1.484 +*/
1.485 + {
1.486 + TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileFullName, MODULEUID, Session().Handle(), SubSessionHandle());
1.487 +
1.488 + TInt r = SendReceive(EFsFileFullName, TIpcArgs(&aName));
1.489 +
1.490 + TRACERETMULT2(UTF::EBorder, UTraceModuleEfsrv::EFileFullNameReturn, MODULEUID, r, aName);
1.491 +
1.492 + return r;
1.493 + }
1.494 +
1.495 +
1.496 +
1.497 +EFSRV_EXPORT_C TInt RFile::Open(RFs& aFs,const TDesC& aName,TUint aMode)
1.498 +/**
1.499 +Opens an existing file for reading or writing.
1.500 +
1.501 +If the file does not already exist, an error is returned.
1.502 +
1.503 +Notes:
1.504 +
1.505 +1. To close the file, use Close()
1.506 +
1.507 +2. Attempting to open a file with the read-only attribute using the EFileWrite
1.508 + access mode results in an error.
1.509 +
1.510 +3. Attempting to open a file which is greater than or equal to 2GByte (2,147,483,648 bytes)
1.511 + will fail with KErrTooBig
1.512 +
1.513 +4. After a file has been opened, the current write position is set to the start
1.514 + of the file.
1.515 + If necessary, use RFile::Seek() to move to a different position within
1.516 + the file.
1.517 +
1.518 +@param aFs The file server session.
1.519 +@param aName The name of the file. Any path components (i.e. drive letter
1.520 + or directory), which are not specified, are taken from
1.521 + the session path.The file name shall not contain wild cards
1.522 + ('?' or '*' characters) and illegal characters like
1.523 + '<', '>', ':', '"', '/', '|' and '\000'. Backslash '\\' character
1.524 + is allowed only as a path delimiter. The filename containing only
1.525 + white space characters (See TChar::IsSpace()) is also illegal.
1.526 +
1.527 +@param aMode The mode in which the file is opened. See TFileMode.
1.528 +
1.529 +@return KErrNone if successful, otherwise one of the other system-wide
1.530 + error codes.
1.531 +
1.532 +@see TFileMode
1.533 +
1.534 +@capability Dependent If the path for aName is /Sys and aMode is neither
1.535 + EFileShareReadersOnly nor EFileRead then Tcb capability is required.
1.536 +@capability Dependent If the path for aName is /Sys and aMode is either
1.537 + EFileShareReadersOnly or EFileRead then Allfiles capability is required.
1.538 +@capability Dependent If the path for aName begins with /Private and does not match this process'
1.539 + SID then AllFiles capability is required.
1.540 +@capability Dependent If the path for aName begins with /Resource and aMode is neither
1.541 + EFileShareReadersOrWriters|EFileRead nor EFileShareReadersOnly
1.542 + nor EFileRead then Tcb capability is required.
1.543 +
1.544 +*/
1.545 + {
1.546 + TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileOpen, MODULEUID, aFs.Handle(), aMode, aName);
1.547 +
1.548 + aMode &= ~EFileBigFile;
1.549 + TInt r = CreateSubSession(aFs,EFsFileOpen,TIpcArgs(&aName,aMode));
1.550 +
1.551 + TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileOpenReturn, MODULEUID, r, SubSessionHandle());
1.552 +
1.553 + return r;
1.554 + }
1.555 +
1.556 +
1.557 +EFSRV_EXPORT_C void RFile::Close()
1.558 +/**
1.559 +Closes the file.
1.560 +
1.561 +Any open files are closed when the file server session is closed.
1.562 +
1.563 +Close() is guaranteed to return, and provides no indication whether
1.564 +it completed successfully or not. When closing a file you have written to,
1.565 +you should ensure that data is committed to the file by invoking RFile::Flush()
1.566 +before closing. If Flush() completes successfully, Close() is essentially a
1.567 +no-operation.
1.568 +*/
1.569 + {
1.570 + TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileClose, MODULEUID, Session().Handle(), SubSessionHandle());
1.571 +
1.572 +#if defined (SYMBIAN_FTRACE_ENABLE) && defined(__DLL__)
1.573 + // Need to close the handle to the trace LDD if this is an auto-close subsession
1.574 + // as these close their parent session by calling RHandleBase::Close(), i.e. they
1.575 + // bypass RFs::Close() which would normally be responsible for closing the LDD
1.576 + TInt h = Session().Handle() ^ CObjectIx::ENoClose;
1.577 + if ( h != NULL && (!(h & CObjectIx::ENoClose)) )
1.578 + {
1.579 + RFTRACE_CLOSE;
1.580 + }
1.581 +#endif
1.582 +
1.583 + CloseSubSession(EFsFileSubClose);
1.584 +
1.585 + TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileCloseReturn, MODULEUID);
1.586 + }
1.587 +
1.588 +
1.589 +EFSRV_EXPORT_C TInt RFile::Create(RFs& aFs,const TDesC& aName,TUint aMode)
1.590 +/**
1.591 +Creates and opens a new file for writing.
1.592 +
1.593 +If the file already exists, an error is returned.
1.594 +
1.595 +If the resulting path does not exist, then the operation cannot proceed and
1.596 +the function returns an error code.
1.597 +
1.598 +Notes:
1.599 +
1.600 +1. To close the file, use Close()
1.601 +
1.602 +2. It automatically sets the file's archive attribute.
1.603 +
1.604 +@param aFs The file server session.
1.605 +@param aName The name of the file. Any path components (i.e. drive letter
1.606 + or directory), which are not specified, are taken from
1.607 + the session path. The file name shall not contain wild cards
1.608 + ('?' or '*' characters) and illegal characters like
1.609 + '<', '>', ':', '"', '/', '|' and '\000'. Backslash '\\' character
1.610 + is allowed only as a path delimiter. The filename containing only
1.611 + white space characters (See TChar::IsSpace()) is also illegal.
1.612 +
1.613 +@param aMode The mode in which the file is opened. The access mode is
1.614 + automatically set to EFileWrite. See TFileMode.
1.615 +
1.616 +@return KErrNone if successful, otherwise one of the other system-wide
1.617 + error codes.
1.618 +
1.619 +@see TFileMode
1.620 +
1.621 +@capability Dependent If the path in aName starts with /Sys then capability Tcb is required
1.622 +@capability Dependent If the path in aName starts with /Resource then capability Tcb is required
1.623 +@capability Dependent If the path in aName starts with /Private and does not match this process'
1.624 + SID then AllFiles capability is required.
1.625 +
1.626 +*/
1.627 + {
1.628 + aMode &= ~EFileBigFile;
1.629 +
1.630 + TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileCreate, MODULEUID, aFs.Handle(), aMode, aName);
1.631 +
1.632 + TInt r = CreateSubSession(aFs,EFsFileCreate,TIpcArgs(&aName,aMode));
1.633 +
1.634 + TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileCreateReturn, MODULEUID, r, SubSessionHandle());
1.635 +
1.636 + return r;
1.637 + }
1.638 +
1.639 +
1.640 +
1.641 +
1.642 +EFSRV_EXPORT_C TInt RFile::Replace(RFs& aFs,const TDesC& aName,TUint aMode)
1.643 +/**
1.644 +Opens a file for writing, replacing the content of any existing file of the
1.645 +same name if it exists, or creating a new file if it does not exist.
1.646 +
1.647 +If the resulting path exists, then:
1.648 +
1.649 +- the length of an existing file with the same filename is re-set to zero
1.650 +
1.651 +- a new file is created, if no existing file with the same filename can be found.
1.652 +
1.653 +If the resulting path does not exist, then the operation cannot proceed and
1.654 +the function returns an error code.
1.655 +
1.656 +Notes:
1.657 +
1.658 +- To close the file, use Close(), defined in the base class RFsBase.
1.659 +
1.660 +- It automatically sets the file's archive attribute.
1.661 +
1.662 +@param aFs The file server session.
1.663 +@param aName The name of the file. Any path components (i.e. drive letter
1.664 + or directory), which are not specified, are taken from
1.665 + the session path. The file name shall not contain wild cards
1.666 + ('?' or '*' characters) and illegal characters like
1.667 + '<', '>', ':', '"', '/', '|' and '\000'. Backslash '\\' character
1.668 + is allowed only as a path delimiter. The filename containing only
1.669 + white space characters (See TChar::IsSpace()) is also illegal.
1.670 +
1.671 +@param aMode The mode in which the file is opened. The access mode is
1.672 + automatically set to EFileWrite. See TFileMode.
1.673 +
1.674 +@return KErrNone if successful, otherwise one of the other system-wide
1.675 + error codes.
1.676 +
1.677 +@see TFileMode
1.678 +
1.679 +@capability Dependent If the path in aName starts with /Sys then capability Tcb is required
1.680 +@capability Dependent If the path in aName starts with /Resource then capability Tcb is required
1.681 +@capability Dependent If the path in aName starts with /Private and does not match this process'
1.682 + SID then AllFiles capability is required.
1.683 +
1.684 +*/
1.685 + {
1.686 + TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileReplace, MODULEUID, aFs.Handle(), aMode, aName);
1.687 + aMode &= ~EFileBigFile;
1.688 + TInt r = CreateSubSession(aFs,EFsFileReplace,TIpcArgs(&aName,aMode));
1.689 + TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileReplaceReturn, MODULEUID, r, SubSessionHandle());
1.690 + return r;
1.691 + }
1.692 +
1.693 +
1.694 +
1.695 +
1.696 +EFSRV_EXPORT_C TInt RFile::Temp(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aMode)
1.697 +/**
1.698 +Creates and opens a temporary file with a unique name for writing and reading.
1.699 +
1.700 +Notes:
1.701 +
1.702 +1. To close the file, use Close()
1.703 +
1.704 +@param aFs The file server session.
1.705 +@param aPath The directory in which the file is created.
1.706 +@param aName On return, contains the full path and file name of the file.
1.707 + The filename is guaranteed to be unique within the directory
1.708 + specified by aPath.
1.709 +@param aMode The mode in which the file is opened. The access mode is
1.710 + automatically set to EFileWrite. See TFileMode.
1.711 +
1.712 +@return KErrNone if successful, otherwise one of the other system-wide
1.713 + error codes.
1.714 +
1.715 +@see TFileMode
1.716 +
1.717 +@capability Dependent If aPath starts with /Sys then capability Tcb is required
1.718 +@capability Dependent If aPath starts with /Resource then capability Tcb is required
1.719 +@capability Dependent If aPath starts with /Private and does not match this process'
1.720 + SID then AllFiles capability is required.
1.721 +*/
1.722 + {
1.723 + TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileTemp, MODULEUID, aFs.Handle(), aPath, aMode);
1.724 + aMode &= ~EFileBigFile;
1.725 + TInt r = CreateSubSession(aFs,EFsFileTemp,TIpcArgs(&aPath,aMode,&aName));
1.726 + TRACERETMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileTempReturn, MODULEUID, r, SubSessionHandle(), aName);
1.727 + return r;
1.728 + }
1.729 +
1.730 +
1.731 +
1.732 +
1.733 +EFSRV_EXPORT_C TInt RFile::Read(TDes8& aDes) const
1.734 +/**
1.735 +Reads from the file at the current position.
1.736 +
1.737 +This is a synchronous function.
1.738 +
1.739 +Note that when an attempt is made to read beyond the end of the file,
1.740 +no error is returned.
1.741 +The descriptor's length is set to the number of bytes read into
1.742 +it. Therefore, when reading through a file,the end of file has been reached
1.743 +when the descriptor length, as returned by TDesC8::Length(), is zero.
1.744 +
1.745 +@param aDes Descriptor into which binary data is read. Any existing contents
1.746 + are overwritten. On return, its length is set to the number of
1.747 + bytes read.
1.748 +@return KErrNone if successful, otherwise one of the other system-wide error
1.749 + codes.
1.750 +
1.751 +@see TDesC8::Length
1.752 +*/
1.753 + {
1.754 + TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileRead1, MODULEUID, Session().Handle(), SubSessionHandle(), aDes.MaxLength());
1.755 +
1.756 + TInt r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),I64LOW(KCurrentPosition64)));
1.757 +
1.758 + TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead1Return, MODULEUID, r, aDes.Length());
1.759 +
1.760 + return r;
1.761 + }
1.762 +
1.763 +
1.764 +
1.765 +
1.766 +EFSRV_EXPORT_C void RFile::Read(TDes8& aDes,TRequestStatus& aStatus) const
1.767 +/**
1.768 +Reads from the file at the current position.
1.769 +
1.770 +This is an asynchronous function.
1.771 +
1.772 +Note that when an attempt is made to read beyond the end of the file,
1.773 +no error is returned.
1.774 +The descriptor's length is set to the number of bytes read into
1.775 +it. Therefore, when reading through a file,the end of file has been reached
1.776 +when the descriptor length, as returned by TDesC8::Length(), is zero.
1.777 +
1.778 +@param aDes Descriptor into which binary data is read. Any existing contents
1.779 + are overwritten. On return, its length is set to the number of
1.780 + bytes read.
1.781 + NB: this function is asynchronous and the request that it
1.782 + represents may not complete until some time after the call
1.783 + to the function has returned. It is important, therefore, that
1.784 + this descriptor remain valid, or remain in scope, until you have
1.785 + been notified that the request is complete.
1.786 +
1.787 +@param aStatus Request status. On completion contains:
1.788 + KErrNone, if successful, otherwise one of the other system-wide error codes.
1.789 +
1.790 +@see TDesC8::Length
1.791 +*/
1.792 + {
1.793 + TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileRead2, MODULEUID, Session().Handle(), SubSessionHandle(), aDes.MaxLength(), &aStatus);
1.794 +
1.795 + RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),I64LOW(KCurrentPosition64)),aStatus);
1.796 +
1.797 + TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead2Return, MODULEUID);
1.798 + }
1.799 +
1.800 +
1.801 +
1.802 +
1.803 +EFSRV_EXPORT_C TInt RFile::Read(TDes8& aDes,TInt aLength) const
1.804 +/**
1.805 +Reads the specified number of bytes of binary data from the file at the current position.
1.806 +
1.807 +This is a synchronous function.
1.808 +
1.809 +Note that when an attempt is made to read beyond the end of the file,
1.810 +no error is returned.
1.811 +The descriptor's length is set to the number of bytes read into
1.812 +it. Therefore, when reading through a file,the end of file has been reached
1.813 +when the descriptor length, as returned by TDesC8::Length(), is zero.
1.814 +Assuming aLength is less than the maximum length of the descriptor, the only circumstances
1.815 +in which Read() can return fewer bytes than requested, is when the end of
1.816 +file is reached or if an error occurs.
1.817 +
1.818 +@param aDes Descriptor into which binary data is read. Any existing
1.819 + contents are overwritten. On return, its length is set to
1.820 + the number of bytes read.
1.821 +
1.822 +@param aLength The number of bytes to be read from the file into the descriptor.
1.823 + If an attempt is made to read more bytes than the descriptor's
1.824 + maximum length, the function returns KErrOverflow.
1.825 + This value must not be negative, otherwise the function
1.826 + returns KErrArgument.
1.827 +
1.828 +@return KErrNone if successful, otherwise one of the other system-wide error
1.829 + codes.
1.830 +*/
1.831 + {
1.832 + TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileRead1, MODULEUID, Session().Handle(), SubSessionHandle(), aLength);
1.833 +
1.834 + if (aLength==0)
1.835 + {
1.836 + aDes.Zero();
1.837 + return(KErrNone);
1.838 + }
1.839 + else if(aLength>aDes.MaxLength())
1.840 + {
1.841 + return(KErrOverflow);
1.842 + }
1.843 + TInt r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,I64LOW(KCurrentPosition64)));
1.844 +
1.845 + TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead1Return, MODULEUID, r, aDes.Length());
1.846 +
1.847 + return r;
1.848 + }
1.849 +
1.850 +
1.851 +
1.852 +
1.853 +EFSRV_EXPORT_C void RFile::Read(TDes8& aDes,TInt aLength,TRequestStatus& aStatus) const
1.854 +/**
1.855 +Reads a specified number of bytes of binary data from the file at the current position.
1.856 +
1.857 +This is an asynchronous function.
1.858 +
1.859 +Note that when an attempt is made to read beyond the end of the file,
1.860 +no error is returned.
1.861 +The descriptor's length is set to the number of bytes read into it.
1.862 +Therefore, when reading through a file, the end of file has been reached
1.863 +when the descriptor length, as returned by TDesC8::Length(), is zero.
1.864 +Assuming aLength is less than the maximum length of the descriptor, the only
1.865 +circumstances in which Read() can return fewer bytes than requested is when
1.866 +the end of file is reached or if an error has occurred.
1.867 +
1.868 +@param aDes Descriptor into which binary data is read. Any existing
1.869 + contents are overwritten. On return, its length is set to the
1.870 + number of bytes read.
1.871 + NB: this function is asynchronous and the request that it
1.872 + represents may not complete until some time after the call
1.873 + to the function has returned. It is important, therefore, that
1.874 + this descriptor remain valid, or remain in scope, until you have
1.875 + been notified that the request is complete.
1.876 +
1.877 +@param aLength The number of bytes to be read from the file into the descriptor.
1.878 + If an attempt is made to read more bytes than the descriptor's
1.879 + maximum length, then the function updates aStatus parameter with KErrOverflow.
1.880 + It must not be negative otherwise the function updates aStatus with KErrArgument.
1.881 +
1.882 +@param aStatus Request status. On completion contains KErrNone if successful,
1.883 + otherwise one of the other system-wide error codes.
1.884 +*/
1.885 + {
1.886 + TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileRead2, MODULEUID, Session().Handle(), SubSessionHandle(), aLength, &aStatus);
1.887 +
1.888 + if (aLength==0)
1.889 + {
1.890 + aDes.Zero();
1.891 + TRequestStatus* req=(&aStatus);
1.892 + User::RequestComplete(req,KErrNone);
1.893 + return;
1.894 + }
1.895 + else if(aLength>aDes.MaxLength())
1.896 + {
1.897 + TRequestStatus* req=(&aStatus);
1.898 + User::RequestComplete(req,KErrOverflow);
1.899 + return;
1.900 + }
1.901 +
1.902 + RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,I64LOW(KCurrentPosition64)),aStatus);
1.903 +
1.904 + TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead2Return, MODULEUID);
1.905 + }
1.906 +
1.907 +
1.908 +
1.909 +
1.910 +EFSRV_EXPORT_C TInt RFile::Read(TInt aPos,TDes8& aDes) const
1.911 +/**
1.912 +Reads from the file at the specified offset within the file
1.913 +
1.914 +This is a synchronous function.
1.915 +
1.916 +Note that when an attempt is made to read beyond the end of the file,
1.917 +no error is returned.
1.918 +The descriptor's length is set to the number of bytes read into it.
1.919 +Therefore, when reading through a file, the end of file has been reached
1.920 +when the descriptor length, as returned by TDesC8::Length(), is zero.
1.921 +
1.922 +@param aPos Position of first byte to be read. This is an offset from
1.923 + the start of the file. If no position is specified, reading
1.924 + begins at the current file position.
1.925 + If aPos is beyond the end of the file, the function returns
1.926 + a zero length descriptor.
1.927 +
1.928 +@param aDes The descriptor into which binary data is read. Any existing content
1.929 + is overwritten. On return, its length is set to the number of
1.930 + bytes read.
1.931 +
1.932 +@return KErrNone if successful, otherwise one of the other system-wide error
1.933 + codes.
1.934 +
1.935 +@panic FSCLIENT 19 if aPos is negative.
1.936 +*/
1.937 + {
1.938 + TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileRead3, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.MaxLength());
1.939 +
1.940 + __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative));
1.941 +
1.942 + TInt r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),aPos));
1.943 +
1.944 + TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead3Return, MODULEUID, r, aDes.Length());
1.945 +
1.946 + return r;
1.947 + }
1.948 +
1.949 +
1.950 +
1.951 +
1.952 +EFSRV_EXPORT_C void RFile::Read(TInt aPos,TDes8& aDes,TRequestStatus& aStatus) const
1.953 +/**
1.954 +Reads from the file at the specified offset within the file.
1.955 +
1.956 +This is an asynchronous function.
1.957 +
1.958 +Note that when an attempt is made to read beyond the end of the file,
1.959 +no error is returned.
1.960 +The descriptor's length is set to the number of bytes read into it.
1.961 +Therefore, when reading through a file, the end of file has been reached
1.962 +when the descriptor length, as returned by TDesC8::Length(), is zero.
1.963 +
1.964 +@param aPos Position of first byte to be read. This is an offset from
1.965 + the start of the file. If no position is specified,
1.966 + reading begins at the current file position.
1.967 + If aPos is beyond the end of the file, the function returns
1.968 + a zero length descriptor.
1.969 +
1.970 +@param aDes The descriptor into which binary data is read. Any existing
1.971 + content is overwritten. On return, its length is set to
1.972 + the number of bytes read.
1.973 + NB: this function is asynchronous and the request that it
1.974 + represents may not complete until some time after the call
1.975 + to the function has returned. It is important, therefore, that
1.976 + this descriptor remain valid, or remain in scope, until you have
1.977 + been notified that the request is complete.
1.978 +
1.979 +@param aStatus The request status. On completion, contains an error code of KErrNone
1.980 + if successful, otherwise one of the other system-wide error codes.
1.981 +
1.982 +@panic FSCLIENT 19 if aPos is negative.
1.983 +*/
1.984 + {
1.985 + TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileRead4, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.MaxLength(), &aStatus);
1.986 +
1.987 + __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative));
1.988 + RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),aPos),aStatus);
1.989 +
1.990 + TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead4Return, MODULEUID);
1.991 + }
1.992 +
1.993 +
1.994 +
1.995 +
1.996 +EFSRV_EXPORT_C TInt RFile::Read(TInt aPos,TDes8& aDes,TInt aLength) const
1.997 +/**
1.998 +Reads the specified number of bytes of binary data from the file at a specified
1.999 +offset within the file.
1.1000 +
1.1001 +This is a synchronous function.
1.1002 +
1.1003 +Note that when an attempt is made to read beyond the end of the file,
1.1004 +no error is returned.
1.1005 +The descriptor's length is set to the number of bytes read into it.
1.1006 +Therefore, when reading through a file, the end of file has been reached
1.1007 +when the descriptor length, as returned by TDesC8::Length(), is zero.
1.1008 +Assuming aLength is less than the maximum length of the descriptor, the only
1.1009 +circumstances in which Read() can return fewer bytes than requested is when
1.1010 +the end of file is reached or if an error has occurred.
1.1011 +
1.1012 +@param aPos Position of first byte to be read. This is an offset from
1.1013 + the start of the file. If no position is specified,
1.1014 + reading begins at the current file position.
1.1015 + If aPos is beyond the end of the file, the function returns
1.1016 + a zero length descriptor.
1.1017 +
1.1018 +@param aDes The descriptor into which binary data is read. Any existing
1.1019 + contents are overwritten. On return, its length is set to
1.1020 + the number of bytes read.
1.1021 +@param aLength The number of bytes to read from the file into the descriptor.
1.1022 + If an attempt is made to read more bytes than the descriptor's
1.1023 + maximum length, then the function updates aStatus parameter with KErrOverflow.
1.1024 + It must not be negative otherwise the function updates aStatus with KErrArgument.
1.1025 +
1.1026 +@return KErrNone if successful, otherwise one of the other system-wide
1.1027 + error codes.
1.1028 +
1.1029 +@panic FSCLIENT 19 if aPos is negative.
1.1030 +*/
1.1031 + {
1.1032 + TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileRead3, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength);
1.1033 +
1.1034 + __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative));
1.1035 + if (aLength==0)
1.1036 + {
1.1037 + aDes.Zero();
1.1038 + return(KErrNone);
1.1039 + }
1.1040 + else if(aLength>aDes.MaxLength())
1.1041 + {
1.1042 + return(KErrOverflow);
1.1043 + }
1.1044 +
1.1045 + TInt r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,aPos));
1.1046 +
1.1047 + TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead3Return, MODULEUID, r, aDes.Length());
1.1048 +
1.1049 + return r;
1.1050 + }
1.1051 +
1.1052 +
1.1053 +
1.1054 +
1.1055 +EFSRV_EXPORT_C void RFile::Read(TInt aPos,TDes8& aDes,TInt aLength,TRequestStatus& aStatus) const
1.1056 +/**
1.1057 +Reads the specified number of bytes of binary data from the file at a specified
1.1058 +offset within the file.
1.1059 +
1.1060 +This is an asynchronous function.
1.1061 +
1.1062 +Note that when an attempt is made to read beyond the end of the file,
1.1063 +no error is returned.
1.1064 +The descriptor's length is set to the number of bytes read into it.
1.1065 +Therefore, when reading through a file, the end of file has been reached
1.1066 +when the descriptor length, as returned by TDesC8::Length(), is zero.
1.1067 +Assuming aLength is less than the maximum length of the descriptor, the only
1.1068 +circumstances in which Read() can return fewer bytes than requested is when
1.1069 +the end of file is reached or if an error has occurred.
1.1070 +
1.1071 +@param aPos Position of first byte to be read. This is an offset from
1.1072 + the start of the file. If no position is specified,
1.1073 + reading begins at the current file position.
1.1074 + If aPos is beyond the end of the file, the function returns
1.1075 + a zero length descriptor.
1.1076 +
1.1077 +@param aDes The descriptor into which binary data is read. Any existing
1.1078 + contents are overwritten. On return, its length is set to
1.1079 + the number of bytes read.
1.1080 + NB: this function is asynchronous and the request that it
1.1081 + represents may not complete until some time after the call
1.1082 + to the function has returned. It is important, therefore, that
1.1083 + this descriptor remain valid, or remain in scope, until you have
1.1084 + been notified that the request is complete.
1.1085 +
1.1086 +@param aLength The number of bytes to read from the file into the descriptor.
1.1087 + If an attempt is made to read more bytes than the descriptor's
1.1088 + maximum length, then the function returns KErrOverflow.
1.1089 + It must not be negative otherwise the function returns KErrArgument.
1.1090 +
1.1091 +@param aStatus Request status. On completion contains KErrNone if successful,
1.1092 + otherwise one of the other system-wide error codes.
1.1093 +
1.1094 +@panic FSCLIENT 19 if aPos is negative.
1.1095 +*/
1.1096 + {
1.1097 + TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileRead4, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength, &aStatus);
1.1098 +
1.1099 + __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative));
1.1100 + if (aLength==0)
1.1101 + {
1.1102 + aDes.Zero();
1.1103 + TRequestStatus* req=(&aStatus);
1.1104 + User::RequestComplete(req,KErrNone);
1.1105 + return;
1.1106 + }
1.1107 + else if(aLength>aDes.MaxLength())
1.1108 + {
1.1109 + TRequestStatus* req=(&aStatus);
1.1110 + User::RequestComplete(req,KErrOverflow);
1.1111 + return;
1.1112 + }
1.1113 +
1.1114 + RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,aPos),aStatus);
1.1115 +
1.1116 + TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead4Return, MODULEUID);
1.1117 + }
1.1118 +
1.1119 +
1.1120 +
1.1121 +
1.1122 +EFSRV_EXPORT_C void RFile::ReadCancel(TRequestStatus& aStatus) const
1.1123 +/**
1.1124 +Cancels a specific outstanding asynchronous read request.
1.1125 +
1.1126 +The outstanding request completes with KErrCancel.
1.1127 +
1.1128 +@param aStat The request status object identified with the original
1.1129 + asynchronous read.
1.1130 +*/
1.1131 + {
1.1132 + if(aStatus != KRequestPending)
1.1133 + return;
1.1134 + SendReceive(EFsFileReadCancel, TIpcArgs(&aStatus));
1.1135 + }
1.1136 +
1.1137 +
1.1138 +
1.1139 +
1.1140 +EFSRV_EXPORT_C void RFile::ReadCancel() const
1.1141 +/**
1.1142 +Cancels all outstanding asynchronous read requests for this subsession.
1.1143 +
1.1144 +All outstanding requests complete with KErrCancel.
1.1145 +*/
1.1146 + {
1.1147 + SendReceive(EFsFileReadCancel, TIpcArgs(NULL));
1.1148 + }
1.1149 +
1.1150 +
1.1151 +
1.1152 +
1.1153 +EFSRV_EXPORT_C TInt RFile::Write(const TDesC8& aDes)
1.1154 +/**
1.1155 +Writes to the file at the current offset within the file.
1.1156 +
1.1157 +This is a synchronous function.
1.1158 +
1.1159 +NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig
1.1160 +
1.1161 +@param aDes The descriptor from which binary data is written.
1.1162 + The function writes the entire contents of aDes to the file.
1.1163 +
1.1164 +@return KErrNone if successful, otherwise one of the other system-wide error
1.1165 + codes.
1.1166 +*/
1.1167 + {
1.1168 + TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1, MODULEUID, Session().Handle(), SubSessionHandle(), aDes.Length());
1.1169 + TInt r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),I64LOW(KCurrentPosition64)));
1.1170 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1Return, MODULEUID, r);
1.1171 + return r;
1.1172 + }
1.1173 +
1.1174 +
1.1175 +EFSRV_EXPORT_C void RFile::Write(const TDesC8& aDes,TRequestStatus& aStatus)
1.1176 +/**
1.1177 +Writes to the file at the current offset within the file.
1.1178 +
1.1179 +This is an asynchronous function.
1.1180 +
1.1181 +NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig
1.1182 +
1.1183 +@param aDes The descriptor from which binary data is written.
1.1184 + The function writes the entire contents of aDes to the file.
1.1185 + NB: this function is asynchronous and the request that it
1.1186 + represents may not complete until some time after the call
1.1187 + to the function has returned. It is important, therefore, that
1.1188 + this descriptor remain valid, or remain in scope, until you have
1.1189 + been notified that the request is complete.
1.1190 +
1.1191 +@param aStatus Request status. On completion contains KErrNone if successful,
1.1192 + otherwise one of the other system-wide error codes.
1.1193 +*/
1.1194 + {
1.1195 + TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2, MODULEUID, Session().Handle(), SubSessionHandle(), aDes.Length(), &aStatus);
1.1196 +
1.1197 + RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),I64LOW(KCurrentPosition64)),aStatus);
1.1198 + TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2Return, MODULEUID);
1.1199 + }
1.1200 +
1.1201 +
1.1202 +
1.1203 +
1.1204 +EFSRV_EXPORT_C TInt RFile::Write(const TDesC8& aDes,TInt aLength)
1.1205 +/**
1.1206 +Writes a portion of a descriptor to the file at the current offset within
1.1207 +the file.
1.1208 +
1.1209 +This is a synchronous function.
1.1210 +
1.1211 +NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig
1.1212 +
1.1213 +@param aDes The descriptor from which binary data is written.
1.1214 +@param aLength The number of bytes to be written from the descriptor.
1.1215 + This must not be greater than the length of the descriptor.
1.1216 + It must not be negative.
1.1217 +
1.1218 +@return KErrNone if successful; KErrArgument if aLength is negative;
1.1219 + otherwise one of the other system-wide error codes.
1.1220 +
1.1221 +@panic FSCLIENT 27 in debug mode, if aLength is greater than the length
1.1222 + of the descriptor aDes.
1.1223 +*/
1.1224 + {
1.1225 + TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1, MODULEUID, Session().Handle(), SubSessionHandle(), aLength);
1.1226 +
1.1227 + __ASSERT_DEBUG(aDes.Length()>=aLength,Panic(EBadLength));
1.1228 + TInt r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,I64LOW(KCurrentPosition64)));
1.1229 +
1.1230 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1Return, MODULEUID, r);
1.1231 + return r;
1.1232 + }
1.1233 +
1.1234 +
1.1235 +
1.1236 +
1.1237 +EFSRV_EXPORT_C void RFile::Write(const TDesC8& aDes,TInt aLength,TRequestStatus& aStatus)
1.1238 +/**
1.1239 +Writes a portion of a descriptor to the file at the current offset
1.1240 +within the file.
1.1241 +
1.1242 +This is an asynchronous function.
1.1243 +
1.1244 +NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig
1.1245 +
1.1246 +@param aDes The descriptor from which binary data is written.
1.1247 + NB: this function is asynchronous and the request that it
1.1248 + represents may not complete until some time after the call
1.1249 + to the function has returned. It is important, therefore, that
1.1250 + this descriptor remain valid, or remain in scope, until you have
1.1251 + been notified that the request is complete.
1.1252 +
1.1253 +@param aLength The number of bytes to be written from the descriptor.
1.1254 + This must not be greater than the length of the descriptor.
1.1255 + It must not be negative.
1.1256 +
1.1257 +@param aStatus Request status. On completion contains KErrNone if successful;
1.1258 + KErrArgument if aLength is negative;
1.1259 + otherwise one of the other system-wide error codes.
1.1260 +
1.1261 +*/
1.1262 + {
1.1263 + TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2, MODULEUID, Session().Handle(), SubSessionHandle(), aLength, &aStatus);
1.1264 +
1.1265 + RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,I64LOW(KCurrentPosition64)),aStatus);
1.1266 +
1.1267 + TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2Return, MODULEUID);
1.1268 + }
1.1269 +
1.1270 +
1.1271 +
1.1272 +
1.1273 +
1.1274 +EFSRV_EXPORT_C TInt RFile::Write(TInt aPos,const TDesC8& aDes)
1.1275 +/**
1.1276 +Writes to the file at the specified offset within the file
1.1277 +
1.1278 +This is a synchronous function.
1.1279 +
1.1280 +NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig
1.1281 +
1.1282 +@param aPos The offset from the start of the file at which the first
1.1283 + byte is written.
1.1284 + If a position beyond the end of the file is specified, then
1.1285 + the write operation begins at the end of the file.
1.1286 + If the position has been locked, then the write fails.
1.1287 +
1.1288 +@param aDes The descriptor from which binary data is written. The function writes
1.1289 + the entire contents of aDes to the file.
1.1290 +
1.1291 +@return KErrNone if successful, otherwise one of the other system-wide error
1.1292 + codes.
1.1293 +
1.1294 +@panic FSCLIENT 19 if aPos is negative.
1.1295 +*/
1.1296 + {
1.1297 + TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileWrite3, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.Length());
1.1298 +
1.1299 + __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative));
1.1300 + TInt r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),aPos));
1.1301 +
1.1302 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite3Return, MODULEUID, r);
1.1303 + return r;
1.1304 + }
1.1305 +
1.1306 +
1.1307 +
1.1308 +
1.1309 +EFSRV_EXPORT_C void RFile::Write(TInt aPos,const TDesC8& aDes,TRequestStatus& aStatus)
1.1310 +/**
1.1311 +Writes to the file at the specified offset within the file
1.1312 +
1.1313 +This is an asynchronous function.
1.1314 +
1.1315 +NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig
1.1316 +
1.1317 +@param aPos The offset from the start of the file at which the first
1.1318 + byte is written.
1.1319 + If a position beyond the end of the file is specified, then
1.1320 + the write operation begins at the end of the file.
1.1321 + If the position has been locked, then the write fails.
1.1322 +
1.1323 +@param aDes The descriptor from which binary data is written. The function
1.1324 + writes the entire contents of aDes to the file.
1.1325 + NB: this function is asynchronous and the request that it
1.1326 + represents may not complete until some time after the call
1.1327 + to the function has returned. It is important, therefore, that
1.1328 + this descriptor remain valid, or remain in scope, until you have
1.1329 + been notified that the request is complete.
1.1330 +
1.1331 +@param aStatus Request status. On completion contains KErrNone if successful,
1.1332 + otherwise one of the other system-wide error codes.
1.1333 +
1.1334 +@panic FSCLIENT 19 if aPos is negative.
1.1335 +*/
1.1336 + {
1.1337 + TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileWrite4, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.Length(), &aStatus);
1.1338 +
1.1339 + __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative));
1.1340 + RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),aPos),aStatus);
1.1341 + TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite4Return, MODULEUID);
1.1342 + }
1.1343 +
1.1344 +
1.1345 +
1.1346 +
1.1347 +EFSRV_EXPORT_C TInt RFile::Write(TInt aPos,const TDesC8& aDes,TInt aLength)
1.1348 +/**
1.1349 +Writes the specified number of bytes to the file at the specified offset within the file.
1.1350 +
1.1351 +This is a synchronous function.
1.1352 +
1.1353 +NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig
1.1354 +
1.1355 +@param aPos The offset from the start of the file at which the first
1.1356 + byte is written.
1.1357 + If a position beyond the end of the file is specified, then
1.1358 + the write operation begins at the end of the file.
1.1359 + If the position has been locked, then the write fails.
1.1360 +
1.1361 +@param aDes The descriptor from which binary data is written.
1.1362 +@param aLength The number of bytes to be written from aDes .
1.1363 + It must not be negative.
1.1364 +
1.1365 +@return KErrNone if successful; KErrArgument if aLength is negative;
1.1366 + otherwise one of the other system-wide error codes.
1.1367 +
1.1368 +@panic FSCLIENT 19 if aPos is negative.
1.1369 +*/
1.1370 + {
1.1371 + TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1, MODULEUID, Session().Handle(), SubSessionHandle(), aLength);
1.1372 +
1.1373 + __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative));
1.1374 + TInt r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,aPos));
1.1375 +
1.1376 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1Return, MODULEUID, r);
1.1377 + return r;
1.1378 + }
1.1379 +
1.1380 +
1.1381 +
1.1382 +
1.1383 +EFSRV_EXPORT_C void RFile::Write(TInt aPos,const TDesC8& aDes,TInt aLength,TRequestStatus& aStatus)
1.1384 +/**
1.1385 +Writes the specified number of bytes to the file at the specified offset within the file.
1.1386 +
1.1387 +This is an asynchronous function.
1.1388 +
1.1389 +NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig
1.1390 +
1.1391 +@param aPos The offset from the start of the file at which the first
1.1392 + byte is written.
1.1393 + If a position beyond the end of the file is specified, then
1.1394 + the write operation begins at the end of the file.
1.1395 + If the position has been locked, then the write fails.
1.1396 +
1.1397 +@param aDes The descriptor from which binary data is written.
1.1398 + NB: this function is asynchronous and the request that it
1.1399 + represents may not complete until some time after the call
1.1400 + to the function has returned. It is important, therefore, that
1.1401 + this descriptor remain valid, or remain in scope, until you have
1.1402 + been notified that the request is complete.
1.1403 +
1.1404 +@param aLength The number of bytes to be written from aDes.
1.1405 + It must not be negative.
1.1406 +
1.1407 +@param aStatus Request status. On completion contains KErrNone if successful;
1.1408 + KErrArgument if aLength is negative;
1.1409 + otherwise one of the other system-wide error codes.
1.1410 +
1.1411 +@panic FSCLIENT 19 if aPos is negative.
1.1412 +*/
1.1413 + {
1.1414 + TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength, &aStatus);
1.1415 +
1.1416 + __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative));
1.1417 + RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,aPos),aStatus);
1.1418 + TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2Return, MODULEUID);
1.1419 + }
1.1420 +
1.1421 +
1.1422 +
1.1423 +
1.1424 +EFSRV_EXPORT_C TInt RFile::Lock(TInt aPos,TInt aLength) const
1.1425 +/**
1.1426 +Locks a region within the file as defined by a range of bytes.
1.1427 +
1.1428 +This ensures that those bytes are accessible
1.1429 +only through the RFile object which claims the lock. To re-allow access by
1.1430 +other programs to the locked region, it must either be unlocked or the file
1.1431 +closed. Locking can be used to synchronize operations on a file when more
1.1432 +than one program has access to the file in EFileShareAny mode.
1.1433 +
1.1434 +More than one distinct region of a file can be locked, but an error is returned
1.1435 +if more than one lock is placed on the same region. Different RFile objects
1.1436 +can lock different parts of the same file as long as the file is opened in
1.1437 +EFileShareAny mode. The locked region may extend beyond the end of a file;
1.1438 +this prevents the file from being extended by other programs.
1.1439 +
1.1440 +@param aPos Position in file from which to lock; this is the offset from
1.1441 + the beginning of the file.
1.1442 +@param aLength Number of bytes to lock.
1.1443 +
1.1444 +@return KErrNone if successful; KErrArgument if aPos+aLength>2G-1 boundary;
1.1445 + otherwise one of the other system-wide error codes.
1.1446 +
1.1447 +@panic FSCLIENT 17 if aLength is not greater than zero,
1.1448 +@panic FSCLIENT 19 if aPos is negative.
1.1449 +
1.1450 +*/
1.1451 + {
1.1452 + TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileLock, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength);
1.1453 +
1.1454 + __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative));
1.1455 +
1.1456 + TInt r = SendReceive(EFsFileLock,TIpcArgs(aPos,aLength));
1.1457 +
1.1458 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileLockReturn, MODULEUID, r);
1.1459 + return r;
1.1460 + }
1.1461 +
1.1462 +
1.1463 +
1.1464 +
1.1465 +EFSRV_EXPORT_C TInt RFile::UnLock(TInt aPos,TInt aLength) const
1.1466 +/**
1.1467 +Unlocks a region within the file as defined by a range of bytes.
1.1468 +
1.1469 +A lock can only be removed by the RFile object which claimed the lock.
1.1470 +
1.1471 +A portion of a locked region cannot be unlocked. The entire locked region
1.1472 +must be unlocked otherwise an error is returned. If any byte within
1.1473 +the specified range of bytes to unlock is not locked, an error is returned.
1.1474 +
1.1475 +@param aPos Position in file from which to unlock; this is the offset from
1.1476 + the beginning of the file.
1.1477 +@param aLength Number of bytes to unlock.
1.1478 +
1.1479 +@return KErrNone if successful; KErrArgument if aPos+aLength>2G-1 boundary;
1.1480 + otherwise one of the other system-wide error codes.
1.1481 +
1.1482 +@panic FSCLIENT 18 if aLength is not greater than zero,
1.1483 +@panic FSCLIENT 19 if aPos is negative.
1.1484 +*/
1.1485 + {
1.1486 + TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileUnLock, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength);
1.1487 +
1.1488 + __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative));
1.1489 + TInt r = SendReceive(EFsFileUnLock,TIpcArgs(aPos,aLength));
1.1490 +
1.1491 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileUnLockReturn, MODULEUID, r);
1.1492 + return r;
1.1493 + }
1.1494 +
1.1495 +
1.1496 +
1.1497 +
1.1498 +EFSRV_EXPORT_C TInt RFile::Seek(TSeek aMode,TInt& aPos) const
1.1499 +/**
1.1500 +Sets the the current file position.
1.1501 +
1.1502 +The function can also be used to get the current file
1.1503 +position without changing it. The file position is the position at which
1.1504 +reading and writing takes place. The start of the file is position zero.
1.1505 +
1.1506 +To retrieve the current file position without changing it, specify ESeekCurrent
1.1507 +for the seek mode, and zero for the offset.
1.1508 +
1.1509 +If the seek mode is ESeekStart, then:
1.1510 +
1.1511 +1. the function does not modify the aPos argument,
1.1512 +
1.1513 +2. the function returns an error if the offset specified is negative.
1.1514 +
1.1515 +If the seek mode is ESeekAddress, an error is returned if:
1.1516 +
1.1517 +1. the file is not in ROM,
1.1518 +
1.1519 +2. the offset specified is greater than the size of the file.
1.1520 +
1.1521 +@param aMode Seek mode. Controls the destination of the seek operation.
1.1522 +@param aPos Offset from location specified in aMode. Can be negative.
1.1523 + On return contains the new file position.
1.1524 + If the seek mode is either ESeekCurrent or ESeekEnd and the offset
1.1525 + specifies a position before the start of the file
1.1526 + or beyond the end of the file, then on return, aPos is set to
1.1527 + the new file position (either the start or the end of the file).
1.1528 + If the seek mode is ESeekAddress, aPos returns the address of
1.1529 + the byte at the specified offset within the file.
1.1530 +
1.1531 +@return KErrNone if successful, otherwise one of the other system-wide error
1.1532 + codes.
1.1533 +*/
1.1534 + {
1.1535 + TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileSeek, MODULEUID, Session().Handle(), SubSessionHandle(), aMode, aPos, 0);
1.1536 +
1.1537 + TInt64 newPos = aPos;
1.1538 + TPckg<TInt64> pkNewPos(newPos);
1.1539 + TInt r = SendReceive(EFsFileSeek|KIpcArgSlot2Desc,TIpcArgs(aPos,aMode,&pkNewPos));
1.1540 + if(KErrNone == r)
1.1541 + aPos = I64LOW(newPos);
1.1542 +
1.1543 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileSeekReturn, MODULEUID, r);
1.1544 + return r;
1.1545 + }
1.1546 +
1.1547 +
1.1548 +
1.1549 +
1.1550 +EFSRV_EXPORT_C TInt RFile::Flush()
1.1551 +/**
1.1552 +Commits data to the storage device and flushes internal buffers without closing
1.1553 +the file.
1.1554 +
1.1555 +Although RFile::Close() also flushes internal buffers, it is often useful
1.1556 +to call Flush() before a file is closed. This is because Close() returns no
1.1557 +error information, so there is no way of telling whether the final data was
1.1558 +written to the file successfully or not. Once data has been flushed, Close()
1.1559 +is effectively a no-operation.
1.1560 +
1.1561 +@return KErrNone if successful, otherwise one of the other system-wide error
1.1562 + codes.
1.1563 +*/
1.1564 + {
1.1565 + TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileFlush, MODULEUID, Session().Handle(), SubSessionHandle(), NULL);
1.1566 +
1.1567 + TInt r = RSubSessionBase::SendReceive(EFsFileFlush);
1.1568 +
1.1569 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileFlushReturn, MODULEUID, r);
1.1570 + return r;
1.1571 + }
1.1572 +
1.1573 +
1.1574 +
1.1575 +
1.1576 +EFSRV_EXPORT_C void RFile::Flush(TRequestStatus& aStatus)
1.1577 +/**
1.1578 +Commits data to the storage device and flushes internal buffers without closing
1.1579 +the file.
1.1580 +
1.1581 +Although RFile::Close() also flushes internal buffers, it is often useful
1.1582 +to call Flush() before a file is closed. This is because Close() returns no
1.1583 +error information, so there is no way of telling whether the final data was
1.1584 +written to the file successfully or not. Once data has been flushed, Close()
1.1585 +is effectively a no-operation.
1.1586 +
1.1587 +@param aStatus Request status. On completion contains KErrNone if successful,
1.1588 + otherwise one of the other system-wide error codes.
1.1589 +*/
1.1590 + {
1.1591 + TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileFlush, MODULEUID, Session().Handle(), SubSessionHandle(), &aStatus);
1.1592 +
1.1593 + RSubSessionBase::SendReceive(EFsFileFlush, aStatus);
1.1594 +
1.1595 + TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileFlushReturn, MODULEUID);
1.1596 + }
1.1597 +
1.1598 +
1.1599 +
1.1600 +
1.1601 +EFSRV_EXPORT_C TInt RFile::Size(TInt& aSize) const
1.1602 +/**
1.1603 +Gets the current file size.
1.1604 +
1.1605 +@param aSize On return, the size of the file in bytes.
1.1606 +
1.1607 +@return KErrNone if successful, otherwise one of the other system-wide error
1.1608 + codes.
1.1609 +*/
1.1610 + {
1.1611 + TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileSize, MODULEUID, Session().Handle(), SubSessionHandle());
1.1612 +
1.1613 + TInt64 size = aSize;
1.1614 + TPckg<TInt64> pkSize(size);
1.1615 + TInt r = SendReceive(EFsFileSize|KIpcArgSlot0Desc,TIpcArgs(&pkSize));
1.1616 + if(KErrNone != r)
1.1617 + return r;
1.1618 + aSize = I64LOW(size);
1.1619 +#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
1.1620 + if (size > KMaxTInt)
1.1621 + return (KErrTooBig);
1.1622 +#endif
1.1623 +
1.1624 + TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileSizeReturn, MODULEUID, r, aSize);
1.1625 + return r;
1.1626 + }
1.1627 +
1.1628 +
1.1629 +
1.1630 +
1.1631 +EFSRV_EXPORT_C TInt RFile::SetSize(TInt aSize)
1.1632 +/**
1.1633 +Sets the file size.
1.1634 +
1.1635 +If the size of the file is reduced, data may be lost from
1.1636 +the end of the file.
1.1637 +
1.1638 +Note:
1.1639 +
1.1640 +1. The current file position remains unchanged unless SetSize() reduces the size
1.1641 + of the file in such a way that the current file position is now beyond
1.1642 + the end of the file. In this case, the current file position is set to
1.1643 + the end of file.
1.1644 +
1.1645 +2. If the file was not opened for writing, an error is returned.
1.1646 +
1.1647 +@param aSize The new size of the file, in bytes. This value must not be negative, otherwise the function raises a panic.
1.1648 +
1.1649 +@return KErrNone if successful, otherwise one of the other system-wide error
1.1650 + codes.
1.1651 +
1.1652 +@panic FSCLIENT 20 If aSize is negative.
1.1653 +
1.1654 +*/
1.1655 + {
1.1656 + TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileSetSize, MODULEUID, Session().Handle(), SubSessionHandle(), aSize, 0);
1.1657 +
1.1658 + TInt r = SendReceive(EFsFileSetSize,TIpcArgs(aSize));
1.1659 +
1.1660 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileSetSizeReturn, MODULEUID, r);
1.1661 + return r;
1.1662 + }
1.1663 +
1.1664 +
1.1665 +
1.1666 +
1.1667 +EFSRV_EXPORT_C TInt RFile::Att(TUint& aVal) const
1.1668 +/**
1.1669 +Gets the file's attributes.
1.1670 +
1.1671 +@param aVal A bitmask which, on return, contains the file’s attributes.
1.1672 + For more information, see KEntryAttNormal and the other
1.1673 + file/directory attributes.
1.1674 +
1.1675 +@return KErrNone if successful, otherwise one of the other system-wide error
1.1676 + codes.
1.1677 +
1.1678 +@see KEntryAttNormal
1.1679 +*/
1.1680 + {
1.1681 + TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileAtt, MODULEUID, Session().Handle(), SubSessionHandle());
1.1682 +
1.1683 + TPtr8 a((TUint8*)&aVal,sizeof(TUint));
1.1684 +
1.1685 + TInt r = SendReceive(EFsFileAtt,TIpcArgs(&a));
1.1686 +
1.1687 + TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileAttReturn, MODULEUID, r, aVal);
1.1688 + return r;
1.1689 + }
1.1690 +
1.1691 +
1.1692 +
1.1693 +
1.1694 +EFSRV_EXPORT_C TInt RFile::SetAtt(TUint aSetAttMask,TUint aClearAttMask)
1.1695 +/**
1.1696 +Sets or clears file attributes using two bitmasks.
1.1697 +
1.1698 +The first mask controls which attributes are set.
1.1699 +The second controls which attributes are cleared.
1.1700 +
1.1701 +Notes:
1.1702 +
1.1703 +1. The file must have been opened for writing, or an error is returned.
1.1704 +
1.1705 +2. A panic is raised if any attribute is specified in both bitmasks.
1.1706 +
1.1707 +3. An attempt to set or clear the KEntryAttDir, KEntryAttVolume or KEntryAttRemote
1.1708 + attributes have no effect.
1.1709 +
1.1710 +4. The new attribute values take effect when the file is flushed or closed (which
1.1711 + implies a flush).
1.1712 +
1.1713 +@param aSetAttMask A bitmask indicating the file attributes to be set
1.1714 +@param aClearAttMask A bitmask indicating the attributes to be cleared. For
1.1715 + more information see KEntryAttNormal, and the other
1.1716 + file/directory attributes.
1.1717 +
1.1718 +@return KErrNone if successful, otherwise one of the other system-wide error
1.1719 + codes.
1.1720 +
1.1721 +@panic FSCLIENT 21 if the same attribute bit is set in both bitmasks.
1.1722 +*/
1.1723 + {
1.1724 + TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileSetAtt, MODULEUID, Session().Handle(), SubSessionHandle(), aSetAttMask, aClearAttMask);
1.1725 +
1.1726 + __ASSERT_ALWAYS((aSetAttMask&aClearAttMask)==0,Panic(EAttributesIllegal));
1.1727 +
1.1728 + TInt r = SendReceive(EFsFileSetAtt,TIpcArgs(aSetAttMask,aClearAttMask));
1.1729 +
1.1730 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileSetAttReturn, MODULEUID, r);
1.1731 + return r;
1.1732 + }
1.1733 +
1.1734 +
1.1735 +
1.1736 +
1.1737 +EFSRV_EXPORT_C TInt RFile::Modified(TTime& aTime) const
1.1738 +/**
1.1739 +Gets local date and time the file was last modified, in universal time.
1.1740 +
1.1741 +@param aTime On return, contains the date and time the file was last modified in UTC.
1.1742 +
1.1743 +@return KErrNone if successful, otherwise one of the other system-wide error
1.1744 + codes.
1.1745 +*/
1.1746 + {
1.1747 + TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileModified, MODULEUID, Session().Handle(), SubSessionHandle());
1.1748 +
1.1749 + TPtr8 t((TUint8*)&aTime,sizeof(TTime));
1.1750 + TInt r = SendReceive(EFsFileModified,TIpcArgs(&t));
1.1751 +
1.1752 + TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileModifiedReturn, MODULEUID, r, I64LOW(aTime.Int64()), I64HIGH(aTime.Int64()));
1.1753 + return r;
1.1754 + }
1.1755 +
1.1756 +
1.1757 +
1.1758 +
1.1759 +EFSRV_EXPORT_C TInt RFile::SetModified(const TTime& aTime)
1.1760 +/**
1.1761 +Sets the date and time the file was last modified. UTC date and time should be used.
1.1762 +
1.1763 +Notes:
1.1764 +
1.1765 +1. The file must have been opened for writing, or an error is returned.
1.1766 +
1.1767 +2. The new modified time takes effect when the file is flushed or closed (which
1.1768 + implies a flush).
1.1769 +
1.1770 +@param aTime The new date and time the file was last modified, in universal time.
1.1771 +
1.1772 +@return KErrNone if successful, otherwise one of the other system-wide error
1.1773 + codes.
1.1774 +*/
1.1775 + {
1.1776 + TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileSetModified, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aTime.Int64()), I64HIGH(aTime.Int64()));
1.1777 +
1.1778 + TPtrC8 t((TUint8*)&aTime,sizeof(TTime));
1.1779 + TInt r = SendReceive(EFsFileSetModified,TIpcArgs(&t));
1.1780 +
1.1781 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileSetModifiedReturn, MODULEUID, r);
1.1782 + return r;
1.1783 + }
1.1784 +
1.1785 +
1.1786 +
1.1787 +
1.1788 +EFSRV_EXPORT_C TInt RFile::Set(const TTime& aTime,TUint aMask,TUint aVal)
1.1789 +/**
1.1790 +Sets the file’s attributes, and the date and time it was last modified.
1.1791 +
1.1792 +It combines the functionality of SetAtt() and SetModified()
1.1793 +
1.1794 +An attempt to set or clear the KEntryAttDir, KEntryAttVolume or KEntryAttRemote
1.1795 +attributes have no effect.
1.1796 +
1.1797 +@param aTime The new date and time the file was last modified. UTC date and time should be used.
1.1798 +@param aMask A bitmask indicating the file attributes to be set
1.1799 +@param aVal A bitmask indicating the attributes to be cleared. For
1.1800 + more information see KEntryAttNormal, and the other
1.1801 + file/directory attributes.
1.1802 +
1.1803 +@return KErrNone if successful, otherwise one of the other system-wide error
1.1804 + codes.
1.1805 +
1.1806 +@panic FSCLIENT 21 if the same attribute bit is set in both bitmasks.
1.1807 +
1.1808 +@see RFile::SetModified
1.1809 +@see RFile::SetAtt
1.1810 +*/
1.1811 + {
1.1812 + TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileSet, MODULEUID,
1.1813 + Session().Handle(), SubSessionHandle(), I64LOW(aTime.Int64()), I64HIGH(aTime.Int64()), aMask, aVal);
1.1814 +
1.1815 + __ASSERT_ALWAYS((aVal&aMask)==0,Panic(EAttributesIllegal));
1.1816 + TPtrC8 t((TUint8*)&aTime,sizeof(TTime));
1.1817 + TInt r = SendReceive(EFsFileSet,TIpcArgs(&t,aMask,aVal));
1.1818 +
1.1819 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileSetReturn, MODULEUID, r);
1.1820 + return r;
1.1821 + }
1.1822 +
1.1823 +
1.1824 +
1.1825 +
1.1826 +EFSRV_EXPORT_C TInt RFile::ChangeMode(TFileMode aNewMode)
1.1827 +/**
1.1828 +Switches an open file's access mode between EFileShareExclusive and EFileShareReadersOnly.
1.1829 +
1.1830 +This allows or disallows read-only access without having to close and re-open the file.
1.1831 +
1.1832 +@param aNewMode The new access mode.
1.1833 +
1.1834 +@return KErrNone, if successful;
1.1835 + KErrArgument, if aNewMode has any value other than the two specified;
1.1836 + KErrAccessDenied, if:
1.1837 + a) the function is called when the current file share
1.1838 + mode is EFileShareAny;
1.1839 + b) the file has multiple readers, and an attempt is made
1.1840 + to change the share mode to EFileShareExclusive;
1.1841 + c) the file has been opened for writing in EFileShareExclusive mode, and an
1.1842 + attempt is made to change the access mode to EFileShareReadersOnly.
1.1843 +
1.1844 +@capability Dependent If the path starts with /Resource then capability DiskAdmin is required
1.1845 +
1.1846 +*/
1.1847 + {
1.1848 + TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileChangeMode, MODULEUID, Session().Handle(), SubSessionHandle(), aNewMode);
1.1849 +
1.1850 + if (aNewMode!=EFileShareExclusive && aNewMode!=EFileShareReadersOnly)
1.1851 + return(KErrArgument);
1.1852 + TInt r = SendReceive(EFsFileChangeMode,TIpcArgs(aNewMode));
1.1853 +
1.1854 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileChangeModeReturn, MODULEUID, r);
1.1855 + return r;
1.1856 + }
1.1857 +
1.1858 +
1.1859 +
1.1860 +
1.1861 +EFSRV_EXPORT_C TInt RFile::Rename(const TDesC& aNewName)
1.1862 +/**
1.1863 +Renames a file.
1.1864 +
1.1865 +If aNewName specifies a different directory to the one in which
1.1866 +the file is currently located, then the file is moved.
1.1867 +
1.1868 +No other process may have access to the file, that is, the file must have
1.1869 +been opened in EFileShareExclusive share mode, or an error is returned. The
1.1870 +file must have been opened for writing (using EFileWrite access mode). An
1.1871 +error is returned if a file with the new filename already exists in the target
1.1872 +directory.
1.1873 +
1.1874 +The file or directory may not be moved to another device by this means, either
1.1875 +explicitly (by another drive specified in the name) or implicitly (because
1.1876 +the directory has been mapped to another device with RFs::SetSubst()).
1.1877 +
1.1878 +Note that the function builds up the new file specification by using all
1.1879 +of the path components specified
1.1880 +in aNewName (directory path, filename and extension),
1.1881 +then adding any missing components from the current file specification, and
1.1882 +finally adding any missing components from the session path. A consequence
1.1883 +of this is that you cannot rename a file to remove its extension. An alternative
1.1884 +to this function is RFs::Rename() which renames the file using the new name
1.1885 +as provided.
1.1886 +
1.1887 +@param aNewName The new file name and/or directory path. No part may contain
1.1888 + wildcard characters or an error is returned.
1.1889 +
1.1890 +@return KErrNone if successful, otherwise one of the other system-wide error
1.1891 + codes.
1.1892 +
1.1893 +@capability Dependent If aNewName starts with /Sys then capability Tcb is required
1.1894 +@capability Dependent If aNewName starts with /Resource then capability Tcb is required
1.1895 +@capability Dependent If aNewName starts with /Private and does not match this process'
1.1896 + SID then AllFiles capability is required.
1.1897 +
1.1898 +*/
1.1899 + {
1.1900 + TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileRename, MODULEUID, Session().Handle(), SubSessionHandle(), aNewName);
1.1901 +
1.1902 + TInt r = SendReceive(EFsFileRename,TIpcArgs(&aNewName));
1.1903 +
1.1904 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileRenameReturn, MODULEUID, r);
1.1905 + return r;
1.1906 + }
1.1907 +
1.1908 +
1.1909 +
1.1910 +
1.1911 +EFSRV_EXPORT_C TInt RFile::Drive(TInt &aDriveNumber, TDriveInfo &aDriveInfo) const
1.1912 +/**
1.1913 +Gets information about the drive on which this file resides.
1.1914 +
1.1915 +@param aDriveNumber On return, the drive number.
1.1916 +
1.1917 +@param aDriveInfo On return, contains information describing the drive
1.1918 + and the medium mounted on it. The value of TDriveInfo::iType
1.1919 + shows whether the drive contains media.
1.1920 +
1.1921 +@return KErrNone, if successful, otherwise one of the other
1.1922 + system-wide error codes
1.1923 +
1.1924 +@see RFs::Drive
1.1925 +*/
1.1926 + {
1.1927 + TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileDrive, MODULEUID, Session().Handle(), SubSessionHandle());
1.1928 +
1.1929 + TPckg<TInt> pki(aDriveNumber);
1.1930 + TPckg<TDriveInfo> pkdi(aDriveInfo);
1.1931 + TInt r = SendReceive(EFsFileDrive,TIpcArgs(&pki,&pkdi));
1.1932 +
1.1933 + TRACERET4(UTF::EBorder, UTraceModuleEfsrv::EFileDriveReturn, MODULEUID, r, aDriveInfo.iDriveAtt, aDriveInfo.iMediaAtt, aDriveInfo.iType);
1.1934 + return r;
1.1935 + }
1.1936 +
1.1937 +
1.1938 +TInt RFile::Clamp(RFileClamp& aHandle)
1.1939 +/**
1.1940 +Instructs the File Server that the file is not to be modified on storage media.
1.1941 +
1.1942 +@param aHandle On return, a handle to the file.
1.1943 +
1.1944 +@return KErrNone, if successful, otherwise one of the other
1.1945 + system-wide error codes
1.1946 +
1.1947 +@see RFs::Unclamp
1.1948 +*/
1.1949 + {
1.1950 + TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileClamp, MODULEUID, Session().Handle(), SubSessionHandle());
1.1951 +
1.1952 + TPckg<RFileClamp> pkHandle(aHandle);
1.1953 + TInt r = SendReceive(EFsFileClamp,TIpcArgs(& pkHandle));
1.1954 +
1.1955 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileClampReturn, MODULEUID, r);
1.1956 + return r;
1.1957 + }
1.1958 +
1.1959 +/**
1.1960 +Fetches the Block Map of a file. Each file in the file system will consist of
1.1961 +a number of groups of blocks. Each group represents a number of contiguous blocks.
1.1962 +Such a group is represented by the TBlockMapEntry class. The full Block Map representing
1.1963 +the file may be determined by repeatedly calling RFile::BlockMap until KErrCompletion is
1.1964 +returned.
1.1965 +
1.1966 +Note:
1.1967 +
1.1968 +1. If the Block Map for the whole file is not required, then a start and end position
1.1969 + for a section of the file can be specified. Both of these parameters specify offsets
1.1970 + from the start of the file in bytes.
1.1971 +
1.1972 +@param aInfo A structure describing a group of block maps.
1.1973 +
1.1974 +@param aStartPos A start position for a desired section of the file.
1.1975 +
1.1976 +@param aEndPos An end position for a desired section of the file. If not passed, then the end of the
1.1977 + file is assumed.
1.1978 +
1.1979 +@return KErrNone until the end of the file or the file section is successfully reached;
1.1980 + KErrCompletion if the end of the file is reached;
1.1981 + KErrNotSupported if the file system does not support Block Mapping or the media is either removable or not pageable.
1.1982 +*/
1.1983 +EFSRV_EXPORT_C TInt RFile::BlockMap(SBlockMapInfo& aInfo, TInt64& aStartPos, TInt64 aEndPos, TInt aBlockMapUsage) const
1.1984 + {
1.1985 + TRACE7(UTF::EBorder, UTraceModuleEfsrv::EFileBlockMap, MODULEUID,
1.1986 + Session().Handle(), SubSessionHandle(), I64LOW(aStartPos), I64HIGH(aEndPos), I64LOW(aEndPos), I64HIGH(aEndPos), aBlockMapUsage);
1.1987 +
1.1988 + SBlockMapArgs args;
1.1989 + args.iStartPos = aStartPos;
1.1990 + args.iEndPos = aEndPos;
1.1991 + TPckg<SBlockMapInfo> pkInfo(aInfo);
1.1992 + TPckg<SBlockMapArgs> pkArgs(args);
1.1993 + TInt r = SendReceive(EFsBlockMap, TIpcArgs(&pkInfo, &pkArgs, aBlockMapUsage));
1.1994 + if(r==KErrNone)
1.1995 + aStartPos = args.iStartPos;
1.1996 +
1.1997 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileBlockMapReturn, MODULEUID, r);
1.1998 + return r;
1.1999 + }
1.2000 +
1.2001 +
1.2002 +#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
1.2003 +/**
1.2004 +Opens an existing file for reading or writing.
1.2005 +
1.2006 +If the file does not already exist, an error is returned.
1.2007 +
1.2008 +This is equivalent to calling RFile::Open except that this function
1.2009 +can open files of size greater than 2GB - 1 also.
1.2010 +
1.2011 +Notes:
1.2012 +
1.2013 +1. To close the file, use Close()
1.2014 +
1.2015 +2. Attempting to open a file with the read-only attribute using the EFileWrite
1.2016 + access mode results in an error.
1.2017 +
1.2018 +3. After a file has been opened, the current write position is set to the start
1.2019 + of the file.
1.2020 + If necessary, use RFile64::Seek() to move to a different position within
1.2021 + the file.
1.2022 +
1.2023 +4. It enables big file support to handle files whose size are greater then 2GB-1
1.2024 +
1.2025 +@param aFs The file server session.
1.2026 +@param aName The name of the file. Any path components (i.e. drive letter
1.2027 + or directory), which are not specified, are taken from
1.2028 + the session path.
1.2029 +@param aMode The mode in which the file is opened. See TFileMode.
1.2030 +
1.2031 +@return KErrNone if successful, otherwise one of the other system-wide
1.2032 + error codes.
1.2033 +
1.2034 +@see TFileMode
1.2035 +@see RFile::Open()
1.2036 +
1.2037 +@capability Dependent If the path for aName is /Sys and aMode is neither
1.2038 + EFileShareReadersOnly nor EFileRead then Tcb capability is required.
1.2039 +@capability Dependent If the path for aName is /Sys and aMode is either
1.2040 + EFileShareReadersOnly or EFileRead then Allfiles capability is required.
1.2041 +@capability Dependent If the path for aName begins with /Private and does not match this process'
1.2042 + SID then AllFiles capability is required.
1.2043 +@capability Dependent If the path for aName begins with /Resource and aMode is neither
1.2044 + EFileShareReadersOrWriters|EFileRead nor EFileShareReadersOnly
1.2045 + nor EFileRead then Tcb capability is required.
1.2046 +
1.2047 +*/
1.2048 +EFSRV_EXPORT_C TInt RFile64::Open(RFs& aFs,const TDesC& aName,TUint aFileMode)
1.2049 + {
1.2050 + TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileOpen, MODULEUID, aFs.Handle(), aFileMode, aName);
1.2051 +
1.2052 + TInt r = CreateSubSession(aFs,EFsFileOpen,TIpcArgs(&aName,aFileMode|EFileBigFile));
1.2053 +
1.2054 + TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileOpenReturn, MODULEUID, r, SubSessionHandle());
1.2055 + return r;
1.2056 + }
1.2057 +
1.2058 +/**
1.2059 +Creates and opens a new file for writing.
1.2060 +
1.2061 +If the file already exists, an error is returned.
1.2062 +
1.2063 +If the resulting path does not exist, then the operation cannot proceed and
1.2064 +the function returns an error code.
1.2065 +
1.2066 +This is equivalent to calling RFile::Create except that the file created with
1.2067 +this function can grow beyond 2GB - 1 also.
1.2068 +
1.2069 +Notes:
1.2070 +
1.2071 +1. To close the file, use Close()
1.2072 +
1.2073 +2. It automatically sets the file's archive attribute.
1.2074 +
1.2075 +3. It enables big file support to handle files whose size are greater then 2GB-1
1.2076 +
1.2077 +
1.2078 +@param aFs The file server session.
1.2079 +@param aName The name of the file. Any path components (i.e. drive letter
1.2080 + or directory), which are not specified, are taken from
1.2081 + the session path.
1.2082 +@param aMode The mode in which the file is opened. The access mode is
1.2083 + automatically set to EFileWrite. See TFileMode.
1.2084 +
1.2085 +@return KErrNone if successful, otherwise one of the other system-wide
1.2086 + error codes.
1.2087 +
1.2088 +@see RFile::Create()
1.2089 +@see TFileMode
1.2090 +
1.2091 +@capability Dependent If the path in aName starts with /Sys then capability Tcb is required
1.2092 +@capability Dependent If the path in aName starts with /Resource then capability Tcb is required
1.2093 +@capability Dependent If the path in aName starts with /Private and does not match this process'
1.2094 + SID then AllFiles capability is required.
1.2095 +
1.2096 +*/
1.2097 +EFSRV_EXPORT_C TInt RFile64::Create(RFs& aFs,const TDesC& aName,TUint aFileMode)
1.2098 + {
1.2099 + TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileCreate, MODULEUID, aFs.Handle(), aFileMode, aName);
1.2100 +
1.2101 + TInt r = CreateSubSession(aFs,EFsFileCreate,TIpcArgs(&aName,aFileMode|EFileBigFile));
1.2102 +
1.2103 + TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileCreateReturn, MODULEUID, r, SubSessionHandle());
1.2104 + return r;
1.2105 + }
1.2106 +
1.2107 +/**
1.2108 +Opens a file for writing, replacing the content of any existing file of the
1.2109 +same name if it exists, or creating a new file if it does not exist.
1.2110 +
1.2111 +This is equivalent to calling RFile::Replace except that the file created or replaced
1.2112 +with this function can grow beyond 2GB - 1 also.
1.2113 +
1.2114 +
1.2115 +If the resulting path exists, then:
1.2116 +
1.2117 +- the length of an existing file with the same filename is re-set to zero
1.2118 +
1.2119 +- a new file is created, if no existing file with the same filename can be found.
1.2120 +
1.2121 +If the resulting path does not exist, then the operation cannot proceed and
1.2122 +the function returns an error code.
1.2123 +
1.2124 +Notes:
1.2125 +
1.2126 +- To close the file, use Close(), defined in the base class RFsBase.
1.2127 +
1.2128 +- It automatically sets the file's archive attribute.
1.2129 +
1.2130 +- It enables big file support to handle files whose size are greater then 2GB-1
1.2131 +
1.2132 +
1.2133 +@param aFs The file server session.
1.2134 +@param aName The name of the file. Any path components (i.e. drive letter
1.2135 + or directory), which are not specified, are taken from
1.2136 + the session path.
1.2137 +@param aMode The mode in which the file is opened. The access mode is
1.2138 + automatically set to EFileWrite. See TFileMode.
1.2139 +
1.2140 +@return KErrNone if successful, otherwise one of the other system-wide
1.2141 + error codes.
1.2142 +
1.2143 +@see TFileMode
1.2144 +@see RFile::Replace()
1.2145 +
1.2146 +@capability Dependent If the path in aName starts with /Sys then capability Tcb is required
1.2147 +@capability Dependent If the path in aName starts with /Resource then capability Tcb is required
1.2148 +@capability Dependent If the path in aName starts with /Private and does not match this process'
1.2149 + SID then AllFiles capability is required.
1.2150 +
1.2151 +*/
1.2152 +EFSRV_EXPORT_C TInt RFile64::Replace(RFs& aFs,const TDesC& aName,TUint aFileMode)
1.2153 + {
1.2154 + TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileReplace, MODULEUID, aFs.Handle(), aFileMode, aName);
1.2155 +
1.2156 + TInt r = CreateSubSession(aFs,EFsFileReplace,TIpcArgs(&aName,aFileMode|EFileBigFile));
1.2157 +
1.2158 + TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileReplaceReturn, MODULEUID, r, SubSessionHandle());
1.2159 + return r;
1.2160 + }
1.2161 +
1.2162 +
1.2163 +/**
1.2164 +Creates and opens a temporary file with a unique name for writing and reading.
1.2165 +This is equivalent to calling RFile::Temp except that the file created
1.2166 +with this function can grow beyond 2GB - 1 also.
1.2167 +
1.2168 +
1.2169 +Notes:
1.2170 +
1.2171 +1. To close the file, use Close()
1.2172 +2. It enables big file support to handle files whose size are greater then 2GB-1
1.2173 +
1.2174 +@param aFs The file server session.
1.2175 +@param aPath The directory in which the file is created.
1.2176 +@param aName On return, contains the full path and file name of the file.
1.2177 + The filename is guaranteed to be unique within the directory
1.2178 + specified by aPath.
1.2179 +@param aMode The mode in which the file is opened. The access mode is
1.2180 + automatically set to EFileWrite. See TFileMode.
1.2181 +
1.2182 +@return KErrNone if successful, otherwise one of the other system-wide
1.2183 + error codes.
1.2184 +
1.2185 +@see TFileMode
1.2186 +@see RFile::Temp()
1.2187 +
1.2188 +@capability Dependent If aPath starts with /Sys then capability Tcb is required
1.2189 +@capability Dependent If aPath starts with /Resource then capability Tcb is required
1.2190 +@capability Dependent If aPath starts with /Private and does not match this process'
1.2191 + SID then AllFiles capability is required.
1.2192 +*/
1.2193 +EFSRV_EXPORT_C TInt RFile64::Temp(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode)
1.2194 + {
1.2195 + TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileTemp, MODULEUID, aFs.Handle(), aPath, aFileMode);
1.2196 + TInt r = CreateSubSession(aFs,EFsFileTemp,TIpcArgs(&aPath,aFileMode|EFileBigFile,&aName));
1.2197 + TRACERETMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileTempReturn, MODULEUID, r, SubSessionHandle(), aName);
1.2198 + return r;
1.2199 + }
1.2200 +
1.2201 +
1.2202 +/**
1.2203 +Allows a server to adopt an already open file from a client.
1.2204 +The client's RFs and RFile or RFile64 handles are contained in message slots within aMsg.
1.2205 +
1.2206 +Assumes that the client's RFs and RFile or RFile64 handles have been sent to the server
1.2207 +using TransferToServer().
1.2208 +
1.2209 +This is equivalent to calling RFile::AdoptFromClient
1.2210 +except that the file adopted can be enlarged to sizes beyond 2GB-1.
1.2211 +
1.2212 +Note:
1.2213 +If a RFile handle is received from the client then enlarging the file beyond
1.2214 +2GB-1 might result in inconsistent behaviour by the client, since it(client) would
1.2215 +not be able to handle files of size greater than 2GB-1.
1.2216 +
1.2217 +If a RFile64 handle is received from the client then enlarging the file beyond
1.2218 +2GB-1 should not cause any issues since the client would be
1.2219 +capable of handling files of size greater than 2GB-1.
1.2220 +
1.2221 +This RFile or RFile64 will own it's RFs session so that when the sub-session (RFile or RFile64)
1.2222 +is closed so will the RFs session.
1.2223 +
1.2224 +@param aMsg The message received from the client
1.2225 +@param aFsHandleIndex The index that identifies the message slot
1.2226 + of a file server session (RFs) handle
1.2227 +@param aFileHandleIndex The index that identifies the message slot
1.2228 + of the sub-session (RFile or RFile64) handle of the already opened file
1.2229 +
1.2230 +@return KErrNone if successful, otherwise one of the other system-wide
1.2231 + error codes.
1.2232 +*/
1.2233 +EFSRV_EXPORT_C TInt RFile64::AdoptFromClient(const RMessage2& aMsg, TInt aFsHandleIndex, TInt aFileHandleIndex)
1.2234 + {
1.2235 + TInt fileHandle = NULL;
1.2236 +
1.2237 + TInt r = KErrNone;
1.2238 + if (aFileHandleIndex == 0)
1.2239 + fileHandle = aMsg.Int0();
1.2240 + else if (aFileHandleIndex == 1)
1.2241 + fileHandle = aMsg.Int1();
1.2242 + else if (aFileHandleIndex == 2)
1.2243 + fileHandle = aMsg.Int2();
1.2244 + else if (aFileHandleIndex == 3)
1.2245 + fileHandle = aMsg.Int3();
1.2246 + else
1.2247 + r = KErrArgument;
1.2248 +
1.2249 +#ifdef SYMBIAN_FTRACE_ENABLE
1.2250 + TInt handle = NULL;
1.2251 + if (aFsHandleIndex == 0)
1.2252 + handle = aMsg.Int0();
1.2253 + else if (aFsHandleIndex == 1)
1.2254 + handle = aMsg.Int1();
1.2255 + else if (aFsHandleIndex == 2)
1.2256 + handle = aMsg.Int2();
1.2257 + else if (aFsHandleIndex == 3)
1.2258 + handle = aMsg.Int3();
1.2259 + TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClient, MODULEUID, handle, fileHandle, aFsHandleIndex, aFileHandleIndex);
1.2260 +#endif
1.2261 +
1.2262 + if (r != KErrNone)
1.2263 + {
1.2264 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClientReturn, MODULEUID, r);
1.2265 + return r;
1.2266 + }
1.2267 +
1.2268 + // Duplicates the file server (RFs) session handle identified by an
1.2269 + // existing handle contained in the message slot at index aFsHandleIndex
1.2270 + RFs fs;
1.2271 + r = fs.Open(aMsg, aFsHandleIndex, KFileServerPolicy);
1.2272 + if (r != KErrNone)
1.2273 + {
1.2274 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClientReturn, MODULEUID, r);
1.2275 + return r;
1.2276 + }
1.2277 +
1.2278 + //return CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(fileHandle));
1.2279 + // Slot 1: Indicate Large File Supportis required.
1.2280 + r = CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(fileHandle, KFileAdopt64));
1.2281 +
1.2282 + TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClientReturn, MODULEUID, r, Session().Handle(), SubSessionHandle());
1.2283 +
1.2284 + return r;
1.2285 + }
1.2286 +
1.2287 +
1.2288 +/**
1.2289 +Allows a client to adopt an already open file from a server.
1.2290 +
1.2291 +Assumes that the server's RFs and RFile or RFile64 handles have been sent to the
1.2292 +client using TransferToClient().
1.2293 +
1.2294 +This is equivalent to calling RFile::AdoptFromServer
1.2295 +except that the file adopted can be enlarged to sizes beyond 2GB-1.
1.2296 +
1.2297 +Note:
1.2298 +If a RFile handle is received from the server then enlarging the file beyond
1.2299 +2GB-1 might result in inconsistent behaviour by the server, since it(server) would
1.2300 +not be able to handle files of size greater than 2GB-1.
1.2301 +
1.2302 +If a RFile64 handle is received from the server then enlarging the file beyond
1.2303 +2GB-1 should not cause any issues since the server would be capable of
1.2304 +handling files of size greater than 2GB-1.
1.2305 +
1.2306 +This RFile or RFile64 will own it's RFs session so that when the sub-session (RFile or RFile64)
1.2307 +is closed so will the RFs session.
1.2308 +
1.2309 +@param aFsHandle The file server session (RFs) handle
1.2310 +@param aFileHandle The file (RFile or RFile64) handle of the already opened file
1.2311 +
1.2312 +@return KErrNone if successful, otherwise one of the other system-wide
1.2313 + error codes.
1.2314 +*/
1.2315 +EFSRV_EXPORT_C TInt RFile64::AdoptFromServer(TInt aFsHandle, TInt aFileHandle)
1.2316 + {
1.2317 + TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromServer, MODULEUID, aFsHandle, aFileHandle);
1.2318 +
1.2319 + RFs fs;
1.2320 + TInt r = fs.SetReturnedHandle(aFsHandle, KFileServerPolicy);
1.2321 + if (r != KErrNone)
1.2322 + {
1.2323 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromServerReturn, MODULEUID, r);
1.2324 + return r;
1.2325 + }
1.2326 +
1.2327 + //return(CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(aFileHandle)));
1.2328 + // Slot 1: Indicate Large File Supportis required.
1.2329 + r = CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(aFileHandle, KFileAdopt64));
1.2330 +
1.2331 + TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromServerReturn, MODULEUID, r, Session().Handle(), SubSessionHandle());
1.2332 +
1.2333 + return r;
1.2334 + }
1.2335 +
1.2336 +
1.2337 +/**
1.2338 +Allows a server to adopt an already open file from a client process.
1.2339 +The client's file-server (RFs) and file (RFile or RFile64) handles are contained in
1.2340 +this process's environment data slots.
1.2341 +
1.2342 +Assumes that the client's RFs and RFile or RFile64 handles have been sent to the server process
1.2343 +using TransferToProcess().
1.2344 +
1.2345 +This is equivalent to calling RFile::AdoptFromCreator
1.2346 +except that the file adopted can be enlarged to sizes beyond 2GB-1.
1.2347 +
1.2348 +Note:
1.2349 +If a RFile handle is received from the client then enlarging the file beyond
1.2350 +2GB-1 might result in inconsistent behaviour by the client, since it(client) would
1.2351 +not be able to handle files of size greater than 2GB-1.
1.2352 +
1.2353 +If a RFile64 handle is received from the client then enlarging the file beyond
1.2354 +2GB-1 should not cause any issues since the client would be capable of
1.2355 +handling files of size greater than 2GB-1.
1.2356 +
1.2357 +This RFile or RFile64 will own it's RFs session so that when the sub-session (RFile or RFile64)
1.2358 +is closed so will the RFs session.
1.2359 +
1.2360 +@param aFsHandleIndex An index that identifies the slot in the process
1.2361 + environment data that contains the file server session (RFs) handle
1.2362 +@param aFileHandleIndex An index that identifies the slot in the process
1.2363 + environment data that contains the sub-session (RFile or RFile64) handle
1.2364 + of the already opened file
1.2365 +
1.2366 +@return KErrNone if successful, otherwise one of the other system-wide
1.2367 + error codes.
1.2368 +*/
1.2369 +EFSRV_EXPORT_C TInt RFile64::AdoptFromCreator(TInt aFsHandleIndex, TInt aFileHandleIndex)
1.2370 + {
1.2371 + TInt fileHandle;
1.2372 + TInt r = User::GetTIntParameter(aFileHandleIndex, fileHandle);
1.2373 +
1.2374 + TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreator, MODULEUID, fileHandle, aFsHandleIndex, aFileHandleIndex);
1.2375 +
1.2376 + if (r != KErrNone)
1.2377 + {
1.2378 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreatorReturn, MODULEUID, r);
1.2379 + return r;
1.2380 + }
1.2381 +
1.2382 +
1.2383 + // Duplicates the file server (RFs) session handle identified by an
1.2384 + // existing handle contained in the environment slot at index aFsHandleIndex
1.2385 + RFs fs;
1.2386 + r = fs.Open(aFsHandleIndex, KFileServerPolicy);
1.2387 + if (r != KErrNone)
1.2388 + {
1.2389 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreatorReturn, MODULEUID, r);
1.2390 + return r;
1.2391 + }
1.2392 +
1.2393 + //return(CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(fileHandle)));
1.2394 + // Slot 1: Indicate Large File Supportis required.
1.2395 + r = CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(fileHandle, KFileAdopt64));
1.2396 +
1.2397 + TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreatorReturn, MODULEUID, r, Session().Handle(), SubSessionHandle());
1.2398 +
1.2399 + return r;
1.2400 + }
1.2401 +
1.2402 +
1.2403 +/**
1.2404 +Reads from the file at the specified offset within the file
1.2405 +
1.2406 +This is a synchronous function.
1.2407 +
1.2408 +This is equivalent to calling RFile::Read(TInt, TDes8&) except that this function
1.2409 +accepts TInt64, instead of TInt, as its first parameter. This allows to specify
1.2410 +the read position beyond 2GB-1.
1.2411 +
1.2412 +@see RFile::Read(TInt aPos, TDes8& aDes)
1.2413 +
1.2414 +Note that when an attempt is made to read beyond the end of the file,
1.2415 +no error is returned.
1.2416 +The descriptor's length is set to the number of bytes read into it.
1.2417 +Therefore, when reading through a file, the end of file has been reached
1.2418 +when the descriptor length, as returned by TDesC8::Length(), is zero.
1.2419 +
1.2420 +@param aPos Position of first byte to be read. This is an offset from
1.2421 + the start of the file. If no position is specified, reading
1.2422 + begins at the current file position.
1.2423 + If aPos is beyond the end of the file, the function returns
1.2424 + a zero length descriptor.
1.2425 +
1.2426 +@param aDes The descriptor into which binary data is read. Any existing content
1.2427 + is overwritten. On return, its length is set to the number of
1.2428 + bytes read.
1.2429 +
1.2430 +@return KErrNone if successful, otherwise one of the other system-wide error
1.2431 + codes.
1.2432 +
1.2433 +@panic FSCLIENT 19 if aPos is negative.
1.2434 +*/
1.2435 +EFSRV_EXPORT_C TInt RFile64::Read(TInt64 aPos, TDes8& aDes) const
1.2436 + {
1.2437 + TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileRead3, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aDes.MaxLength());
1.2438 +
1.2439 + __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative));
1.2440 +
1.2441 + TInt r;
1.2442 + if (!(I64HIGH(aPos+1)))
1.2443 + {
1.2444 + r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),I64LOW(aPos)));
1.2445 + }
1.2446 + else
1.2447 + {
1.2448 + TPckgC<TInt64> pkPos(aPos);
1.2449 + r = SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.MaxLength(),&pkPos));
1.2450 + }
1.2451 +
1.2452 + TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead3Return, MODULEUID, r, aDes.Length());
1.2453 +
1.2454 + return r;
1.2455 + }
1.2456 +
1.2457 +
1.2458 +/**
1.2459 +Reads from the file at the specified offset within the file.
1.2460 +
1.2461 +This is an asynchronous function.
1.2462 +
1.2463 +This is equivalent to calling RFile::Read(TInt, TDes8&, TRequestStatus&) except
1.2464 +that this function accepts TInt64, instead of TInt, as its first parameter.
1.2465 +This allows to specify the read position beyond 2GB-1.
1.2466 +
1.2467 +@see RFile::Read(TInt aPos, TDes8& aDes, TRequestStatus& aStatus)
1.2468 +
1.2469 +Note that when an attempt is made to read beyond the end of the file,
1.2470 +no error is returned.
1.2471 +The descriptor's length is set to the number of bytes read into it.
1.2472 +Therefore, when reading through a file, the end of file has been reached
1.2473 +when the descriptor length, as returned by TDesC8::Length(), is zero.
1.2474 +
1.2475 +@param aPos Position of first byte to be read. This is an offset from
1.2476 + the start of the file. If no position is specified,
1.2477 + reading begins at the current file position.
1.2478 + If aPos is beyond the end of the file, the function returns
1.2479 + a zero length descriptor.
1.2480 +
1.2481 +@param aDes The descriptor into which binary data is read. Any existing
1.2482 + content is overwritten. On return, its length is set to
1.2483 + the number of bytes read.
1.2484 + NB: this function is asynchronous and the request that it
1.2485 + represents may not complete until some time after the call
1.2486 + to the function has returned. It is important, therefore, that
1.2487 + this descriptor remain valid, or remain in scope, until you have
1.2488 + been notified that the request is complete.
1.2489 +
1.2490 +@param aStatus The request status. On completion, contains an error code of KErrNone
1.2491 + if successful, otherwise one of the other system-wide error codes.
1.2492 +
1.2493 +@panic FSCLIENT 19 if aPos is negative.
1.2494 +*/
1.2495 +EFSRV_EXPORT_C void RFile64::Read(TInt64 aPos, TDes8& aDes, TRequestStatus& aStatus) const
1.2496 + {
1.2497 + TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileRead4, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aDes.MaxLength(), &aStatus);
1.2498 +
1.2499 + __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative));
1.2500 + if (!(I64HIGH(aPos+1)))
1.2501 + {
1.2502 + RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),I64LOW(aPos)),aStatus);
1.2503 + }
1.2504 + else
1.2505 + {
1.2506 + TPckgC<TInt64> pkPos(aPos);
1.2507 + RSubSessionBase::SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.MaxLength(),&pkPos),aStatus);
1.2508 + }
1.2509 +
1.2510 + TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead4Return, MODULEUID);
1.2511 + }
1.2512 +
1.2513 +
1.2514 +/**
1.2515 +Reads the specified number of bytes of binary data from the file at a specified
1.2516 +offset within the file.
1.2517 +
1.2518 +This is a synchronous function.
1.2519 +
1.2520 +This is equivalent to calling RFile::Read(TInt, TDes8&, TInt) except
1.2521 +that this function accepts TInt64, instead of TInt, as its first parameter.
1.2522 +This allows to specify the read position beyond 2GB-1.
1.2523 +
1.2524 +@see RFile::Read(TInt aPos, TDes8& aDes, TInt aLength)
1.2525 +
1.2526 +Note that when an attempt is made to read beyond the end of the file,
1.2527 +no error is returned.
1.2528 +The descriptor's length is set to the number of bytes read into it.
1.2529 +Therefore, when reading through a file, the end of file has been reached
1.2530 +when the descriptor length, as returned by TDesC8::Length(), is zero.
1.2531 +Assuming aLength is less than the maximum length of the descriptor, the only
1.2532 +circumstances in which Read() can return fewer bytes than requested is when
1.2533 +the end of file is reached or if an error has occurred.
1.2534 +
1.2535 +@param aPos Position of first byte to be read. This is an offset from
1.2536 + the start of the file. If no position is specified,
1.2537 + reading begins at the current file position.
1.2538 + If aPos is beyond the end of the file, the function returns
1.2539 + a zero length descriptor.
1.2540 +
1.2541 +@param aDes The descriptor into which binary data is read. Any existing
1.2542 + contents are overwritten. On return, its length is set to
1.2543 + the number of bytes read.
1.2544 +@param aLength The number of bytes to read from the file into the descriptor.
1.2545 + If an attempt is made to read more bytes than the descriptor's
1.2546 + maximum length, then the function updates aStatus parameter with KErrOverflow.
1.2547 + It must not be negative otherwise the function updates aStatus with KErrArgument.
1.2548 +
1.2549 +@return KErrNone if successful, otherwise one of the other system-wide
1.2550 + error codes.
1.2551 +
1.2552 +@panic FSCLIENT 19 if aPos is negative.
1.2553 +*/
1.2554 +EFSRV_EXPORT_C TInt RFile64::Read(TInt64 aPos, TDes8& aDes, TInt aLength) const
1.2555 + {
1.2556 + TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileRead3, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aLength);
1.2557 +
1.2558 + __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative));
1.2559 + if (aLength==0)
1.2560 + {
1.2561 + aDes.Zero();
1.2562 + return(KErrNone);
1.2563 + }
1.2564 + else if(aLength>aDes.MaxLength())
1.2565 + {
1.2566 + return(KErrOverflow);
1.2567 + }
1.2568 +
1.2569 + TInt r;
1.2570 + if (!(I64HIGH(aPos+1)))
1.2571 + {
1.2572 + r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,I64LOW(aPos)));
1.2573 + }
1.2574 + else
1.2575 + {
1.2576 + TPckgC<TInt64> pkPos(aPos);
1.2577 + r = SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos));
1.2578 + }
1.2579 +
1.2580 + TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead3Return, MODULEUID, r, aDes.Length());
1.2581 +
1.2582 + return r;
1.2583 + }
1.2584 +
1.2585 +
1.2586 +/**
1.2587 +Reads the specified number of bytes of binary data from the file at a specified
1.2588 +offset within the file.
1.2589 +
1.2590 +This is an asynchronous function.
1.2591 +
1.2592 +This is equivalent to calling RFile::Read(TInt, TDes8&, TInt, TRequestStatus&) except
1.2593 +that this function accepts TInt64, instead of TInt, as its first parameter.
1.2594 +This allows to specify the read position beyond 2GB-1.
1.2595 +
1.2596 +@see RFile::Read(TInt aPos, TDes8& aDes,TInt aLength,TRequestStatus& aStatus)
1.2597 +
1.2598 +Note that when an attempt is made to read beyond the end of the file,
1.2599 +no error is returned.
1.2600 +The descriptor's length is set to the number of bytes read into it.
1.2601 +Therefore, when reading through a file, the end of file has been reached
1.2602 +when the descriptor length, as returned by TDesC8::Length(), is zero.
1.2603 +Assuming aLength is less than the maximum length of the descriptor, the only
1.2604 +circumstances in which Read() can return fewer bytes than requested is when
1.2605 +the end of file is reached or if an error has occurred.
1.2606 +
1.2607 +@param aPos Position of first byte to be read. This is an offset from
1.2608 + the start of the file. If no position is specified,
1.2609 + reading begins at the current file position.
1.2610 + If aPos is beyond the end of the file, the function returns
1.2611 + a zero length descriptor.
1.2612 +
1.2613 +@param aDes The descriptor into which binary data is read. Any existing
1.2614 + contents are overwritten. On return, its length is set to
1.2615 + the number of bytes read.
1.2616 + NB: this function is asynchronous and the request that it
1.2617 + represents may not complete until some time after the call
1.2618 + to the function has returned. It is important, therefore, that
1.2619 + this descriptor remain valid, or remain in scope, until you have
1.2620 + been notified that the request is complete.
1.2621 +
1.2622 +@param aLength The number of bytes to read from the file into the descriptor.
1.2623 + If an attempt is made to read more bytes than the descriptor's
1.2624 + maximum length, then the function returns KErrOverflow.
1.2625 + It must not be negative otherwise the function returns KErrArgument.
1.2626 +
1.2627 +@param aStatus Request status. On completion contains KErrNone if successful,
1.2628 + otherwise one of the other system-wide error codes.
1.2629 +
1.2630 +@panic FSCLIENT 19 if aPos is negative.
1.2631 +*/
1.2632 +EFSRV_EXPORT_C void RFile64::Read(TInt64 aPos, TDes8& aDes, TInt aLength,TRequestStatus& aStatus) const
1.2633 + {
1.2634 + TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileRead4, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aLength, &aStatus);
1.2635 +
1.2636 + __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative));
1.2637 + if (aLength==0)
1.2638 + {
1.2639 + aDes.Zero();
1.2640 + TRequestStatus* req=(&aStatus);
1.2641 + User::RequestComplete(req,KErrNone);
1.2642 + return;
1.2643 + }
1.2644 + else if(aLength>aDes.MaxLength())
1.2645 + {
1.2646 + TRequestStatus* req=(&aStatus);
1.2647 + User::RequestComplete(req,KErrOverflow);
1.2648 + return;
1.2649 + }
1.2650 +
1.2651 + if (!(I64HIGH(aPos+1)))
1.2652 + {
1.2653 + RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,I64LOW(aPos)),aStatus);
1.2654 + }
1.2655 + else
1.2656 + {
1.2657 + TPckgC<TInt64> pkPos(aPos);
1.2658 + RSubSessionBase::SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos),aStatus);
1.2659 + }
1.2660 +
1.2661 + TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead4Return, MODULEUID);
1.2662 + }
1.2663 +
1.2664 +
1.2665 +/**
1.2666 +Writes to the file at the specified offset within the file
1.2667 +
1.2668 +This is a synchronous function.
1.2669 +
1.2670 +This is equivalent to calling RFile::Write(TInt, TDes8&) except
1.2671 +that this function accepts TInt64, instead of TInt, as its first parameter.
1.2672 +This allows to specify the write position beyond 2GB-1.
1.2673 +
1.2674 +@see RFile::Write(TInt aPos, TDes8& aDes)
1.2675 +
1.2676 +
1.2677 +@param aPos The offset from the start of the file at which the first
1.2678 + byte is written.
1.2679 + If a position beyond the end of the file is specified, then
1.2680 + the write operation begins at the end of the file.
1.2681 + If the position has been locked, then the write fails.
1.2682 +
1.2683 +@param aDes The descriptor from which binary data is written. The function writes
1.2684 + the entire contents of aDes to the file.
1.2685 +
1.2686 +@return KErrNone if successful, otherwise one of the other system-wide error
1.2687 + codes.
1.2688 +
1.2689 +@panic FSCLIENT 19 if aPos is negative.
1.2690 +*/
1.2691 +EFSRV_EXPORT_C TInt RFile64::Write(TInt64 aPos, const TDesC8& aDes)
1.2692 + {
1.2693 + TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileWrite3, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aDes.Length());
1.2694 +
1.2695 + __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative));
1.2696 +
1.2697 + TInt r;
1.2698 + if (!(I64HIGH(aPos+1)))
1.2699 + {
1.2700 + r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),I64LOW(aPos)));
1.2701 + }
1.2702 + else
1.2703 + {
1.2704 + TPckgC<TInt64> pkPos(aPos);
1.2705 + r = SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.Length(),&pkPos));
1.2706 + }
1.2707 +
1.2708 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite3Return, MODULEUID, r);
1.2709 + return r;
1.2710 + }
1.2711 +
1.2712 +
1.2713 +/**
1.2714 +Writes to the file at the specified offset within the file
1.2715 +
1.2716 +This is an asynchronous function.
1.2717 +
1.2718 +This is equivalent to calling RFile::Write(TInt, TDes8&, TRequestStatus&) except
1.2719 +that this function accepts TInt64, instead of TInt, as its first parameter.
1.2720 +This allows to specify the write position beyond 2GB-1.
1.2721 +
1.2722 +@see RFile::Write(TInt aPos, TDes8& aDes, TRequestStatus& aStatus)
1.2723 +
1.2724 +
1.2725 +@param aPos The offset from the start of the file at which the first
1.2726 + byte is written.
1.2727 + If a position beyond the end of the file is specified, then
1.2728 + the write operation begins at the end of the file.
1.2729 + If the position has been locked, then the write fails.
1.2730 +
1.2731 +@param aDes The descriptor from which binary data is written. The function
1.2732 + writes the entire contents of aDes to the file.
1.2733 + NB: this function is asynchronous and the request that it
1.2734 + represents may not complete until some time after the call
1.2735 + to the function has returned. It is important, therefore, that
1.2736 + this descriptor remain valid, or remain in scope, until you have
1.2737 + been notified that the request is complete.
1.2738 +
1.2739 +@param aStatus Request status. On completion contains KErrNone if successful,
1.2740 + otherwise one of the other system-wide error codes.
1.2741 +
1.2742 +@panic FSCLIENT 19 if aPos is negative.
1.2743 +*/
1.2744 +EFSRV_EXPORT_C void RFile64::Write(TInt64 aPos, const TDesC8& aDes,TRequestStatus& aStatus)
1.2745 + {
1.2746 + TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileWrite4, MODULEUID, Session().Handle(), SubSessionHandle(), aDes.Length(), &aStatus);
1.2747 +
1.2748 + __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative));
1.2749 +
1.2750 + if (!(I64HIGH(aPos+1)))
1.2751 + {
1.2752 + RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),I64LOW(aPos)),aStatus);
1.2753 + }
1.2754 + else
1.2755 + {
1.2756 + TPckgC<TInt64> pkPos(aPos);
1.2757 + RSubSessionBase::SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.Length(),&pkPos),aStatus);
1.2758 + }
1.2759 +
1.2760 + TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite4Return, MODULEUID);
1.2761 + }
1.2762 +
1.2763 +
1.2764 +/**
1.2765 +Writes the specified number of bytes to the file at the specified offset within the file.
1.2766 +
1.2767 +This is a synchronous function.
1.2768 +
1.2769 +This is equivalent to calling RFile::Write(TInt, TDes8&, TInt) except
1.2770 +that this function accepts TInt64, instead of TInt, as its first parameter.
1.2771 +This allows to specify the write position beyond 2GB-1.
1.2772 +
1.2773 +@see RFile::Write(TInt aPos, TDes8& aDes, TInt aLength)
1.2774 +
1.2775 +@param aPos The offset from the start of the file at which the first
1.2776 + byte is written.
1.2777 + If a position beyond the end of the file is specified, then
1.2778 + the write operation begins at the end of the file.
1.2779 + If the position has been locked, then the write fails.
1.2780 +
1.2781 +@param aDes The descriptor from which binary data is written.
1.2782 +@param aLength The number of bytes to be written from aDes .
1.2783 + It must not be negative.
1.2784 +
1.2785 +@return KErrNone if successful; KErrArgument if aLength is negative;
1.2786 + otherwise one of the other system-wide error codes.
1.2787 +
1.2788 +@panic FSCLIENT 19 if aPos is negative.
1.2789 +*/
1.2790 +EFSRV_EXPORT_C TInt RFile64::Write(TInt64 aPos, const TDesC8& aDes,TInt aLength)
1.2791 + {
1.2792 + TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1, MODULEUID, Session().Handle(), SubSessionHandle(), aLength);
1.2793 +
1.2794 + __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative));
1.2795 +
1.2796 + TInt r;
1.2797 + if (!(I64HIGH(aPos+1)))
1.2798 + {
1.2799 + r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,I64LOW(aPos)));
1.2800 + }
1.2801 + else
1.2802 + {
1.2803 + TPckgC<TInt64> pkPos(aPos);
1.2804 + r = SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos));
1.2805 + }
1.2806 +
1.2807 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1Return, MODULEUID, r);
1.2808 + return r;
1.2809 + }
1.2810 +
1.2811 +
1.2812 +/**
1.2813 +Writes the specified number of bytes to the file at the specified offset within the file.
1.2814 +
1.2815 +This is an asynchronous function.
1.2816 +
1.2817 +This is equivalent to calling RFile::Write(TInt, TDes8&, TInt, TRequestStatus&) except
1.2818 +that this function accepts TInt64, instead of TInt, as its first parameter.
1.2819 +This allows to specify the write position beyond 2GB-1.
1.2820 +
1.2821 +@see RFile::Write(TInt aPos, TDes8& aDes, TInt aLength, TRequestStatus &aStatus)
1.2822 +
1.2823 +@param aPos The offset from the start of the file at which the first
1.2824 + byte is written.
1.2825 + If a position beyond the end of the file is specified, then
1.2826 + the write operation begins at the end of the file.
1.2827 + If the position has been locked, then the write fails.
1.2828 +
1.2829 +@param aDes The descriptor from which binary data is written.
1.2830 + NB: this function is asynchronous and the request that it
1.2831 + represents may not complete until some time after the call
1.2832 + to the function has returned. It is important, therefore, that
1.2833 + this descriptor remain valid, or remain in scope, until you have
1.2834 + been notified that the request is complete.
1.2835 +
1.2836 +@param aLength The number of bytes to be written from aDes.
1.2837 + It must not be negative.
1.2838 +
1.2839 +@param aStatus Request status. On completion contains KErrNone if successful;
1.2840 + KErrArgument if aLength is negative;
1.2841 + otherwise one of the other system-wide error codes.
1.2842 +
1.2843 +@panic FSCLIENT 19 if aPos is negative.
1.2844 +*/
1.2845 +EFSRV_EXPORT_C void RFile64::Write(TInt64 aPos, const TDesC8& aDes,TInt aLength,TRequestStatus& aStatus)
1.2846 + {
1.2847 + TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aLength, &aStatus);
1.2848 +
1.2849 + __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative));
1.2850 +
1.2851 + if (!(I64HIGH(aPos+1)))
1.2852 + {
1.2853 + RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,I64LOW(aPos)),aStatus);
1.2854 + }
1.2855 + else
1.2856 + {
1.2857 + TPckgC<TInt64> pkPos(aPos);
1.2858 + RSubSessionBase::SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos),aStatus);
1.2859 + }
1.2860 +
1.2861 + TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2Return, MODULEUID);
1.2862 + }
1.2863 +
1.2864 +
1.2865 +/**
1.2866 +Sets the the current file position.
1.2867 +
1.2868 +The function can also be used to get the current file
1.2869 +position without changing it. The file position is the position at which
1.2870 +reading and writing takes place. The start of the file is position zero.
1.2871 +
1.2872 +To retrieve the current file position without changing it, specify ESeekCurrent
1.2873 +for the seek mode, and zero for the offset.
1.2874 +
1.2875 +This is equivalent to calling RFile::Seek except that this function accepts
1.2876 +a reference to TInt64, instead of TInt, as its second parameter.
1.2877 +This allows to seek to positions beyond 2GB-1.
1.2878 +
1.2879 +@see RFile::Seek()
1.2880 +
1.2881 +If the seek mode is ESeekStart, then:
1.2882 +
1.2883 +1. the function does not modify the aPos argument,
1.2884 +
1.2885 +2. the function returns an error if the offset specified is negative.
1.2886 +
1.2887 +If the seek mode is ESeekAddress, an error is returned if:
1.2888 +
1.2889 +1. the file is not in ROM,
1.2890 +
1.2891 +2. the offset specified is greater than the size of the file.
1.2892 +
1.2893 +@param aMode Seek mode. Controls the destination of the seek operation.
1.2894 +@param aPos Offset from location specified in aMode. Can be negative.
1.2895 + On return contains the new file position.
1.2896 + If the seek mode is either ESeekCurrent or ESeekEnd and the offset
1.2897 + specifies a position before the start of the file
1.2898 + or beyond the end of the file, then on return, aPos is set to
1.2899 + the new file position (either the start or the end of the file).
1.2900 + If the seek mode is ESeekAddress, aPos returns the address of
1.2901 + the byte at the specified offset within the file.
1.2902 +
1.2903 +@return KErrNone if successful, otherwise one of the other system-wide error
1.2904 + codes.
1.2905 +*/
1.2906 +EFSRV_EXPORT_C TInt RFile64::Seek(TSeek aMode, TInt64& aPos) const
1.2907 + {
1.2908 + TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileSeek, MODULEUID, Session().Handle(), SubSessionHandle(), aMode, aPos, 0);
1.2909 +
1.2910 + TPckgC<TInt64> pkOffset(aPos);
1.2911 + TPckg<TInt64> pkNewPos(aPos);
1.2912 + TInt r = SendReceive(EFsFileSeek|KIpcArgSlot0Desc|KIpcArgSlot2Desc,TIpcArgs(&pkOffset,aMode,&pkNewPos));
1.2913 +
1.2914 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileSeekReturn, MODULEUID, r);
1.2915 + return r;
1.2916 + }
1.2917 +
1.2918 +
1.2919 +/**
1.2920 +Gets the current file size.
1.2921 +
1.2922 +This is equivalent to calling RFile::Size except that this function accepts
1.2923 +a reference to TInt64, instead of TInt, as its first parameter.
1.2924 +This allows to query file sizes, which are greater than 2GB-1
1.2925 +
1.2926 +@see RFile::Size()
1.2927 +
1.2928 +
1.2929 +@param aSize On return, the size of the file in bytes.
1.2930 +
1.2931 +@return KErrNone if successful, otherwise one of the other system-wide error
1.2932 + codes.
1.2933 +*/
1.2934 +EFSRV_EXPORT_C TInt RFile64::Size(TInt64& aSize) const
1.2935 + {
1.2936 + TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileSize2, MODULEUID, Session().Handle(), SubSessionHandle());
1.2937 +
1.2938 + TPckg<TInt64> pkSize(aSize);
1.2939 + TInt r = SendReceive(EFsFileSize|KIpcArgSlot0Desc,TIpcArgs(&pkSize));
1.2940 +
1.2941 + TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileSize2Return, MODULEUID, r, I64LOW(aSize), I64HIGH(aSize));
1.2942 + return r;
1.2943 + }
1.2944 +
1.2945 +
1.2946 +/**
1.2947 +Sets the file size.
1.2948 +
1.2949 +If the size of the file is reduced, data may be lost from
1.2950 +the end of the file.
1.2951 +
1.2952 +This is equivalent to calling RFile::SetSize except that this function accepts
1.2953 +a reference to TInt64, instead of TInt, as its first parameter.
1.2954 +This allows to set file sizes to greater than 2GB-1
1.2955 +
1.2956 +@see RFile::SetSize()
1.2957 +
1.2958 +
1.2959 +Note:
1.2960 +
1.2961 +1. The current file position remains unchanged unless SetSize() reduces the size
1.2962 + of the file in such a way that the current file position is now beyond
1.2963 + the end of the file. In this case, the current file position is set to
1.2964 + the end of file.
1.2965 +
1.2966 +2. If the file was not opened for writing, an error is returned.
1.2967 +
1.2968 +@param aSize The new size of the file, in bytes. This value must not be negative, otherwise the function raises a panic.
1.2969 +
1.2970 +@return KErrNone if successful, otherwise one of the other system-wide error
1.2971 + codes.
1.2972 +
1.2973 +@panic FSCLIENT 20 If aSize is negative.
1.2974 +*/
1.2975 +EFSRV_EXPORT_C TInt RFile64::SetSize(TInt64 aSize)
1.2976 + {
1.2977 + TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileSetSize, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aSize), I64HIGH(aSize));
1.2978 +
1.2979 + TPckgC<TInt64> pkSize(aSize);
1.2980 + TInt r = SendReceive(EFsFileSetSize|KIpcArgSlot0Desc, TIpcArgs(&pkSize));
1.2981 +
1.2982 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileSetSizeReturn, MODULEUID, r);
1.2983 + return r;
1.2984 + }
1.2985 +
1.2986 +
1.2987 +/**
1.2988 +Locks a region within the file as defined by a range of bytes.
1.2989 +
1.2990 +This ensures that those bytes are accessible
1.2991 +only through the RFile object which claims the lock. To re-allow access by
1.2992 +other programs to the locked region, it must either be unlocked or the file
1.2993 +closed. Locking can be used to synchronize operations on a file when more
1.2994 +than one program has access to the file in EFileShareAny mode.
1.2995 +
1.2996 +More than one distinct region of a file can be locked, but an error is returned
1.2997 +if more than one lock is placed on the same region. Different RFile objects
1.2998 +can lock different parts of the same file as long as the file is opened in
1.2999 +EFileShareAny mode. The locked region may extend beyond the end of a file;
1.3000 +this prevents the file from being extended by other programs.
1.3001 +
1.3002 +This is equivalent to calling RFile::Lock except that this function accepts
1.3003 +TInt64 parameters instead of TInt parameters.
1.3004 +This allows to to lock positions in file beyond 2GB-1.
1.3005 +
1.3006 +@see RFile::Lock()
1.3007 +
1.3008 +@param aPos Position in file from which to lock; this is the offset from
1.3009 + the beginning of the file.
1.3010 +@param aLength Number of bytes to lock.
1.3011 +
1.3012 +@return KErrNone if successful, otherwise one of the other system-wide error
1.3013 + codes.
1.3014 +
1.3015 +@panic FSCLIENT 17 if aLength is not greater than zero,
1.3016 +*/
1.3017 +EFSRV_EXPORT_C TInt RFile64::Lock(TInt64 aPos, TInt64 aLength) const
1.3018 + {
1.3019 + TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileLock, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aLength);
1.3020 +
1.3021 + __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative));
1.3022 + TPckgC<TInt64> pkPos(aPos);
1.3023 + TPckgC<TInt64> pkLength(aLength);
1.3024 +
1.3025 + TInt r;
1.3026 +
1.3027 + if(aPos <= KMaxTInt && aLength <= KMaxTInt)
1.3028 + r = SendReceive(EFsFileLock,TIpcArgs(I64LOW(aPos), I64LOW(aLength)));
1.3029 + else if(aPos <= KMaxTInt)
1.3030 + r = SendReceive(EFsFileLock|KIpcArgSlot1Desc,TIpcArgs(I64LOW(aPos), &pkLength));
1.3031 + else if(aLength <= KMaxTInt)
1.3032 + r = SendReceive(EFsFileLock|KIpcArgSlot0Desc,TIpcArgs(&pkPos, I64LOW(aLength)));
1.3033 + else
1.3034 + r = SendReceive(EFsFileLock|KIpcArgSlot0Desc|KIpcArgSlot1Desc,TIpcArgs(&pkPos, &pkLength));
1.3035 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileLockReturn, MODULEUID, r);
1.3036 + return r;
1.3037 + }
1.3038 +
1.3039 +
1.3040 +/**
1.3041 +Unlocks a region within the file as defined by a range of bytes.
1.3042 +
1.3043 +A lock can only be removed by the RFile object which claimed the lock.
1.3044 +
1.3045 +A portion of a locked region cannot be unlocked. The entire locked region
1.3046 +must be unlocked otherwise an error is returned. If any byte within
1.3047 +the specified range of bytes to unlock is not locked, an error is returned.
1.3048 +
1.3049 +This is equivalent to calling RFile::UnLock except that this function accepts
1.3050 +TInt64 parameters instead of TInt parameters.
1.3051 +This allows to to unlock positions in file beyond 2GB-1.
1.3052 +
1.3053 +@see RFile::UnLock()
1.3054 +
1.3055 +@param aPos Position in file from which to unlock; this is the offset from
1.3056 + the beginning of the file.
1.3057 +@param aLength Number of bytes to unlock.
1.3058 +
1.3059 +@return KErrNone if successful, otherwise one of the other system-wide error
1.3060 + codes.
1.3061 +
1.3062 +@panic FSCLIENT 18 if aLength is not greater than zero,
1.3063 +*/
1.3064 +EFSRV_EXPORT_C TInt RFile64::UnLock(TInt64 aPos, TInt64 aLength) const
1.3065 + {
1.3066 + TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileUnLock, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aLength);
1.3067 +
1.3068 + __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative));
1.3069 +
1.3070 + TPckgC<TInt64> pkPos(aPos);
1.3071 + TPckgC<TInt64> pkLength(aLength);
1.3072 +
1.3073 + TInt r;
1.3074 +
1.3075 + if(aPos <= KMaxTInt && aLength <= KMaxTInt)
1.3076 + r = SendReceive(EFsFileUnLock,TIpcArgs(I64LOW(aPos), I64LOW(aLength)));
1.3077 + else if(aPos <= KMaxTInt)
1.3078 + r = SendReceive(EFsFileUnLock|KIpcArgSlot1Desc,TIpcArgs(I64LOW(aPos), &pkLength));
1.3079 + else if(aLength <= KMaxTInt)
1.3080 + r = SendReceive(EFsFileUnLock|KIpcArgSlot0Desc,TIpcArgs(&pkPos, I64LOW(aLength)));
1.3081 + else
1.3082 + r = SendReceive(EFsFileUnLock|KIpcArgSlot0Desc|KIpcArgSlot1Desc,TIpcArgs(&pkPos, &pkLength));
1.3083 +
1.3084 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileUnLockReturn, MODULEUID, r);
1.3085 + return r;
1.3086 + }
1.3087 +
1.3088 +
1.3089 +/**
1.3090 +Reads from the file at the specified offset within the file
1.3091 +
1.3092 +This is a synchronous function.
1.3093 +
1.3094 +This is equivalent to calling RFile::Read(TInt, TDes8&) or RFile64::Read(TInt64, TDes8&)
1.3095 +except that this function accepts TUint, instead of TInt or TInt64, as its first parameter.
1.3096 +
1.3097 +This function is provided for gradual migration of a client from 32-bit RFile APIs
1.3098 +to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION
1.3099 +macro. If the macro is defined, then it hides this overload, which would then throw
1.3100 +compile-time errors for any user code that uses TUint parameter for RFile64::Read.
1.3101 +
1.3102 +
1.3103 +@see RFile::Read(TInt aPos, TDes8& aDes)
1.3104 +@see RFile64::Read(TInt aPos, TDes8& aDes)
1.3105 +
1.3106 +Note that when an attempt is made to read beyond the end of the file,
1.3107 +no error is returned.
1.3108 +The descriptor's length is set to the number of bytes read into it.
1.3109 +Therefore, when reading through a file, the end of file has been reached
1.3110 +when the descriptor length, as returned by TDesC8::Length(), is zero.
1.3111 +
1.3112 +@param aPos Position of first byte to be read. This is an offset from
1.3113 + the start of the file. If no position is specified, reading
1.3114 + begins at the current file position.
1.3115 + If aPos is beyond the end of the file, the function returns
1.3116 + a zero length descriptor.
1.3117 +
1.3118 +@param aDes The descriptor into which binary data is read. Any existing content
1.3119 + is overwritten. On return, its length is set to the number of
1.3120 + bytes read.
1.3121 +
1.3122 +@return KErrNone if successful, otherwise one of the other system-wide error
1.3123 + codes.
1.3124 +
1.3125 +*/
1.3126 +EFSRV_EXPORT_C TInt RFile64::Read(TUint aPos,TDes8& aDes) const
1.3127 + {
1.3128 + TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileRead3, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.MaxLength());
1.3129 +
1.3130 + TInt r;
1.3131 + if(!(aPos + 1))
1.3132 + {
1.3133 + r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),aPos));
1.3134 + }
1.3135 + else
1.3136 + {
1.3137 + TInt64 pos = aPos;
1.3138 + TPckgC<TInt64> pkPos(pos);
1.3139 + r = SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.MaxLength(),&pkPos));
1.3140 + }
1.3141 +
1.3142 + TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead3Return, MODULEUID, r, aDes.Length());
1.3143 +
1.3144 + return r;
1.3145 + }
1.3146 +
1.3147 +
1.3148 +/**
1.3149 +Reads from the file at the specified offset within the file.
1.3150 +
1.3151 +This is an asynchronous function.
1.3152 +
1.3153 +This is equivalent to calling RFile::Read(TInt, TDes8&, TRequestStatus&) or
1.3154 +RFile64::Read(TInt64, TDes8&, TRequestStatus&) except that this function
1.3155 +accepts TUint, instead of TInt or TInt64, as its first parameter.
1.3156 +
1.3157 +This function is provided for gradual migration of a client from 32-bit RFile APIs
1.3158 +to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION
1.3159 +macro. If the macro is defined, then it hides this overload, which would then throw
1.3160 +compile-time errors for any user code that uses TUint parameter for RFile64::Read.
1.3161 +
1.3162 +@see RFile::Read(TInt aPos, TDes8& aDes, TRequestStatus& aStatus)
1.3163 +@see RFile64::Read(TInt aPos, TDes8& aDes, TRequestStatus& aStatus)
1.3164 +
1.3165 +Note that when an attempt is made to read beyond the end of the file,
1.3166 +no error is returned.
1.3167 +The descriptor's length is set to the number of bytes read into it.
1.3168 +Therefore, when reading through a file, the end of file has been reached
1.3169 +when the descriptor length, as returned by TDesC8::Length(), is zero.
1.3170 +
1.3171 +@param aPos Position of first byte to be read. This is an offset from
1.3172 + the start of the file. If no position is specified,
1.3173 + reading begins at the current file position.
1.3174 + If aPos is beyond the end of the file, the function returns
1.3175 + a zero length descriptor.
1.3176 +
1.3177 +@param aDes The descriptor into which binary data is read. Any existing
1.3178 + content is overwritten. On return, its length is set to
1.3179 + the number of bytes read.
1.3180 + NB: this function is asynchronous and the request that it
1.3181 + represents may not complete until some time after the call
1.3182 + to the function has returned. It is important, therefore, that
1.3183 + this descriptor remain valid, or remain in scope, until you have
1.3184 + been notified that the request is complete.
1.3185 +
1.3186 +@param aStatus The request status. On completion, contains an error code of KErrNone
1.3187 + if successful, otherwise one of the other system-wide error codes.
1.3188 +
1.3189 +*/
1.3190 +EFSRV_EXPORT_C void RFile64::Read(TUint aPos,TDes8& aDes,TRequestStatus& aStatus) const
1.3191 + {
1.3192 + TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileRead4, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.MaxLength(), &aStatus);
1.3193 +
1.3194 + if(!(aPos + 1))
1.3195 + {
1.3196 + RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),aPos),aStatus);
1.3197 + }
1.3198 + else
1.3199 + {
1.3200 + TInt64 pos = aPos;
1.3201 + TPckgC<TInt64> pkPos(pos);
1.3202 + RSubSessionBase::SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.MaxLength(),&pkPos),aStatus);
1.3203 + }
1.3204 +
1.3205 + TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead4Return, MODULEUID);
1.3206 + }
1.3207 +
1.3208 +
1.3209 +/**
1.3210 +Reads the specified number of bytes of binary data from the file at a specified
1.3211 +offset within the file.
1.3212 +
1.3213 +This is a synchronous function.
1.3214 +
1.3215 +This is equivalent to calling RFile::Read(TInt, TDes8&, TInt) or
1.3216 +RFile64::Read(TInt64, TDes8&, TInt) except that this function
1.3217 +accepts TUint, instead of TInt or TInt64, as its first parameter.
1.3218 +
1.3219 +This function is provided for gradual migration of a client from 32-bit RFile APIs
1.3220 +to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION
1.3221 +macro. If the macro is defined, then it hides this overload, which would then throw
1.3222 +compile-time errors for any user code that uses TUint parameter for RFile64::Read.
1.3223 +
1.3224 +
1.3225 +@see RFile::Read(TInt aPos, TDes8& aDes,TInt aLength)
1.3226 +@see RFile64::Read(TInt aPos, TDes8& aDes,TInt aLength)
1.3227 +
1.3228 +Note that when an attempt is made to read beyond the end of the file,
1.3229 +no error is returned.
1.3230 +The descriptor's length is set to the number of bytes read into it.
1.3231 +Therefore, when reading through a file, the end of file has been reached
1.3232 +when the descriptor length, as returned by TDesC8::Length(), is zero.
1.3233 +Assuming aLength is less than the maximum length of the descriptor, the only
1.3234 +circumstances in which Read() can return fewer bytes than requested is when
1.3235 +the end of file is reached or if an error has occurred.
1.3236 +
1.3237 +@param aPos Position of first byte to be read. This is an offset from
1.3238 + the start of the file. If no position is specified,
1.3239 + reading begins at the current file position.
1.3240 + If aPos is beyond the end of the file, the function returns
1.3241 + a zero length descriptor.
1.3242 +
1.3243 +@param aDes The descriptor into which binary data is read. Any existing
1.3244 + contents are overwritten. On return, its length is set to
1.3245 + the number of bytes read.
1.3246 +@param aLength The number of bytes to read from the file into the descriptor.
1.3247 + If an attempt is made to read more bytes than the descriptor's
1.3248 + maximum length, then the function updates aStatus parameter with KErrOverflow.
1.3249 + It must not be negative otherwise the function updates aStatus with KErrArgument.
1.3250 +
1.3251 +@return KErrNone if successful, otherwise one of the other system-wide
1.3252 + error codes.
1.3253 +
1.3254 +*/
1.3255 +EFSRV_EXPORT_C TInt RFile64::Read(TUint aPos,TDes8& aDes,TInt aLength) const
1.3256 + {
1.3257 + TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileRead3, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength);
1.3258 +
1.3259 + if (aLength==0)
1.3260 + {
1.3261 + aDes.Zero();
1.3262 + return(KErrNone);
1.3263 + }
1.3264 + else if(aLength>aDes.MaxLength())
1.3265 + {
1.3266 + return(KErrOverflow);
1.3267 + }
1.3268 +
1.3269 + TInt r;
1.3270 + if(!(aPos + 1))
1.3271 + {
1.3272 + r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,aPos));
1.3273 + }
1.3274 + else
1.3275 + {
1.3276 + TInt64 pos = aPos;
1.3277 + TPckgC<TInt64> pkPos(pos);
1.3278 + r = SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos));
1.3279 + }
1.3280 +
1.3281 + TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead3Return, MODULEUID, r, aDes.Length());
1.3282 +
1.3283 + return r;
1.3284 + }
1.3285 +
1.3286 +
1.3287 +/**
1.3288 +Reads the specified number of bytes of binary data from the file at a specified
1.3289 +offset within the file.
1.3290 +
1.3291 +This is an asynchronous function.
1.3292 +
1.3293 +This is equivalent to calling RFile::Read(TInt, TDes8&, TInt,TRequestStatus&) or
1.3294 +RFile64::Read(TInt64, TDes8&, TInt, TRequestStatus&) except that this function
1.3295 +accepts TUint, instead of TInt or TInt64, as its first parameter.
1.3296 +
1.3297 +This function is provided for gradual migration of a client from 32-bit RFile APIs
1.3298 +to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION
1.3299 +macro. If the macro is defined, then it hides this overload, which would then throw
1.3300 +compile-time errors for any user code that uses TUint parameter for RFile64::Read.
1.3301 +
1.3302 +
1.3303 +@see RFile::Read(TInt aPos, TDes8& aDes,TInt aLength,TRequestStatus& aStatus)
1.3304 +@see RFile64::Read(TInt aPos, TDes8& aDes,TInt aLength,TRequestStatus& aStatus)
1.3305 +
1.3306 +Note that when an attempt is made to read beyond the end of the file,
1.3307 +no error is returned.
1.3308 +The descriptor's length is set to the number of bytes read into it.
1.3309 +Therefore, when reading through a file, the end of file has been reached
1.3310 +when the descriptor length, as returned by TDesC8::Length(), is zero.
1.3311 +Assuming aLength is less than the maximum length of the descriptor, the only
1.3312 +circumstances in which Read() can return fewer bytes than requested is when
1.3313 +the end of file is reached or if an error has occurred.
1.3314 +
1.3315 +@param aPos Position of first byte to be read. This is an offset from
1.3316 + the start of the file. If no position is specified,
1.3317 + reading begins at the current file position.
1.3318 + If aPos is beyond the end of the file, the function returns
1.3319 + a zero length descriptor.
1.3320 +
1.3321 +@param aDes The descriptor into which binary data is read. Any existing
1.3322 + contents are overwritten. On return, its length is set to
1.3323 + the number of bytes read.
1.3324 + NB: this function is asynchronous and the request that it
1.3325 + represents may not complete until some time after the call
1.3326 + to the function has returned. It is important, therefore, that
1.3327 + this descriptor remain valid, or remain in scope, until you have
1.3328 + been notified that the request is complete.
1.3329 +
1.3330 +@param aLength The number of bytes to read from the file into the descriptor.
1.3331 + If an attempt is made to read more bytes than the descriptor's
1.3332 + maximum length, then the function returns KErrOverflow.
1.3333 + It must not be negative otherwise the function returns KErrArgument.
1.3334 +
1.3335 +@param aStatus Request status. On completion contains KErrNone if successful,
1.3336 + otherwise one of the other system-wide error codes.
1.3337 +
1.3338 +*/
1.3339 +EFSRV_EXPORT_C void RFile64::Read(TUint aPos,TDes8& aDes,TInt aLength,TRequestStatus& aStatus) const
1.3340 + {
1.3341 + TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileRead4, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength, &aStatus);
1.3342 +
1.3343 + if (aLength==0)
1.3344 + {
1.3345 + aDes.Zero();
1.3346 + TRequestStatus* req=(&aStatus);
1.3347 + User::RequestComplete(req,KErrNone);
1.3348 + return;
1.3349 + }
1.3350 + else if(aLength>aDes.MaxLength())
1.3351 + {
1.3352 + TRequestStatus* req=(&aStatus);
1.3353 + User::RequestComplete(req,KErrOverflow);
1.3354 + return;
1.3355 + }
1.3356 +
1.3357 + if(!(aPos + 1))
1.3358 + {
1.3359 + RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,aPos),aStatus);
1.3360 + }
1.3361 + else
1.3362 + {
1.3363 + TInt64 pos = aPos;
1.3364 + TPckgC<TInt64> pkPos(pos);
1.3365 + RSubSessionBase::SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos),aStatus);
1.3366 + }
1.3367 +
1.3368 + TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead4Return, MODULEUID);
1.3369 + }
1.3370 +
1.3371 +
1.3372 +/**
1.3373 +Writes to the file at the specified offset within the file
1.3374 +
1.3375 +This is a synchronous function.
1.3376 +
1.3377 +This is equivalent to calling RFile::Write(TInt, TDes8&) or
1.3378 +RFile64::Write(TInt64, TDes8&) except that this function
1.3379 +accepts TUint, instead of TInt or TInt64, as its first parameter.
1.3380 +
1.3381 +This function is provided for gradual migration of a client from 32-bit RFile APIs
1.3382 +to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION
1.3383 +macro. If the macro is defined, then it hides this overload, which would then throw
1.3384 +compile-time errors for any user code that uses TUint parameter for RFile64::Read.
1.3385 +
1.3386 +
1.3387 +@see RFile::Write(TInt aPos, TDes8& aDes)
1.3388 +@see RFile64::Write(TInt aPos, TDes8& aDes)
1.3389 +
1.3390 +
1.3391 +@param aPos The offset from the start of the file at which the first
1.3392 + byte is written.
1.3393 + If a position beyond the end of the file is specified, then
1.3394 + the write operation begins at the end of the file.
1.3395 + If the position has been locked, then the write fails.
1.3396 +
1.3397 +@param aDes The descriptor from which binary data is written. The function writes
1.3398 + the entire contents of aDes to the file.
1.3399 +
1.3400 +@return KErrNone if successful, otherwise one of the other system-wide error
1.3401 + codes.
1.3402 +
1.3403 +*/
1.3404 +EFSRV_EXPORT_C TInt RFile64::Write(TUint aPos,const TDesC8& aDes)
1.3405 + {
1.3406 + TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileWrite3, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.Length());
1.3407 +
1.3408 + TInt r;
1.3409 + if(!(aPos + 1))
1.3410 + {
1.3411 + r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),aPos));
1.3412 + }
1.3413 + else
1.3414 + {
1.3415 + TInt64 pos = aPos;
1.3416 + TPckgC<TInt64> pkPos(pos);
1.3417 + r = SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.Length(),&pkPos));
1.3418 + }
1.3419 +
1.3420 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite3Return, MODULEUID, r);
1.3421 + return r;
1.3422 + }
1.3423 +
1.3424 +
1.3425 +/**
1.3426 +Writes to the file at the specified offset within the file
1.3427 +
1.3428 +This is an asynchronous function.
1.3429 +
1.3430 +This is equivalent to calling RFile::Write(TInt, TDes8&,TRequestStatus&) or
1.3431 +RFile64::Write(TInt64, TDes8&,TRequestStatus&) except that this function
1.3432 +accepts TUint, instead of TInt or TInt64, as its first parameter.
1.3433 +
1.3434 +This function is provided for gradual migration of a client from 32-bit RFile APIs
1.3435 +to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION
1.3436 +macro. If the macro is defined, then it hides this overload, which would then throw
1.3437 +compile-time errors for any user code that uses TUint parameter for RFile64::Read.
1.3438 +
1.3439 +
1.3440 +@see RFile::Write(TInt aPos, TDes8& aDes,TRequestStatus& aStatus)
1.3441 +@see RFile64::Write(TInt aPos, TDes8& aDes,TRequestStatus& aStatus)
1.3442 +
1.3443 +
1.3444 +@param aPos The offset from the start of the file at which the first
1.3445 + byte is written.
1.3446 + If a position beyond the end of the file is specified, then
1.3447 + the write operation begins at the end of the file.
1.3448 + If the position has been locked, then the write fails.
1.3449 +
1.3450 +@param aDes The descriptor from which binary data is written. The function
1.3451 + writes the entire contents of aDes to the file.
1.3452 + NB: this function is asynchronous and the request that it
1.3453 + represents may not complete until some time after the call
1.3454 + to the function has returned. It is important, therefore, that
1.3455 + this descriptor remain valid, or remain in scope, until you have
1.3456 + been notified that the request is complete.
1.3457 +
1.3458 +@param aStatus Request status. On completion contains KErrNone if successful,
1.3459 + otherwise one of the other system-wide error codes.
1.3460 +
1.3461 +*/
1.3462 +EFSRV_EXPORT_C void RFile64::Write(TUint aPos,const TDesC8& aDes,TRequestStatus& aStatus)
1.3463 + {
1.3464 + TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileWrite4, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.Length(), &aStatus);
1.3465 +
1.3466 + if(!(aPos + 1))
1.3467 + {
1.3468 + RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),aPos),aStatus);
1.3469 + }
1.3470 + else
1.3471 + {
1.3472 + TInt64 pos = aPos;
1.3473 + TPckgC<TInt64> pkPos(pos);
1.3474 + RSubSessionBase::SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.Length(),&pkPos),aStatus);
1.3475 + }
1.3476 + TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite4Return, MODULEUID);
1.3477 + }
1.3478 +
1.3479 +
1.3480 +/**
1.3481 +Writes the specified number of bytes to the file at the specified offset within the file.
1.3482 +
1.3483 +This is a synchronous function.
1.3484 +
1.3485 +This is equivalent to calling RFile::Write(TInt, TDes8&,TInt) or
1.3486 +RFile64::Write(TInt64, TDes8&,TInt) except that this function
1.3487 +accepts TUint, instead of TInt or TInt64, as its first parameter.
1.3488 +
1.3489 +This function is provided for gradual migration of a client from 32-bit RFile APIs
1.3490 +to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION
1.3491 +macro. If the macro is defined, then it hides this overload, which would then throw
1.3492 +compile-time errors for any user code that uses TUint parameter for RFile64::Read.
1.3493 +
1.3494 +
1.3495 +@see RFile::Write(TInt aPos, TDes8& aDes,TInt aLength)
1.3496 +@see RFile64::Write(TInt aPos, TDes8& aDes,TInt aLength)
1.3497 +
1.3498 +@param aPos The offset from the start of the file at which the first
1.3499 + byte is written.
1.3500 + If a position beyond the end of the file is specified, then
1.3501 + the write operation begins at the end of the file.
1.3502 + If the position has been locked, then the write fails.
1.3503 +
1.3504 +@param aDes The descriptor from which binary data is written.
1.3505 +@param aLength The number of bytes to be written from aDes .
1.3506 + It must not be negative.
1.3507 +
1.3508 +@return KErrNone if successful; KErrArgument if aLength is negative;
1.3509 + otherwise one of the other system-wide error codes.
1.3510 +
1.3511 +*/
1.3512 +EFSRV_EXPORT_C TInt RFile64::Write(TUint aPos,const TDesC8& aDes,TInt aLength)
1.3513 + {
1.3514 + TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1, MODULEUID, Session().Handle(), SubSessionHandle(), aLength);
1.3515 +
1.3516 + TInt r;
1.3517 + if(!(aPos + 1))
1.3518 + {
1.3519 + r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,aPos));
1.3520 + }
1.3521 + else
1.3522 + {
1.3523 + TInt64 pos = aPos;
1.3524 + TPckgC<TInt64> pkPos(pos);
1.3525 + r = SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos));
1.3526 + }
1.3527 +
1.3528 + TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1Return, MODULEUID, r);
1.3529 + return r;
1.3530 + }
1.3531 +
1.3532 +
1.3533 +/**
1.3534 +Writes the specified number of bytes to the file at the specified offset within the file.
1.3535 +
1.3536 +This is an asynchronous function.
1.3537 +
1.3538 +This is equivalent to calling RFile::Write(TInt, TDes8&,TInt,TRequestStatus&) or
1.3539 +RFile64::Write(TInt64, TDes8&,TInt,TRequestStatus&) except that this function
1.3540 +accepts TUint, instead of TInt or TInt64, as its first parameter.
1.3541 +
1.3542 +This function is provided for gradual migration of a client from 32-bit RFile APIs
1.3543 +to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION
1.3544 +macro. If the macro is defined, then it hides this overload, which would then throw
1.3545 +compile-time errors for any user code that uses TUint parameter for RFile64::Read.
1.3546 +
1.3547 +
1.3548 +@see RFile::Write(TInt aPos, TDes8& aDes, TInt aLength, TRequestStatus& aStatus)
1.3549 +@see RFile64::Write(TInt aPos, TDes8& aDes,TInt aLength, TRequestStatus& aStatus)
1.3550 +
1.3551 +
1.3552 +@param aPos The offset from the start of the file at which the first
1.3553 + byte is written.
1.3554 + If a position beyond the end of the file is specified, then
1.3555 + the write operation begins at the end of the file.
1.3556 + If the position has been locked, then the write fails.
1.3557 +
1.3558 +@param aDes The descriptor from which binary data is written.
1.3559 + NB: this function is asynchronous and the request that it
1.3560 + represents may not complete until some time after the call
1.3561 + to the function has returned. It is important, therefore, that
1.3562 + this descriptor remain valid, or remain in scope, until you have
1.3563 + been notified that the request is complete.
1.3564 +
1.3565 +@param aLength The number of bytes to be written from aDes.
1.3566 + It must not be negative.
1.3567 +
1.3568 +@param aStatus Request status. On completion contains KErrNone if successful;
1.3569 + KErrArgument if aLength is negative;
1.3570 + otherwise one of the other system-wide error codes.
1.3571 +
1.3572 +*/
1.3573 +EFSRV_EXPORT_C void RFile64::Write(TUint aPos,const TDesC8& aDes,TInt aLength,TRequestStatus& aStatus)
1.3574 + {
1.3575 + TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength, &aStatus);
1.3576 +
1.3577 + if(!(aPos + 1))
1.3578 + {
1.3579 + RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,aPos),aStatus);
1.3580 + }
1.3581 + else
1.3582 + {
1.3583 + TInt64 pos = aPos;
1.3584 + TPckgC<TInt64> pkPos(pos);
1.3585 + RSubSessionBase::SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos),aStatus);
1.3586 + }
1.3587 + TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2Return, MODULEUID);
1.3588 + }
1.3589 +#else
1.3590 +EFSRV_EXPORT_C TInt RFile64::Open(RFs& /*aFs*/,const TDesC& /*aName*/,TUint /*aFileMode*/)
1.3591 + {Panic(ENotImplemented);return (KErrNotSupported);}
1.3592 +EFSRV_EXPORT_C TInt RFile64::Create(RFs& /*aFs*/,const TDesC& /*aName*/,TUint /*aFileMode*/)
1.3593 + {Panic(ENotImplemented);return (KErrNotSupported);}
1.3594 +EFSRV_EXPORT_C TInt RFile64::Replace(RFs& /*aFs*/,const TDesC& /*aName*/,TUint /*aFileMode*/)
1.3595 + {Panic(ENotImplemented);return (KErrNotSupported);}
1.3596 +EFSRV_EXPORT_C TInt RFile64::Temp(RFs& /*aFs*/,const TDesC& /*aPath*/,TFileName& /*aName*/,TUint /*aFileMode*/)
1.3597 + {Panic(ENotImplemented);return (KErrNotSupported);}
1.3598 +EFSRV_EXPORT_C TInt RFile64::AdoptFromClient(const RMessage2& /*aMsg*/, TInt /*aFsHandleIndex*/, TInt /*aFileHandleIndex*/)
1.3599 + {Panic(ENotImplemented);return (KErrNotSupported);}
1.3600 +EFSRV_EXPORT_C TInt RFile64::AdoptFromServer(TInt /*aFsHandle*/, TInt /*aFileHandle*/)
1.3601 + {Panic(ENotImplemented);return (KErrNotSupported);}
1.3602 +EFSRV_EXPORT_C TInt RFile64::AdoptFromCreator(TInt /*aFsHandleIndex*/, TInt /*aFileHandleIndex*/)
1.3603 + {Panic(ENotImplemented);return (KErrNotSupported);}
1.3604 +EFSRV_EXPORT_C TInt RFile64::Read(TInt64 /*aPos*/, TDes8& /*aDes*/) const
1.3605 + {Panic(ENotImplemented);return (KErrNotSupported);}
1.3606 +EFSRV_EXPORT_C void RFile64::Read(TInt64 /*aPos*/, TDes8& /*aDes*/, TRequestStatus& /*aStatus*/) const
1.3607 + {Panic(ENotImplemented);}
1.3608 +EFSRV_EXPORT_C TInt RFile64::Read(TInt64 /*aPos*/, TDes8& /*aDes*/, TInt /*aLength*/) const
1.3609 + {Panic(ENotImplemented);return (KErrNotSupported);}
1.3610 +EFSRV_EXPORT_C void RFile64::Read(TInt64 /*aPos*/, TDes8& /*aDes*/, TInt /*aLength*/,TRequestStatus& /*aStatus*/) const
1.3611 + {Panic(ENotImplemented);}
1.3612 +EFSRV_EXPORT_C TInt RFile64::Write(TInt64 /*aPos*/, const TDesC8& /*aDes*/)
1.3613 + {Panic(ENotImplemented);return (KErrNotSupported);}
1.3614 +EFSRV_EXPORT_C void RFile64::Write(TInt64 /*aPos*/, const TDesC8& /*aDes*/,TRequestStatus& /*aStatus*/)
1.3615 + {Panic(ENotImplemented);}
1.3616 +EFSRV_EXPORT_C TInt RFile64::Write(TInt64 /*aPos*/, const TDesC8& /*aDes*/, TInt /*aLength*/)
1.3617 + {Panic(ENotImplemented);return (KErrNotSupported);}
1.3618 +EFSRV_EXPORT_C void RFile64::Write(TInt64 /*aPos*/, const TDesC8& /*aDes*/,TInt /*aLength*/,TRequestStatus& /*aStatus*/)
1.3619 + {Panic(ENotImplemented);}
1.3620 +EFSRV_EXPORT_C TInt RFile64::Seek(TSeek /*aMode*/, TInt64& /*aPos*/) const
1.3621 + {Panic(ENotImplemented);return (KErrNotSupported);}
1.3622 +EFSRV_EXPORT_C TInt RFile64::Size(TInt64& /*aSize*/) const
1.3623 + {Panic(ENotImplemented);return (KErrNotSupported);}
1.3624 +EFSRV_EXPORT_C TInt RFile64::SetSize(TInt64 /*aSize*/)
1.3625 + {Panic(ENotImplemented);return (KErrNotSupported);}
1.3626 +EFSRV_EXPORT_C TInt RFile64::Lock(TInt64 /*aPos*/, TInt64 /*aLength*/) const
1.3627 + {Panic(ENotImplemented);return (KErrNotSupported);}
1.3628 +EFSRV_EXPORT_C TInt RFile64::UnLock(TInt64 /*aPos*/, TInt64 /*aLength*/) const
1.3629 + {Panic(ENotImplemented);return (KErrNotSupported);}
1.3630 +EFSRV_EXPORT_C TInt RFile64::Read(TUint /*aPos*/,TDes8& /*aDes*/) const
1.3631 + {Panic(ENotImplemented);return (KErrNotSupported);}
1.3632 +EFSRV_EXPORT_C void RFile64::Read(TUint /*aPos*/,TDes8& /*aDes*/,TRequestStatus& /*aStatus*/) const
1.3633 + {Panic(ENotImplemented);}
1.3634 +EFSRV_EXPORT_C TInt RFile64::Read(TUint /*aPos*/,TDes8& /*aDes*/,TInt /*aLength*/) const
1.3635 + {Panic(ENotImplemented);return (KErrNotSupported);}
1.3636 +EFSRV_EXPORT_C void RFile64::Read(TUint /*aPos*/,TDes8& /*aDes*/,TInt /*aLength*/,TRequestStatus& /*aStatus*/) const
1.3637 + {Panic(ENotImplemented);}
1.3638 +EFSRV_EXPORT_C TInt RFile64::Write(TUint /*aPos*/,const TDesC8& /*aDes*/)
1.3639 + {Panic(ENotImplemented);return (KErrNotSupported);}
1.3640 +EFSRV_EXPORT_C void RFile64::Write(TUint /*aPos*/,const TDesC8& /*aDes*/,TRequestStatus& /*aStatus*/)
1.3641 + {Panic(ENotImplemented);}
1.3642 +EFSRV_EXPORT_C TInt RFile64::Write(TUint /*aPos*/,const TDesC8& /*aDes*/,TInt /*aLength*/)
1.3643 + {Panic(ENotImplemented);return (KErrNotSupported);}
1.3644 +EFSRV_EXPORT_C void RFile64::Write(TUint /*aPos*/, const TDesC8& /*aDes*/,TInt /*aLength*/,TRequestStatus& /*aStatus*/)
1.3645 + {Panic(ENotImplemented);}
1.3646 +#endif