sl@0: // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // f32\sfsrv\cl_file.cpp sl@0: // sl@0: // sl@0: sl@0: #include "cl_std.h" sl@0: sl@0: static _LIT_SECURITY_POLICY_S1(KFileServerPolicy,KFileServerUidValue,ECapabilityTCB); sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::Adopt(RFs& aFs, TInt aHandle) sl@0: /** sl@0: Adopts an already open file. sl@0: sl@0: @param aFs The file server session. sl@0: @param aHandle The handle number of the already opened file sl@0: sl@0: @return KErrNone if successful, sl@0: KErrBadHandle if the sub-session handle is invalid, sl@0: otherwise one of the other system-wide error codes. sl@0: sl@0: @deprecated sl@0: */ sl@0: { sl@0: sl@0: TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileAdopt, MODULEUID, aFs.Handle(), aHandle); sl@0: sl@0: // duplicate the sub-session handle; don't panic if it's invalid. sl@0: RFile file; sl@0: TInt r = file.CreateSubSession(aFs, EFsFileDuplicate, TIpcArgs(aHandle, EFalse)); sl@0: if (r == KErrArgument) sl@0: { sl@0: TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptReturn, MODULEUID, KErrBadHandle); sl@0: return KErrBadHandle; sl@0: } sl@0: else if (r != KErrNone) sl@0: { sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: // adopt the duplicated handle sl@0: r = CreateAutoCloseSubSession(aFs, EFsFileAdopt, TIpcArgs(file.SubSessionHandle(), KFileAdopt32)); sl@0: sl@0: TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptReturn, MODULEUID, r, Session().Handle(), SubSessionHandle()); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::AdoptFromServer(TInt aFsHandle, TInt aFileHandle) sl@0: /** sl@0: Allows a client to adopt an already open file from a server. sl@0: sl@0: Assumes that the server's RFs and RFile handles have been sent to the sl@0: client using TransferToClient(). sl@0: sl@0: This RFile will own it's RFs session so that when the sub-session (RFile) sl@0: is closed so will the RFs session. sl@0: sl@0: @param aFsHandle The file server session (RFs) handle sl@0: @param aFileHandle The file (RFile) handle of the already opened file sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide sl@0: error codes. sl@0: */ sl@0: { sl@0: TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromServer, MODULEUID, aFsHandle, aFileHandle); sl@0: sl@0: RFs fs; sl@0: TInt r = fs.SetReturnedHandle(aFsHandle, KFileServerPolicy); sl@0: if (r != KErrNone) sl@0: { sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromServerReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: r = CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(aFileHandle, KFileAdopt32)); sl@0: sl@0: TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromServerReturn, MODULEUID, r, Session().Handle(), SubSessionHandle()); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::AdoptFromClient(const RMessage2& aMsg, TInt aFsHandleIndex, TInt aFileHandleIndex) sl@0: /** sl@0: Allows a server to adopt an already open file from a client. sl@0: The client's RFs and RFile handles are contained in message slots within aMsg. sl@0: sl@0: Assumes that the client's RFs and RFile handles have been sent to the server sl@0: using TransferToServer(). sl@0: sl@0: sl@0: This RFile will own it's RFs session so that when the sub-session (RFile) sl@0: is closed so will the RFs session. sl@0: sl@0: @param aMsg The message received from the client sl@0: @param aFsHandleIndex The index that identifies the message slot sl@0: of a file server session (RFs) handle sl@0: @param aFileHandleIndex The index that identifies the message slot sl@0: of the sub-session (RFile) handle of the already opened file sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide sl@0: error codes. sl@0: */ sl@0: { sl@0: TInt fileHandle = NULL; sl@0: sl@0: TInt r = KErrNone; sl@0: if (aFileHandleIndex == 0) sl@0: fileHandle = aMsg.Int0(); sl@0: else if (aFileHandleIndex == 1) sl@0: fileHandle = aMsg.Int1(); sl@0: else if (aFileHandleIndex == 2) sl@0: fileHandle = aMsg.Int2(); sl@0: else if (aFileHandleIndex == 3) sl@0: fileHandle = aMsg.Int3(); sl@0: else sl@0: r = KErrArgument; sl@0: sl@0: #ifdef SYMBIAN_FTRACE_ENABLE sl@0: TInt handle = NULL; sl@0: if (aFsHandleIndex == 0) sl@0: handle = aMsg.Int0(); sl@0: else if (aFsHandleIndex == 1) sl@0: handle = aMsg.Int1(); sl@0: else if (aFsHandleIndex == 2) sl@0: handle = aMsg.Int2(); sl@0: else if (aFsHandleIndex == 3) sl@0: handle = aMsg.Int3(); sl@0: TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClient, MODULEUID, handle, fileHandle, aFsHandleIndex, aFileHandleIndex); sl@0: #endif sl@0: sl@0: if (r != KErrNone) sl@0: { sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClientReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: // Duplicates the file server (RFs) session handle identified by an sl@0: // existing handle contained in the message slot at index aFsHandleIndex sl@0: RFs fs; sl@0: r = fs.Open(aMsg, aFsHandleIndex, KFileServerPolicy); sl@0: if (r != KErrNone) sl@0: { sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClientReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: r = CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(fileHandle, KFileAdopt32)); sl@0: sl@0: TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClientReturn, MODULEUID, r, Session().Handle(), SubSessionHandle()); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::AdoptFromCreator(TInt aFsHandleIndex, TInt aFileHandleIndex) sl@0: /** sl@0: Allows a server to adopt an already open file from a client process. sl@0: The client's file-server (RFs) and file (RFile) handles are contained in sl@0: this process's environment data slots. sl@0: sl@0: Assumes that the client's RFs and RFile handles have been sent to the server process sl@0: using TransferToProcess(). sl@0: sl@0: This RFile will own it's RFs session so that when the sub-session (RFile) sl@0: is closed so will the RFs session. sl@0: sl@0: @param aFsHandleIndex An index that identifies the slot in the process sl@0: environment data that contains the file server session (RFs) handle sl@0: @param aFileHandleIndex An index that identifies the slot in the process sl@0: environment data that contains the sub-session (RFile) handle sl@0: of the already opened file sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide sl@0: error codes. sl@0: */ sl@0: { sl@0: TInt fileHandle = NULL; sl@0: sl@0: TInt r = User::GetTIntParameter(aFileHandleIndex, fileHandle); sl@0: sl@0: TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreator, MODULEUID, fileHandle, aFsHandleIndex, aFileHandleIndex); sl@0: sl@0: if (r != KErrNone) sl@0: { sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreatorReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: // Duplicates the file server (RFs) session handle identified by an sl@0: // existing handle contained in the environment slot at index aFsHandleIndex sl@0: RFs fs; sl@0: r = fs.Open(aFsHandleIndex, KFileServerPolicy); sl@0: if (r != KErrNone) sl@0: { sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreatorReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: r = CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(fileHandle, KFileAdopt32)); sl@0: sl@0: TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreatorReturn, MODULEUID, r, Session().Handle(), SubSessionHandle()); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: Make a duplicate of the passed file handle in the same thread. sl@0: sl@0: By default, any thread in the process can use the duplicated handle to access the sl@0: file. However, specifying EOwnerThread as the second parameter to this function, sl@0: means that only the creating thread can use the handle. sl@0: sl@0: @param aFile The file handle to duplicate sl@0: @param aType An enumeration whose enumerators define the ownership of this sl@0: handle. If not explicitly specified, EOwnerProcess is taken sl@0: as default. sl@0: sl@0: @return one of the other system-wide error codes. sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile::Duplicate(const RFile& aFile, TOwnerType aType) sl@0: { sl@0: TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileDuplicate, MODULEUID, aFile.Session().Handle(), aFile.SubSessionHandle(), aType); sl@0: sl@0: RFs fs; sl@0: fs.SetHandle(aFile.Session().Handle()); sl@0: sl@0: // Need to make a duplicate of the session handle in the current thread, sl@0: // otherwise closing one session will close both sub-sessions. sl@0: TInt r = fs.Duplicate(RThread(), aType); sl@0: if (r != KErrNone) sl@0: { sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileDuplicateReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: // duplicate the sub-session handle sl@0: TInt dupSubSessionHandle; sl@0: r = aFile.DuplicateHandle(dupSubSessionHandle); sl@0: if (r != KErrNone) sl@0: { sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileDuplicateReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: // adopt the duplicated sub-session handle sl@0: r = CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(dupSubSessionHandle, KFileDuplicate)); sl@0: sl@0: TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileDuplicateReturn, MODULEUID, r, Session().Handle(), SubSessionHandle()); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: // Makes a duplicate of this file (RFile) handle in the current thread and sl@0: // returns it in aSubSessionHandle. sl@0: // The duplicate file handle will effectively be in limbo (although still sl@0: // owned by the session) until : sl@0: // (1) the session handle is duplicated into another process - sl@0: // this happens in one of : TransferToClient(), TransferToProcess() or sl@0: // AdoptFromClient() and sl@0: // (2) the sub-session handle is transferred to the other process - using AdoptXXX() sl@0: // sl@0: TInt RFile::DuplicateHandle(TInt& aSubSessionHandle) const sl@0: { sl@0: RFs fs; sl@0: fs.SetHandle(Session().Handle()); sl@0: RFile file; sl@0: sl@0: // duplicate the sub-session handle; panic if it's invalid. sl@0: TInt r = file.CreateSubSession(fs, EFsFileDuplicate, TIpcArgs(SubSessionHandle(), ETrue)); sl@0: sl@0: // return the duplicated handle sl@0: // Note that this handle needs to be adopted before it can be used sl@0: aSubSessionHandle = file.SubSessionHandle(); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Transfers an already open file to a server. sl@0: sl@0: Before this function can be called, the file server session which owns this file handle sl@0: must first be marked as shareable by calling RFs::ShareProtected(). sl@0: sl@0: This function packages handle details for this file into 2 arguments of a TIpcArgs object. sl@0: When these arguments are sent in an IPC message, the server which receives them may sl@0: call AdoptFromClient() to open a new RFile object which refers to the same file as this. sl@0: sl@0: @param aIpcArgs The IPC message arguments. sl@0: @param aFsHandleIndex An index that identifies an argument in aIpcArgs where the sl@0: file server session handle will be stored. sl@0: This argument must not be used for anything else otherwise the sl@0: results will be unpredictable. sl@0: @param aFileHandleIndex An index that identifies an argument in aIpcArgs where the sl@0: file handle will be stored. sl@0: This argument must not be used for anything else otherwise the sl@0: results will be unpredictable. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide sl@0: error codes. sl@0: sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile::TransferToServer(TIpcArgs& aIpcArgs, TInt aFsHandleIndex, TInt aFileHandleIndex) const sl@0: { sl@0: TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToServer, MODULEUID, Session().Handle(), SubSessionHandle(), aFsHandleIndex, aFileHandleIndex); sl@0: sl@0: if ((aFsHandleIndex < 0) || (aFsHandleIndex > (KMaxMessageArguments-2))) sl@0: { sl@0: TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToServerReturn, MODULEUID, (TUint) KErrArgument); sl@0: return KErrArgument; sl@0: } sl@0: sl@0: TInt dupSubSessionHandle; sl@0: TInt r = DuplicateHandle(dupSubSessionHandle); sl@0: if (r == KErrNone) sl@0: { sl@0: aIpcArgs.Set(aFsHandleIndex, Session()); sl@0: aIpcArgs.Set(aFileHandleIndex, dupSubSessionHandle); sl@0: } sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToServerReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: /** sl@0: Transfers an already open file from a server to a client. sl@0: sl@0: Before this function can be called, the file server session which owns this file handle sl@0: must first be marked as shareable by calling RFs::ShareProtected(). sl@0: sl@0: The file (RFile) handle is written to the client's address space to the package sl@0: buffer in the message address slot in aMsg identified by aFileHandleIndex. sl@0: sl@0: If no error occurs, then the message is completed with the file-server (RFs) sl@0: session handle. sl@0: sl@0: When the message completes, the client may call AdoptFromServer() to open sl@0: a new RFile object which refers to the same file as this. sl@0: sl@0: Note that if an error occurs then the message is not completed. sl@0: sl@0: @param aMsg A message received from the client sl@0: @param aFileHandleIndex Identifies the message slot that contains a package sl@0: buffer pointing to an address in the client's address space sl@0: to receive the file (RFile) handle sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide sl@0: error codes. sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile::TransferToClient(const RMessage2& aMsg, TInt aFileHandleIndex) const sl@0: { sl@0: TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToClient, MODULEUID, Session().Handle(), SubSessionHandle(), aFileHandleIndex); sl@0: sl@0: if (TUint(aFileHandleIndex) >= TUint(KMaxMessageArguments)) sl@0: { sl@0: TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToClientReturn, MODULEUID, (TUint) KErrArgument); sl@0: return KErrArgument; sl@0: } sl@0: sl@0: TInt dupSubSessionHandle; sl@0: TInt r = DuplicateHandle(dupSubSessionHandle); sl@0: if (r == KErrNone) sl@0: r = aMsg.Write(aFileHandleIndex, TPckgC(dupSubSessionHandle)); sl@0: sl@0: if (r != KErrNone) sl@0: { sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToClientReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: aMsg.Complete(Session()); sl@0: sl@0: TRACE1(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToClientReturn, MODULEUID, r); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Transfers an already open file to another process. sl@0: sl@0: Before this function can be called, the file server session which owns this file handle sl@0: must first be marked as shareable by calling RFs::ShareProtected(). sl@0: sl@0: This function packages handle details for this file into 2 arguments in another sl@0: process's environment data slots. sl@0: When the other process runs, it may call AdoptFromCreator() to open a new RFile sl@0: object which refers to the same file as this. sl@0: sl@0: @param aProcess A handle to another process. sl@0: @param aFsHandleIndex An index that identifies a slot in the process's sl@0: environment data which on exit will contain the file server sl@0: session (RFs) handle sl@0: This slot must not be used for anything else otherwise the sl@0: results will be unpredictable. sl@0: @param aFileHandleIndex An index that identifies a slot in the process's sl@0: environment data which on exit will contain the file sl@0: (RFile) handle. sl@0: This slot must not be used for anything else otherwise the sl@0: results will be unpredictable. sl@0: @return KErrNone if successful, otherwise one of the other system-wide sl@0: error codes. sl@0: */ sl@0: // NB slot 0 is reserved for the command line sl@0: EFSRV_EXPORT_C TInt RFile::TransferToProcess(RProcess& aProcess, TInt aFsHandleIndex, TInt aFileHandleIndex) const sl@0: { sl@0: TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToProcess, MODULEUID, Session().Handle(), SubSessionHandle(), aFsHandleIndex, aFileHandleIndex); sl@0: sl@0: TInt dupSubSessionHandle; sl@0: TInt r = DuplicateHandle(dupSubSessionHandle); sl@0: sl@0: if (r == KErrNone) sl@0: r = aProcess.SetParameter(aFsHandleIndex, RHandleBase(Session())); sl@0: sl@0: if (r == KErrNone) sl@0: r = aProcess.SetParameter(aFileHandleIndex, dupSubSessionHandle); sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileTransferToProcessReturn, MODULEUID, r); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::Name(TDes& aName) const sl@0: /** sl@0: Gets the final part of a filename sl@0: sl@0: This is used to retrieve the name and extension of a file that has been sl@0: passed from one process to another using the RFile::AdoptXXX() methods. sl@0: sl@0: @param aName On return, contains the name of the file, including the name and sl@0: extension but excluding the drive letter and path. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other sl@0: system-wide error codes. sl@0: sl@0: */ sl@0: { sl@0: TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileName, MODULEUID, Session().Handle(), SubSessionHandle()); sl@0: sl@0: TInt r = SendReceive(EFsFileName, TIpcArgs(&aName)); sl@0: sl@0: TRACERETMULT2(UTF::EBorder, UTraceModuleEfsrv::EFileNameReturn, MODULEUID, r, aName); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::FullName(TDes& aName) const sl@0: /** sl@0: Gets the full filename sl@0: sl@0: This is used to retrieve the full filename, including drive and path, sl@0: of a file that has been passed from one process to another using the sl@0: RFile::AdoptXXX() methods. sl@0: sl@0: @param aName On return, contains the full name of the file, including drive and path. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other sl@0: system-wide error codes. sl@0: sl@0: */ sl@0: { sl@0: TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileFullName, MODULEUID, Session().Handle(), SubSessionHandle()); sl@0: sl@0: TInt r = SendReceive(EFsFileFullName, TIpcArgs(&aName)); sl@0: sl@0: TRACERETMULT2(UTF::EBorder, UTraceModuleEfsrv::EFileFullNameReturn, MODULEUID, r, aName); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::Open(RFs& aFs,const TDesC& aName,TUint aMode) sl@0: /** sl@0: Opens an existing file for reading or writing. sl@0: sl@0: If the file does not already exist, an error is returned. sl@0: sl@0: Notes: sl@0: sl@0: 1. To close the file, use Close() sl@0: sl@0: 2. Attempting to open a file with the read-only attribute using the EFileWrite sl@0: access mode results in an error. sl@0: sl@0: 3. Attempting to open a file which is greater than or equal to 2GByte (2,147,483,648 bytes) sl@0: will fail with KErrTooBig sl@0: sl@0: 4. After a file has been opened, the current write position is set to the start sl@0: of the file. sl@0: If necessary, use RFile::Seek() to move to a different position within sl@0: the file. sl@0: sl@0: @param aFs The file server session. sl@0: @param aName The name of the file. Any path components (i.e. drive letter sl@0: or directory), which are not specified, are taken from sl@0: the session path.The file name shall not contain wild cards sl@0: ('?' or '*' characters) and illegal characters like sl@0: '<', '>', ':', '"', '/', '|' and '\000'. Backslash '\\' character sl@0: is allowed only as a path delimiter. The filename containing only sl@0: white space characters (See TChar::IsSpace()) is also illegal. sl@0: sl@0: @param aMode The mode in which the file is opened. See TFileMode. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide sl@0: error codes. sl@0: sl@0: @see TFileMode sl@0: sl@0: @capability Dependent If the path for aName is /Sys and aMode is neither sl@0: EFileShareReadersOnly nor EFileRead then Tcb capability is required. sl@0: @capability Dependent If the path for aName is /Sys and aMode is either sl@0: EFileShareReadersOnly or EFileRead then Allfiles capability is required. sl@0: @capability Dependent If the path for aName begins with /Private and does not match this process' sl@0: SID then AllFiles capability is required. sl@0: @capability Dependent If the path for aName begins with /Resource and aMode is neither sl@0: EFileShareReadersOrWriters|EFileRead nor EFileShareReadersOnly sl@0: nor EFileRead then Tcb capability is required. sl@0: sl@0: */ sl@0: { sl@0: TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileOpen, MODULEUID, aFs.Handle(), aMode, aName); sl@0: sl@0: aMode &= ~EFileBigFile; sl@0: TInt r = CreateSubSession(aFs,EFsFileOpen,TIpcArgs(&aName,aMode)); sl@0: sl@0: TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileOpenReturn, MODULEUID, r, SubSessionHandle()); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: EFSRV_EXPORT_C void RFile::Close() sl@0: /** sl@0: Closes the file. sl@0: sl@0: Any open files are closed when the file server session is closed. sl@0: sl@0: Close() is guaranteed to return, and provides no indication whether sl@0: it completed successfully or not. When closing a file you have written to, sl@0: you should ensure that data is committed to the file by invoking RFile::Flush() sl@0: before closing. If Flush() completes successfully, Close() is essentially a sl@0: no-operation. sl@0: */ sl@0: { sl@0: TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileClose, MODULEUID, Session().Handle(), SubSessionHandle()); sl@0: sl@0: #if defined (SYMBIAN_FTRACE_ENABLE) && defined(__DLL__) sl@0: // Need to close the handle to the trace LDD if this is an auto-close subsession sl@0: // as these close their parent session by calling RHandleBase::Close(), i.e. they sl@0: // bypass RFs::Close() which would normally be responsible for closing the LDD sl@0: TInt h = Session().Handle() ^ CObjectIx::ENoClose; sl@0: if ( h != NULL && (!(h & CObjectIx::ENoClose)) ) sl@0: { sl@0: RFTRACE_CLOSE; sl@0: } sl@0: #endif sl@0: sl@0: CloseSubSession(EFsFileSubClose); sl@0: sl@0: TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileCloseReturn, MODULEUID); sl@0: } sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::Create(RFs& aFs,const TDesC& aName,TUint aMode) sl@0: /** sl@0: Creates and opens a new file for writing. sl@0: sl@0: If the file already exists, an error is returned. sl@0: sl@0: If the resulting path does not exist, then the operation cannot proceed and sl@0: the function returns an error code. sl@0: sl@0: Notes: sl@0: sl@0: 1. To close the file, use Close() sl@0: sl@0: 2. It automatically sets the file's archive attribute. sl@0: sl@0: @param aFs The file server session. sl@0: @param aName The name of the file. Any path components (i.e. drive letter sl@0: or directory), which are not specified, are taken from sl@0: the session path. The file name shall not contain wild cards sl@0: ('?' or '*' characters) and illegal characters like sl@0: '<', '>', ':', '"', '/', '|' and '\000'. Backslash '\\' character sl@0: is allowed only as a path delimiter. The filename containing only sl@0: white space characters (See TChar::IsSpace()) is also illegal. sl@0: sl@0: @param aMode The mode in which the file is opened. The access mode is sl@0: automatically set to EFileWrite. See TFileMode. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide sl@0: error codes. sl@0: sl@0: @see TFileMode sl@0: sl@0: @capability Dependent If the path in aName starts with /Sys then capability Tcb is required sl@0: @capability Dependent If the path in aName starts with /Resource then capability Tcb is required sl@0: @capability Dependent If the path in aName starts with /Private and does not match this process' sl@0: SID then AllFiles capability is required. sl@0: sl@0: */ sl@0: { sl@0: aMode &= ~EFileBigFile; sl@0: sl@0: TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileCreate, MODULEUID, aFs.Handle(), aMode, aName); sl@0: sl@0: TInt r = CreateSubSession(aFs,EFsFileCreate,TIpcArgs(&aName,aMode)); sl@0: sl@0: TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileCreateReturn, MODULEUID, r, SubSessionHandle()); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::Replace(RFs& aFs,const TDesC& aName,TUint aMode) sl@0: /** sl@0: Opens a file for writing, replacing the content of any existing file of the sl@0: same name if it exists, or creating a new file if it does not exist. sl@0: sl@0: If the resulting path exists, then: sl@0: sl@0: - the length of an existing file with the same filename is re-set to zero sl@0: sl@0: - a new file is created, if no existing file with the same filename can be found. sl@0: sl@0: If the resulting path does not exist, then the operation cannot proceed and sl@0: the function returns an error code. sl@0: sl@0: Notes: sl@0: sl@0: - To close the file, use Close(), defined in the base class RFsBase. sl@0: sl@0: - It automatically sets the file's archive attribute. sl@0: sl@0: @param aFs The file server session. sl@0: @param aName The name of the file. Any path components (i.e. drive letter sl@0: or directory), which are not specified, are taken from sl@0: the session path. The file name shall not contain wild cards sl@0: ('?' or '*' characters) and illegal characters like sl@0: '<', '>', ':', '"', '/', '|' and '\000'. Backslash '\\' character sl@0: is allowed only as a path delimiter. The filename containing only sl@0: white space characters (See TChar::IsSpace()) is also illegal. sl@0: sl@0: @param aMode The mode in which the file is opened. The access mode is sl@0: automatically set to EFileWrite. See TFileMode. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide sl@0: error codes. sl@0: sl@0: @see TFileMode sl@0: sl@0: @capability Dependent If the path in aName starts with /Sys then capability Tcb is required sl@0: @capability Dependent If the path in aName starts with /Resource then capability Tcb is required sl@0: @capability Dependent If the path in aName starts with /Private and does not match this process' sl@0: SID then AllFiles capability is required. sl@0: sl@0: */ sl@0: { sl@0: TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileReplace, MODULEUID, aFs.Handle(), aMode, aName); sl@0: aMode &= ~EFileBigFile; sl@0: TInt r = CreateSubSession(aFs,EFsFileReplace,TIpcArgs(&aName,aMode)); sl@0: TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileReplaceReturn, MODULEUID, r, SubSessionHandle()); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::Temp(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aMode) sl@0: /** sl@0: Creates and opens a temporary file with a unique name for writing and reading. sl@0: sl@0: Notes: sl@0: sl@0: 1. To close the file, use Close() sl@0: sl@0: @param aFs The file server session. sl@0: @param aPath The directory in which the file is created. sl@0: @param aName On return, contains the full path and file name of the file. sl@0: The filename is guaranteed to be unique within the directory sl@0: specified by aPath. sl@0: @param aMode The mode in which the file is opened. The access mode is sl@0: automatically set to EFileWrite. See TFileMode. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide sl@0: error codes. sl@0: sl@0: @see TFileMode sl@0: sl@0: @capability Dependent If aPath starts with /Sys then capability Tcb is required sl@0: @capability Dependent If aPath starts with /Resource then capability Tcb is required sl@0: @capability Dependent If aPath starts with /Private and does not match this process' sl@0: SID then AllFiles capability is required. sl@0: */ sl@0: { sl@0: TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileTemp, MODULEUID, aFs.Handle(), aPath, aMode); sl@0: aMode &= ~EFileBigFile; sl@0: TInt r = CreateSubSession(aFs,EFsFileTemp,TIpcArgs(&aPath,aMode,&aName)); sl@0: TRACERETMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileTempReturn, MODULEUID, r, SubSessionHandle(), aName); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::Read(TDes8& aDes) const sl@0: /** sl@0: Reads from the file at the current position. sl@0: sl@0: This is a synchronous function. sl@0: sl@0: Note that when an attempt is made to read beyond the end of the file, sl@0: no error is returned. sl@0: The descriptor's length is set to the number of bytes read into sl@0: it. Therefore, when reading through a file,the end of file has been reached sl@0: when the descriptor length, as returned by TDesC8::Length(), is zero. sl@0: sl@0: @param aDes Descriptor into which binary data is read. Any existing contents sl@0: are overwritten. On return, its length is set to the number of sl@0: bytes read. sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: sl@0: @see TDesC8::Length sl@0: */ sl@0: { sl@0: TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileRead1, MODULEUID, Session().Handle(), SubSessionHandle(), aDes.MaxLength()); sl@0: sl@0: TInt r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),I64LOW(KCurrentPosition64))); sl@0: sl@0: TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead1Return, MODULEUID, r, aDes.Length()); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C void RFile::Read(TDes8& aDes,TRequestStatus& aStatus) const sl@0: /** sl@0: Reads from the file at the current position. sl@0: sl@0: This is an asynchronous function. sl@0: sl@0: Note that when an attempt is made to read beyond the end of the file, sl@0: no error is returned. sl@0: The descriptor's length is set to the number of bytes read into sl@0: it. Therefore, when reading through a file,the end of file has been reached sl@0: when the descriptor length, as returned by TDesC8::Length(), is zero. sl@0: sl@0: @param aDes Descriptor into which binary data is read. Any existing contents sl@0: are overwritten. On return, its length is set to the number of sl@0: bytes read. sl@0: NB: this function is asynchronous and the request that it sl@0: represents may not complete until some time after the call sl@0: to the function has returned. It is important, therefore, that sl@0: this descriptor remain valid, or remain in scope, until you have sl@0: been notified that the request is complete. sl@0: sl@0: @param aStatus Request status. On completion contains: sl@0: KErrNone, if successful, otherwise one of the other system-wide error codes. sl@0: sl@0: @see TDesC8::Length sl@0: */ sl@0: { sl@0: TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileRead2, MODULEUID, Session().Handle(), SubSessionHandle(), aDes.MaxLength(), &aStatus); sl@0: sl@0: RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),I64LOW(KCurrentPosition64)),aStatus); sl@0: sl@0: TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead2Return, MODULEUID); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::Read(TDes8& aDes,TInt aLength) const sl@0: /** sl@0: Reads the specified number of bytes of binary data from the file at the current position. sl@0: sl@0: This is a synchronous function. sl@0: sl@0: Note that when an attempt is made to read beyond the end of the file, sl@0: no error is returned. sl@0: The descriptor's length is set to the number of bytes read into sl@0: it. Therefore, when reading through a file,the end of file has been reached sl@0: when the descriptor length, as returned by TDesC8::Length(), is zero. sl@0: Assuming aLength is less than the maximum length of the descriptor, the only circumstances sl@0: in which Read() can return fewer bytes than requested, is when the end of sl@0: file is reached or if an error occurs. sl@0: sl@0: @param aDes Descriptor into which binary data is read. Any existing sl@0: contents are overwritten. On return, its length is set to sl@0: the number of bytes read. sl@0: sl@0: @param aLength The number of bytes to be read from the file into the descriptor. sl@0: If an attempt is made to read more bytes than the descriptor's sl@0: maximum length, the function returns KErrOverflow. sl@0: This value must not be negative, otherwise the function sl@0: returns KErrArgument. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: */ sl@0: { sl@0: TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileRead1, MODULEUID, Session().Handle(), SubSessionHandle(), aLength); sl@0: sl@0: if (aLength==0) sl@0: { sl@0: aDes.Zero(); sl@0: return(KErrNone); sl@0: } sl@0: else if(aLength>aDes.MaxLength()) sl@0: { sl@0: return(KErrOverflow); sl@0: } sl@0: TInt r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,I64LOW(KCurrentPosition64))); sl@0: sl@0: TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead1Return, MODULEUID, r, aDes.Length()); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C void RFile::Read(TDes8& aDes,TInt aLength,TRequestStatus& aStatus) const sl@0: /** sl@0: Reads a specified number of bytes of binary data from the file at the current position. sl@0: sl@0: This is an asynchronous function. sl@0: sl@0: Note that when an attempt is made to read beyond the end of the file, sl@0: no error is returned. sl@0: The descriptor's length is set to the number of bytes read into it. sl@0: Therefore, when reading through a file, the end of file has been reached sl@0: when the descriptor length, as returned by TDesC8::Length(), is zero. sl@0: Assuming aLength is less than the maximum length of the descriptor, the only sl@0: circumstances in which Read() can return fewer bytes than requested is when sl@0: the end of file is reached or if an error has occurred. sl@0: sl@0: @param aDes Descriptor into which binary data is read. Any existing sl@0: contents are overwritten. On return, its length is set to the sl@0: number of bytes read. sl@0: NB: this function is asynchronous and the request that it sl@0: represents may not complete until some time after the call sl@0: to the function has returned. It is important, therefore, that sl@0: this descriptor remain valid, or remain in scope, until you have sl@0: been notified that the request is complete. sl@0: sl@0: @param aLength The number of bytes to be read from the file into the descriptor. sl@0: If an attempt is made to read more bytes than the descriptor's sl@0: maximum length, then the function updates aStatus parameter with KErrOverflow. sl@0: It must not be negative otherwise the function updates aStatus with KErrArgument. sl@0: sl@0: @param aStatus Request status. On completion contains KErrNone if successful, sl@0: otherwise one of the other system-wide error codes. sl@0: */ sl@0: { sl@0: TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileRead2, MODULEUID, Session().Handle(), SubSessionHandle(), aLength, &aStatus); sl@0: sl@0: if (aLength==0) sl@0: { sl@0: aDes.Zero(); sl@0: TRequestStatus* req=(&aStatus); sl@0: User::RequestComplete(req,KErrNone); sl@0: return; sl@0: } sl@0: else if(aLength>aDes.MaxLength()) sl@0: { sl@0: TRequestStatus* req=(&aStatus); sl@0: User::RequestComplete(req,KErrOverflow); sl@0: return; sl@0: } sl@0: sl@0: RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,I64LOW(KCurrentPosition64)),aStatus); sl@0: sl@0: TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead2Return, MODULEUID); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::Read(TInt aPos,TDes8& aDes) const sl@0: /** sl@0: Reads from the file at the specified offset within the file sl@0: sl@0: This is a synchronous function. sl@0: sl@0: Note that when an attempt is made to read beyond the end of the file, sl@0: no error is returned. sl@0: The descriptor's length is set to the number of bytes read into it. sl@0: Therefore, when reading through a file, the end of file has been reached sl@0: when the descriptor length, as returned by TDesC8::Length(), is zero. sl@0: sl@0: @param aPos Position of first byte to be read. This is an offset from sl@0: the start of the file. If no position is specified, reading sl@0: begins at the current file position. sl@0: If aPos is beyond the end of the file, the function returns sl@0: a zero length descriptor. sl@0: sl@0: @param aDes The descriptor into which binary data is read. Any existing content sl@0: is overwritten. On return, its length is set to the number of sl@0: bytes read. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: sl@0: @panic FSCLIENT 19 if aPos is negative. sl@0: */ sl@0: { sl@0: TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileRead3, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.MaxLength()); sl@0: sl@0: __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); sl@0: sl@0: TInt r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),aPos)); sl@0: sl@0: TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead3Return, MODULEUID, r, aDes.Length()); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C void RFile::Read(TInt aPos,TDes8& aDes,TRequestStatus& aStatus) const sl@0: /** sl@0: Reads from the file at the specified offset within the file. sl@0: sl@0: This is an asynchronous function. sl@0: sl@0: Note that when an attempt is made to read beyond the end of the file, sl@0: no error is returned. sl@0: The descriptor's length is set to the number of bytes read into it. sl@0: Therefore, when reading through a file, the end of file has been reached sl@0: when the descriptor length, as returned by TDesC8::Length(), is zero. sl@0: sl@0: @param aPos Position of first byte to be read. This is an offset from sl@0: the start of the file. If no position is specified, sl@0: reading begins at the current file position. sl@0: If aPos is beyond the end of the file, the function returns sl@0: a zero length descriptor. sl@0: sl@0: @param aDes The descriptor into which binary data is read. Any existing sl@0: content is overwritten. On return, its length is set to sl@0: the number of bytes read. sl@0: NB: this function is asynchronous and the request that it sl@0: represents may not complete until some time after the call sl@0: to the function has returned. It is important, therefore, that sl@0: this descriptor remain valid, or remain in scope, until you have sl@0: been notified that the request is complete. sl@0: sl@0: @param aStatus The request status. On completion, contains an error code of KErrNone sl@0: if successful, otherwise one of the other system-wide error codes. sl@0: sl@0: @panic FSCLIENT 19 if aPos is negative. sl@0: */ sl@0: { sl@0: TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileRead4, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.MaxLength(), &aStatus); sl@0: sl@0: __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); sl@0: RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),aPos),aStatus); sl@0: sl@0: TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead4Return, MODULEUID); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::Read(TInt aPos,TDes8& aDes,TInt aLength) const sl@0: /** sl@0: Reads the specified number of bytes of binary data from the file at a specified sl@0: offset within the file. sl@0: sl@0: This is a synchronous function. sl@0: sl@0: Note that when an attempt is made to read beyond the end of the file, sl@0: no error is returned. sl@0: The descriptor's length is set to the number of bytes read into it. sl@0: Therefore, when reading through a file, the end of file has been reached sl@0: when the descriptor length, as returned by TDesC8::Length(), is zero. sl@0: Assuming aLength is less than the maximum length of the descriptor, the only sl@0: circumstances in which Read() can return fewer bytes than requested is when sl@0: the end of file is reached or if an error has occurred. sl@0: sl@0: @param aPos Position of first byte to be read. This is an offset from sl@0: the start of the file. If no position is specified, sl@0: reading begins at the current file position. sl@0: If aPos is beyond the end of the file, the function returns sl@0: a zero length descriptor. sl@0: sl@0: @param aDes The descriptor into which binary data is read. Any existing sl@0: contents are overwritten. On return, its length is set to sl@0: the number of bytes read. sl@0: @param aLength The number of bytes to read from the file into the descriptor. sl@0: If an attempt is made to read more bytes than the descriptor's sl@0: maximum length, then the function updates aStatus parameter with KErrOverflow. sl@0: It must not be negative otherwise the function updates aStatus with KErrArgument. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide sl@0: error codes. sl@0: sl@0: @panic FSCLIENT 19 if aPos is negative. sl@0: */ sl@0: { sl@0: TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileRead3, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength); sl@0: sl@0: __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); sl@0: if (aLength==0) sl@0: { sl@0: aDes.Zero(); sl@0: return(KErrNone); sl@0: } sl@0: else if(aLength>aDes.MaxLength()) sl@0: { sl@0: return(KErrOverflow); sl@0: } sl@0: sl@0: TInt r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,aPos)); sl@0: sl@0: TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead3Return, MODULEUID, r, aDes.Length()); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C void RFile::Read(TInt aPos,TDes8& aDes,TInt aLength,TRequestStatus& aStatus) const sl@0: /** sl@0: Reads the specified number of bytes of binary data from the file at a specified sl@0: offset within the file. sl@0: sl@0: This is an asynchronous function. sl@0: sl@0: Note that when an attempt is made to read beyond the end of the file, sl@0: no error is returned. sl@0: The descriptor's length is set to the number of bytes read into it. sl@0: Therefore, when reading through a file, the end of file has been reached sl@0: when the descriptor length, as returned by TDesC8::Length(), is zero. sl@0: Assuming aLength is less than the maximum length of the descriptor, the only sl@0: circumstances in which Read() can return fewer bytes than requested is when sl@0: the end of file is reached or if an error has occurred. sl@0: sl@0: @param aPos Position of first byte to be read. This is an offset from sl@0: the start of the file. If no position is specified, sl@0: reading begins at the current file position. sl@0: If aPos is beyond the end of the file, the function returns sl@0: a zero length descriptor. sl@0: sl@0: @param aDes The descriptor into which binary data is read. Any existing sl@0: contents are overwritten. On return, its length is set to sl@0: the number of bytes read. sl@0: NB: this function is asynchronous and the request that it sl@0: represents may not complete until some time after the call sl@0: to the function has returned. It is important, therefore, that sl@0: this descriptor remain valid, or remain in scope, until you have sl@0: been notified that the request is complete. sl@0: sl@0: @param aLength The number of bytes to read from the file into the descriptor. sl@0: If an attempt is made to read more bytes than the descriptor's sl@0: maximum length, then the function returns KErrOverflow. sl@0: It must not be negative otherwise the function returns KErrArgument. sl@0: sl@0: @param aStatus Request status. On completion contains KErrNone if successful, sl@0: otherwise one of the other system-wide error codes. sl@0: sl@0: @panic FSCLIENT 19 if aPos is negative. sl@0: */ sl@0: { sl@0: TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileRead4, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength, &aStatus); sl@0: sl@0: __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); sl@0: if (aLength==0) sl@0: { sl@0: aDes.Zero(); sl@0: TRequestStatus* req=(&aStatus); sl@0: User::RequestComplete(req,KErrNone); sl@0: return; sl@0: } sl@0: else if(aLength>aDes.MaxLength()) sl@0: { sl@0: TRequestStatus* req=(&aStatus); sl@0: User::RequestComplete(req,KErrOverflow); sl@0: return; sl@0: } sl@0: sl@0: RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,aPos),aStatus); sl@0: sl@0: TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead4Return, MODULEUID); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C void RFile::ReadCancel(TRequestStatus& aStatus) const sl@0: /** sl@0: Cancels a specific outstanding asynchronous read request. sl@0: sl@0: The outstanding request completes with KErrCancel. sl@0: sl@0: @param aStat The request status object identified with the original sl@0: asynchronous read. sl@0: */ sl@0: { sl@0: if(aStatus != KRequestPending) sl@0: return; sl@0: SendReceive(EFsFileReadCancel, TIpcArgs(&aStatus)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C void RFile::ReadCancel() const sl@0: /** sl@0: Cancels all outstanding asynchronous read requests for this subsession. sl@0: sl@0: All outstanding requests complete with KErrCancel. sl@0: */ sl@0: { sl@0: SendReceive(EFsFileReadCancel, TIpcArgs(NULL)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::Write(const TDesC8& aDes) sl@0: /** sl@0: Writes to the file at the current offset within the file. sl@0: sl@0: This is a synchronous function. sl@0: sl@0: NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig sl@0: sl@0: @param aDes The descriptor from which binary data is written. sl@0: The function writes the entire contents of aDes to the file. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: */ sl@0: { sl@0: TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1, MODULEUID, Session().Handle(), SubSessionHandle(), aDes.Length()); sl@0: TInt r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),I64LOW(KCurrentPosition64))); sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1Return, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: EFSRV_EXPORT_C void RFile::Write(const TDesC8& aDes,TRequestStatus& aStatus) sl@0: /** sl@0: Writes to the file at the current offset within the file. sl@0: sl@0: This is an asynchronous function. sl@0: sl@0: NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig sl@0: sl@0: @param aDes The descriptor from which binary data is written. sl@0: The function writes the entire contents of aDes to the file. sl@0: NB: this function is asynchronous and the request that it sl@0: represents may not complete until some time after the call sl@0: to the function has returned. It is important, therefore, that sl@0: this descriptor remain valid, or remain in scope, until you have sl@0: been notified that the request is complete. sl@0: sl@0: @param aStatus Request status. On completion contains KErrNone if successful, sl@0: otherwise one of the other system-wide error codes. sl@0: */ sl@0: { sl@0: TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2, MODULEUID, Session().Handle(), SubSessionHandle(), aDes.Length(), &aStatus); sl@0: sl@0: RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),I64LOW(KCurrentPosition64)),aStatus); sl@0: TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2Return, MODULEUID); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::Write(const TDesC8& aDes,TInt aLength) sl@0: /** sl@0: Writes a portion of a descriptor to the file at the current offset within sl@0: the file. sl@0: sl@0: This is a synchronous function. sl@0: sl@0: NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig sl@0: sl@0: @param aDes The descriptor from which binary data is written. sl@0: @param aLength The number of bytes to be written from the descriptor. sl@0: This must not be greater than the length of the descriptor. sl@0: It must not be negative. sl@0: sl@0: @return KErrNone if successful; KErrArgument if aLength is negative; sl@0: otherwise one of the other system-wide error codes. sl@0: sl@0: @panic FSCLIENT 27 in debug mode, if aLength is greater than the length sl@0: of the descriptor aDes. sl@0: */ sl@0: { sl@0: TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1, MODULEUID, Session().Handle(), SubSessionHandle(), aLength); sl@0: sl@0: __ASSERT_DEBUG(aDes.Length()>=aLength,Panic(EBadLength)); sl@0: TInt r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,I64LOW(KCurrentPosition64))); sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1Return, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C void RFile::Write(const TDesC8& aDes,TInt aLength,TRequestStatus& aStatus) sl@0: /** sl@0: Writes a portion of a descriptor to the file at the current offset sl@0: within the file. sl@0: sl@0: This is an asynchronous function. sl@0: sl@0: NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig sl@0: sl@0: @param aDes The descriptor from which binary data is written. sl@0: NB: this function is asynchronous and the request that it sl@0: represents may not complete until some time after the call sl@0: to the function has returned. It is important, therefore, that sl@0: this descriptor remain valid, or remain in scope, until you have sl@0: been notified that the request is complete. sl@0: sl@0: @param aLength The number of bytes to be written from the descriptor. sl@0: This must not be greater than the length of the descriptor. sl@0: It must not be negative. sl@0: sl@0: @param aStatus Request status. On completion contains KErrNone if successful; sl@0: KErrArgument if aLength is negative; sl@0: otherwise one of the other system-wide error codes. sl@0: sl@0: */ sl@0: { sl@0: TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2, MODULEUID, Session().Handle(), SubSessionHandle(), aLength, &aStatus); sl@0: sl@0: RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,I64LOW(KCurrentPosition64)),aStatus); sl@0: sl@0: TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2Return, MODULEUID); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::Write(TInt aPos,const TDesC8& aDes) sl@0: /** sl@0: Writes to the file at the specified offset within the file sl@0: sl@0: This is a synchronous function. sl@0: sl@0: NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig sl@0: sl@0: @param aPos The offset from the start of the file at which the first sl@0: byte is written. sl@0: If a position beyond the end of the file is specified, then sl@0: the write operation begins at the end of the file. sl@0: If the position has been locked, then the write fails. sl@0: sl@0: @param aDes The descriptor from which binary data is written. The function writes sl@0: the entire contents of aDes to the file. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: sl@0: @panic FSCLIENT 19 if aPos is negative. sl@0: */ sl@0: { sl@0: TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileWrite3, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.Length()); sl@0: sl@0: __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); sl@0: TInt r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),aPos)); sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite3Return, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C void RFile::Write(TInt aPos,const TDesC8& aDes,TRequestStatus& aStatus) sl@0: /** sl@0: Writes to the file at the specified offset within the file sl@0: sl@0: This is an asynchronous function. sl@0: sl@0: NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig sl@0: sl@0: @param aPos The offset from the start of the file at which the first sl@0: byte is written. sl@0: If a position beyond the end of the file is specified, then sl@0: the write operation begins at the end of the file. sl@0: If the position has been locked, then the write fails. sl@0: sl@0: @param aDes The descriptor from which binary data is written. The function sl@0: writes the entire contents of aDes to the file. sl@0: NB: this function is asynchronous and the request that it sl@0: represents may not complete until some time after the call sl@0: to the function has returned. It is important, therefore, that sl@0: this descriptor remain valid, or remain in scope, until you have sl@0: been notified that the request is complete. sl@0: sl@0: @param aStatus Request status. On completion contains KErrNone if successful, sl@0: otherwise one of the other system-wide error codes. sl@0: sl@0: @panic FSCLIENT 19 if aPos is negative. sl@0: */ sl@0: { sl@0: TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileWrite4, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.Length(), &aStatus); sl@0: sl@0: __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); sl@0: RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),aPos),aStatus); sl@0: TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite4Return, MODULEUID); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::Write(TInt aPos,const TDesC8& aDes,TInt aLength) sl@0: /** sl@0: Writes the specified number of bytes to the file at the specified offset within the file. sl@0: sl@0: This is a synchronous function. sl@0: sl@0: NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig sl@0: sl@0: @param aPos The offset from the start of the file at which the first sl@0: byte is written. sl@0: If a position beyond the end of the file is specified, then sl@0: the write operation begins at the end of the file. sl@0: If the position has been locked, then the write fails. sl@0: sl@0: @param aDes The descriptor from which binary data is written. sl@0: @param aLength The number of bytes to be written from aDes . sl@0: It must not be negative. sl@0: sl@0: @return KErrNone if successful; KErrArgument if aLength is negative; sl@0: otherwise one of the other system-wide error codes. sl@0: sl@0: @panic FSCLIENT 19 if aPos is negative. sl@0: */ sl@0: { sl@0: TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1, MODULEUID, Session().Handle(), SubSessionHandle(), aLength); sl@0: sl@0: __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); sl@0: TInt r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,aPos)); sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1Return, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C void RFile::Write(TInt aPos,const TDesC8& aDes,TInt aLength,TRequestStatus& aStatus) sl@0: /** sl@0: Writes the specified number of bytes to the file at the specified offset within the file. sl@0: sl@0: This is an asynchronous function. sl@0: sl@0: NB Attempting to extend the file to 2 GByte or greater will fail with KErrTooBig sl@0: sl@0: @param aPos The offset from the start of the file at which the first sl@0: byte is written. sl@0: If a position beyond the end of the file is specified, then sl@0: the write operation begins at the end of the file. sl@0: If the position has been locked, then the write fails. sl@0: sl@0: @param aDes The descriptor from which binary data is written. sl@0: NB: this function is asynchronous and the request that it sl@0: represents may not complete until some time after the call sl@0: to the function has returned. It is important, therefore, that sl@0: this descriptor remain valid, or remain in scope, until you have sl@0: been notified that the request is complete. sl@0: sl@0: @param aLength The number of bytes to be written from aDes. sl@0: It must not be negative. sl@0: sl@0: @param aStatus Request status. On completion contains KErrNone if successful; sl@0: KErrArgument if aLength is negative; sl@0: otherwise one of the other system-wide error codes. sl@0: sl@0: @panic FSCLIENT 19 if aPos is negative. sl@0: */ sl@0: { sl@0: TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength, &aStatus); sl@0: sl@0: __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); sl@0: RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,aPos),aStatus); sl@0: TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2Return, MODULEUID); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::Lock(TInt aPos,TInt aLength) const sl@0: /** sl@0: Locks a region within the file as defined by a range of bytes. sl@0: sl@0: This ensures that those bytes are accessible sl@0: only through the RFile object which claims the lock. To re-allow access by sl@0: other programs to the locked region, it must either be unlocked or the file sl@0: closed. Locking can be used to synchronize operations on a file when more sl@0: than one program has access to the file in EFileShareAny mode. sl@0: sl@0: More than one distinct region of a file can be locked, but an error is returned sl@0: if more than one lock is placed on the same region. Different RFile objects sl@0: can lock different parts of the same file as long as the file is opened in sl@0: EFileShareAny mode. The locked region may extend beyond the end of a file; sl@0: this prevents the file from being extended by other programs. sl@0: sl@0: @param aPos Position in file from which to lock; this is the offset from sl@0: the beginning of the file. sl@0: @param aLength Number of bytes to lock. sl@0: sl@0: @return KErrNone if successful; KErrArgument if aPos+aLength>2G-1 boundary; sl@0: otherwise one of the other system-wide error codes. sl@0: sl@0: @panic FSCLIENT 17 if aLength is not greater than zero, sl@0: @panic FSCLIENT 19 if aPos is negative. sl@0: sl@0: */ sl@0: { sl@0: TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileLock, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength); sl@0: sl@0: __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); sl@0: sl@0: TInt r = SendReceive(EFsFileLock,TIpcArgs(aPos,aLength)); sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileLockReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::UnLock(TInt aPos,TInt aLength) const sl@0: /** sl@0: Unlocks a region within the file as defined by a range of bytes. sl@0: sl@0: A lock can only be removed by the RFile object which claimed the lock. sl@0: sl@0: A portion of a locked region cannot be unlocked. The entire locked region sl@0: must be unlocked otherwise an error is returned. If any byte within sl@0: the specified range of bytes to unlock is not locked, an error is returned. sl@0: sl@0: @param aPos Position in file from which to unlock; this is the offset from sl@0: the beginning of the file. sl@0: @param aLength Number of bytes to unlock. sl@0: sl@0: @return KErrNone if successful; KErrArgument if aPos+aLength>2G-1 boundary; sl@0: otherwise one of the other system-wide error codes. sl@0: sl@0: @panic FSCLIENT 18 if aLength is not greater than zero, sl@0: @panic FSCLIENT 19 if aPos is negative. sl@0: */ sl@0: { sl@0: TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileUnLock, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength); sl@0: sl@0: __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); sl@0: TInt r = SendReceive(EFsFileUnLock,TIpcArgs(aPos,aLength)); sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileUnLockReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::Seek(TSeek aMode,TInt& aPos) const sl@0: /** sl@0: Sets the the current file position. sl@0: sl@0: The function can also be used to get the current file sl@0: position without changing it. The file position is the position at which sl@0: reading and writing takes place. The start of the file is position zero. sl@0: sl@0: To retrieve the current file position without changing it, specify ESeekCurrent sl@0: for the seek mode, and zero for the offset. sl@0: sl@0: If the seek mode is ESeekStart, then: sl@0: sl@0: 1. the function does not modify the aPos argument, sl@0: sl@0: 2. the function returns an error if the offset specified is negative. sl@0: sl@0: If the seek mode is ESeekAddress, an error is returned if: sl@0: sl@0: 1. the file is not in ROM, sl@0: sl@0: 2. the offset specified is greater than the size of the file. sl@0: sl@0: @param aMode Seek mode. Controls the destination of the seek operation. sl@0: @param aPos Offset from location specified in aMode. Can be negative. sl@0: On return contains the new file position. sl@0: If the seek mode is either ESeekCurrent or ESeekEnd and the offset sl@0: specifies a position before the start of the file sl@0: or beyond the end of the file, then on return, aPos is set to sl@0: the new file position (either the start or the end of the file). sl@0: If the seek mode is ESeekAddress, aPos returns the address of sl@0: the byte at the specified offset within the file. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: */ sl@0: { sl@0: TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileSeek, MODULEUID, Session().Handle(), SubSessionHandle(), aMode, aPos, 0); sl@0: sl@0: TInt64 newPos = aPos; sl@0: TPckg pkNewPos(newPos); sl@0: TInt r = SendReceive(EFsFileSeek|KIpcArgSlot2Desc,TIpcArgs(aPos,aMode,&pkNewPos)); sl@0: if(KErrNone == r) sl@0: aPos = I64LOW(newPos); sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileSeekReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::Flush() sl@0: /** sl@0: Commits data to the storage device and flushes internal buffers without closing sl@0: the file. sl@0: sl@0: Although RFile::Close() also flushes internal buffers, it is often useful sl@0: to call Flush() before a file is closed. This is because Close() returns no sl@0: error information, so there is no way of telling whether the final data was sl@0: written to the file successfully or not. Once data has been flushed, Close() sl@0: is effectively a no-operation. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: */ sl@0: { sl@0: TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileFlush, MODULEUID, Session().Handle(), SubSessionHandle(), NULL); sl@0: sl@0: TInt r = RSubSessionBase::SendReceive(EFsFileFlush); sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileFlushReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C void RFile::Flush(TRequestStatus& aStatus) sl@0: /** sl@0: Commits data to the storage device and flushes internal buffers without closing sl@0: the file. sl@0: sl@0: Although RFile::Close() also flushes internal buffers, it is often useful sl@0: to call Flush() before a file is closed. This is because Close() returns no sl@0: error information, so there is no way of telling whether the final data was sl@0: written to the file successfully or not. Once data has been flushed, Close() sl@0: is effectively a no-operation. sl@0: sl@0: @param aStatus Request status. On completion contains KErrNone if successful, sl@0: otherwise one of the other system-wide error codes. sl@0: */ sl@0: { sl@0: TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileFlush, MODULEUID, Session().Handle(), SubSessionHandle(), &aStatus); sl@0: sl@0: RSubSessionBase::SendReceive(EFsFileFlush, aStatus); sl@0: sl@0: TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileFlushReturn, MODULEUID); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::Size(TInt& aSize) const sl@0: /** sl@0: Gets the current file size. sl@0: sl@0: @param aSize On return, the size of the file in bytes. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: */ sl@0: { sl@0: TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileSize, MODULEUID, Session().Handle(), SubSessionHandle()); sl@0: sl@0: TInt64 size = aSize; sl@0: TPckg pkSize(size); sl@0: TInt r = SendReceive(EFsFileSize|KIpcArgSlot0Desc,TIpcArgs(&pkSize)); sl@0: if(KErrNone != r) sl@0: return r; sl@0: aSize = I64LOW(size); sl@0: #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API sl@0: if (size > KMaxTInt) sl@0: return (KErrTooBig); sl@0: #endif sl@0: sl@0: TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileSizeReturn, MODULEUID, r, aSize); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::SetSize(TInt aSize) sl@0: /** sl@0: Sets the file size. sl@0: sl@0: If the size of the file is reduced, data may be lost from sl@0: the end of the file. sl@0: sl@0: Note: sl@0: sl@0: 1. The current file position remains unchanged unless SetSize() reduces the size sl@0: of the file in such a way that the current file position is now beyond sl@0: the end of the file. In this case, the current file position is set to sl@0: the end of file. sl@0: sl@0: 2. If the file was not opened for writing, an error is returned. sl@0: sl@0: @param aSize The new size of the file, in bytes. This value must not be negative, otherwise the function raises a panic. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: sl@0: @panic FSCLIENT 20 If aSize is negative. sl@0: sl@0: */ sl@0: { sl@0: TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileSetSize, MODULEUID, Session().Handle(), SubSessionHandle(), aSize, 0); sl@0: sl@0: TInt r = SendReceive(EFsFileSetSize,TIpcArgs(aSize)); sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileSetSizeReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::Att(TUint& aVal) const sl@0: /** sl@0: Gets the file's attributes. sl@0: sl@0: @param aVal A bitmask which, on return, contains the file’s attributes. sl@0: For more information, see KEntryAttNormal and the other sl@0: file/directory attributes. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: sl@0: @see KEntryAttNormal sl@0: */ sl@0: { sl@0: TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileAtt, MODULEUID, Session().Handle(), SubSessionHandle()); sl@0: sl@0: TPtr8 a((TUint8*)&aVal,sizeof(TUint)); sl@0: sl@0: TInt r = SendReceive(EFsFileAtt,TIpcArgs(&a)); sl@0: sl@0: TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileAttReturn, MODULEUID, r, aVal); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::SetAtt(TUint aSetAttMask,TUint aClearAttMask) sl@0: /** sl@0: Sets or clears file attributes using two bitmasks. sl@0: sl@0: The first mask controls which attributes are set. sl@0: The second controls which attributes are cleared. sl@0: sl@0: Notes: sl@0: sl@0: 1. The file must have been opened for writing, or an error is returned. sl@0: sl@0: 2. A panic is raised if any attribute is specified in both bitmasks. sl@0: sl@0: 3. An attempt to set or clear the KEntryAttDir, KEntryAttVolume or KEntryAttRemote sl@0: attributes have no effect. sl@0: sl@0: 4. The new attribute values take effect when the file is flushed or closed (which sl@0: implies a flush). sl@0: sl@0: @param aSetAttMask A bitmask indicating the file attributes to be set sl@0: @param aClearAttMask A bitmask indicating the attributes to be cleared. For sl@0: more information see KEntryAttNormal, and the other sl@0: file/directory attributes. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: sl@0: @panic FSCLIENT 21 if the same attribute bit is set in both bitmasks. sl@0: */ sl@0: { sl@0: TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileSetAtt, MODULEUID, Session().Handle(), SubSessionHandle(), aSetAttMask, aClearAttMask); sl@0: sl@0: __ASSERT_ALWAYS((aSetAttMask&aClearAttMask)==0,Panic(EAttributesIllegal)); sl@0: sl@0: TInt r = SendReceive(EFsFileSetAtt,TIpcArgs(aSetAttMask,aClearAttMask)); sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileSetAttReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::Modified(TTime& aTime) const sl@0: /** sl@0: Gets local date and time the file was last modified, in universal time. sl@0: sl@0: @param aTime On return, contains the date and time the file was last modified in UTC. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: */ sl@0: { sl@0: TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileModified, MODULEUID, Session().Handle(), SubSessionHandle()); sl@0: sl@0: TPtr8 t((TUint8*)&aTime,sizeof(TTime)); sl@0: TInt r = SendReceive(EFsFileModified,TIpcArgs(&t)); sl@0: sl@0: TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileModifiedReturn, MODULEUID, r, I64LOW(aTime.Int64()), I64HIGH(aTime.Int64())); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::SetModified(const TTime& aTime) sl@0: /** sl@0: Sets the date and time the file was last modified. UTC date and time should be used. sl@0: sl@0: Notes: sl@0: sl@0: 1. The file must have been opened for writing, or an error is returned. sl@0: sl@0: 2. The new modified time takes effect when the file is flushed or closed (which sl@0: implies a flush). sl@0: sl@0: @param aTime The new date and time the file was last modified, in universal time. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: */ sl@0: { sl@0: TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileSetModified, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aTime.Int64()), I64HIGH(aTime.Int64())); sl@0: sl@0: TPtrC8 t((TUint8*)&aTime,sizeof(TTime)); sl@0: TInt r = SendReceive(EFsFileSetModified,TIpcArgs(&t)); sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileSetModifiedReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::Set(const TTime& aTime,TUint aMask,TUint aVal) sl@0: /** sl@0: Sets the file’s attributes, and the date and time it was last modified. sl@0: sl@0: It combines the functionality of SetAtt() and SetModified() sl@0: sl@0: An attempt to set or clear the KEntryAttDir, KEntryAttVolume or KEntryAttRemote sl@0: attributes have no effect. sl@0: sl@0: @param aTime The new date and time the file was last modified. UTC date and time should be used. sl@0: @param aMask A bitmask indicating the file attributes to be set sl@0: @param aVal A bitmask indicating the attributes to be cleared. For sl@0: more information see KEntryAttNormal, and the other sl@0: file/directory attributes. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: sl@0: @panic FSCLIENT 21 if the same attribute bit is set in both bitmasks. sl@0: sl@0: @see RFile::SetModified sl@0: @see RFile::SetAtt sl@0: */ sl@0: { sl@0: TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileSet, MODULEUID, sl@0: Session().Handle(), SubSessionHandle(), I64LOW(aTime.Int64()), I64HIGH(aTime.Int64()), aMask, aVal); sl@0: sl@0: __ASSERT_ALWAYS((aVal&aMask)==0,Panic(EAttributesIllegal)); sl@0: TPtrC8 t((TUint8*)&aTime,sizeof(TTime)); sl@0: TInt r = SendReceive(EFsFileSet,TIpcArgs(&t,aMask,aVal)); sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileSetReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::ChangeMode(TFileMode aNewMode) sl@0: /** sl@0: Switches an open file's access mode between EFileShareExclusive and EFileShareReadersOnly. sl@0: sl@0: This allows or disallows read-only access without having to close and re-open the file. sl@0: sl@0: @param aNewMode The new access mode. sl@0: sl@0: @return KErrNone, if successful; sl@0: KErrArgument, if aNewMode has any value other than the two specified; sl@0: KErrAccessDenied, if: sl@0: a) the function is called when the current file share sl@0: mode is EFileShareAny; sl@0: b) the file has multiple readers, and an attempt is made sl@0: to change the share mode to EFileShareExclusive; sl@0: c) the file has been opened for writing in EFileShareExclusive mode, and an sl@0: attempt is made to change the access mode to EFileShareReadersOnly. sl@0: sl@0: @capability Dependent If the path starts with /Resource then capability DiskAdmin is required sl@0: sl@0: */ sl@0: { sl@0: TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileChangeMode, MODULEUID, Session().Handle(), SubSessionHandle(), aNewMode); sl@0: sl@0: if (aNewMode!=EFileShareExclusive && aNewMode!=EFileShareReadersOnly) sl@0: return(KErrArgument); sl@0: TInt r = SendReceive(EFsFileChangeMode,TIpcArgs(aNewMode)); sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileChangeModeReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::Rename(const TDesC& aNewName) sl@0: /** sl@0: Renames a file. sl@0: sl@0: If aNewName specifies a different directory to the one in which sl@0: the file is currently located, then the file is moved. sl@0: sl@0: No other process may have access to the file, that is, the file must have sl@0: been opened in EFileShareExclusive share mode, or an error is returned. The sl@0: file must have been opened for writing (using EFileWrite access mode). An sl@0: error is returned if a file with the new filename already exists in the target sl@0: directory. sl@0: sl@0: The file or directory may not be moved to another device by this means, either sl@0: explicitly (by another drive specified in the name) or implicitly (because sl@0: the directory has been mapped to another device with RFs::SetSubst()). sl@0: sl@0: Note that the function builds up the new file specification by using all sl@0: of the path components specified sl@0: in aNewName (directory path, filename and extension), sl@0: then adding any missing components from the current file specification, and sl@0: finally adding any missing components from the session path. A consequence sl@0: of this is that you cannot rename a file to remove its extension. An alternative sl@0: to this function is RFs::Rename() which renames the file using the new name sl@0: as provided. sl@0: sl@0: @param aNewName The new file name and/or directory path. No part may contain sl@0: wildcard characters or an error is returned. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: sl@0: @capability Dependent If aNewName starts with /Sys then capability Tcb is required sl@0: @capability Dependent If aNewName starts with /Resource then capability Tcb is required sl@0: @capability Dependent If aNewName starts with /Private and does not match this process' sl@0: SID then AllFiles capability is required. sl@0: sl@0: */ sl@0: { sl@0: TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileRename, MODULEUID, Session().Handle(), SubSessionHandle(), aNewName); sl@0: sl@0: TInt r = SendReceive(EFsFileRename,TIpcArgs(&aNewName)); sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileRenameReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EFSRV_EXPORT_C TInt RFile::Drive(TInt &aDriveNumber, TDriveInfo &aDriveInfo) const sl@0: /** sl@0: Gets information about the drive on which this file resides. sl@0: sl@0: @param aDriveNumber On return, the drive number. sl@0: sl@0: @param aDriveInfo On return, contains information describing the drive sl@0: and the medium mounted on it. The value of TDriveInfo::iType sl@0: shows whether the drive contains media. sl@0: sl@0: @return KErrNone, if successful, otherwise one of the other sl@0: system-wide error codes sl@0: sl@0: @see RFs::Drive sl@0: */ sl@0: { sl@0: TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileDrive, MODULEUID, Session().Handle(), SubSessionHandle()); sl@0: sl@0: TPckg pki(aDriveNumber); sl@0: TPckg pkdi(aDriveInfo); sl@0: TInt r = SendReceive(EFsFileDrive,TIpcArgs(&pki,&pkdi)); sl@0: sl@0: TRACERET4(UTF::EBorder, UTraceModuleEfsrv::EFileDriveReturn, MODULEUID, r, aDriveInfo.iDriveAtt, aDriveInfo.iMediaAtt, aDriveInfo.iType); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: TInt RFile::Clamp(RFileClamp& aHandle) sl@0: /** sl@0: Instructs the File Server that the file is not to be modified on storage media. sl@0: sl@0: @param aHandle On return, a handle to the file. sl@0: sl@0: @return KErrNone, if successful, otherwise one of the other sl@0: system-wide error codes sl@0: sl@0: @see RFs::Unclamp sl@0: */ sl@0: { sl@0: TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileClamp, MODULEUID, Session().Handle(), SubSessionHandle()); sl@0: sl@0: TPckg pkHandle(aHandle); sl@0: TInt r = SendReceive(EFsFileClamp,TIpcArgs(& pkHandle)); sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileClampReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: /** sl@0: Fetches the Block Map of a file. Each file in the file system will consist of sl@0: a number of groups of blocks. Each group represents a number of contiguous blocks. sl@0: Such a group is represented by the TBlockMapEntry class. The full Block Map representing sl@0: the file may be determined by repeatedly calling RFile::BlockMap until KErrCompletion is sl@0: returned. sl@0: sl@0: Note: sl@0: sl@0: 1. If the Block Map for the whole file is not required, then a start and end position sl@0: for a section of the file can be specified. Both of these parameters specify offsets sl@0: from the start of the file in bytes. sl@0: sl@0: @param aInfo A structure describing a group of block maps. sl@0: sl@0: @param aStartPos A start position for a desired section of the file. sl@0: sl@0: @param aEndPos An end position for a desired section of the file. If not passed, then the end of the sl@0: file is assumed. sl@0: sl@0: @return KErrNone until the end of the file or the file section is successfully reached; sl@0: KErrCompletion if the end of the file is reached; sl@0: KErrNotSupported if the file system does not support Block Mapping or the media is either removable or not pageable. sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile::BlockMap(SBlockMapInfo& aInfo, TInt64& aStartPos, TInt64 aEndPos, TInt aBlockMapUsage) const sl@0: { sl@0: TRACE7(UTF::EBorder, UTraceModuleEfsrv::EFileBlockMap, MODULEUID, sl@0: Session().Handle(), SubSessionHandle(), I64LOW(aStartPos), I64HIGH(aEndPos), I64LOW(aEndPos), I64HIGH(aEndPos), aBlockMapUsage); sl@0: sl@0: SBlockMapArgs args; sl@0: args.iStartPos = aStartPos; sl@0: args.iEndPos = aEndPos; sl@0: TPckg pkInfo(aInfo); sl@0: TPckg pkArgs(args); sl@0: TInt r = SendReceive(EFsBlockMap, TIpcArgs(&pkInfo, &pkArgs, aBlockMapUsage)); sl@0: if(r==KErrNone) sl@0: aStartPos = args.iStartPos; sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileBlockMapReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API sl@0: /** sl@0: Opens an existing file for reading or writing. sl@0: sl@0: If the file does not already exist, an error is returned. sl@0: sl@0: This is equivalent to calling RFile::Open except that this function sl@0: can open files of size greater than 2GB - 1 also. sl@0: sl@0: Notes: sl@0: sl@0: 1. To close the file, use Close() sl@0: sl@0: 2. Attempting to open a file with the read-only attribute using the EFileWrite sl@0: access mode results in an error. sl@0: sl@0: 3. After a file has been opened, the current write position is set to the start sl@0: of the file. sl@0: If necessary, use RFile64::Seek() to move to a different position within sl@0: the file. sl@0: sl@0: 4. It enables big file support to handle files whose size are greater then 2GB-1 sl@0: sl@0: @param aFs The file server session. sl@0: @param aName The name of the file. Any path components (i.e. drive letter sl@0: or directory), which are not specified, are taken from sl@0: the session path. sl@0: @param aMode The mode in which the file is opened. See TFileMode. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide sl@0: error codes. sl@0: sl@0: @see TFileMode sl@0: @see RFile::Open() sl@0: sl@0: @capability Dependent If the path for aName is /Sys and aMode is neither sl@0: EFileShareReadersOnly nor EFileRead then Tcb capability is required. sl@0: @capability Dependent If the path for aName is /Sys and aMode is either sl@0: EFileShareReadersOnly or EFileRead then Allfiles capability is required. sl@0: @capability Dependent If the path for aName begins with /Private and does not match this process' sl@0: SID then AllFiles capability is required. sl@0: @capability Dependent If the path for aName begins with /Resource and aMode is neither sl@0: EFileShareReadersOrWriters|EFileRead nor EFileShareReadersOnly sl@0: nor EFileRead then Tcb capability is required. sl@0: sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile64::Open(RFs& aFs,const TDesC& aName,TUint aFileMode) sl@0: { sl@0: TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileOpen, MODULEUID, aFs.Handle(), aFileMode, aName); sl@0: sl@0: TInt r = CreateSubSession(aFs,EFsFileOpen,TIpcArgs(&aName,aFileMode|EFileBigFile)); sl@0: sl@0: TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileOpenReturn, MODULEUID, r, SubSessionHandle()); sl@0: return r; sl@0: } sl@0: sl@0: /** sl@0: Creates and opens a new file for writing. sl@0: sl@0: If the file already exists, an error is returned. sl@0: sl@0: If the resulting path does not exist, then the operation cannot proceed and sl@0: the function returns an error code. sl@0: sl@0: This is equivalent to calling RFile::Create except that the file created with sl@0: this function can grow beyond 2GB - 1 also. sl@0: sl@0: Notes: sl@0: sl@0: 1. To close the file, use Close() sl@0: sl@0: 2. It automatically sets the file's archive attribute. sl@0: sl@0: 3. It enables big file support to handle files whose size are greater then 2GB-1 sl@0: sl@0: sl@0: @param aFs The file server session. sl@0: @param aName The name of the file. Any path components (i.e. drive letter sl@0: or directory), which are not specified, are taken from sl@0: the session path. sl@0: @param aMode The mode in which the file is opened. The access mode is sl@0: automatically set to EFileWrite. See TFileMode. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide sl@0: error codes. sl@0: sl@0: @see RFile::Create() sl@0: @see TFileMode sl@0: sl@0: @capability Dependent If the path in aName starts with /Sys then capability Tcb is required sl@0: @capability Dependent If the path in aName starts with /Resource then capability Tcb is required sl@0: @capability Dependent If the path in aName starts with /Private and does not match this process' sl@0: SID then AllFiles capability is required. sl@0: sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile64::Create(RFs& aFs,const TDesC& aName,TUint aFileMode) sl@0: { sl@0: TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileCreate, MODULEUID, aFs.Handle(), aFileMode, aName); sl@0: sl@0: TInt r = CreateSubSession(aFs,EFsFileCreate,TIpcArgs(&aName,aFileMode|EFileBigFile)); sl@0: sl@0: TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileCreateReturn, MODULEUID, r, SubSessionHandle()); sl@0: return r; sl@0: } sl@0: sl@0: /** sl@0: Opens a file for writing, replacing the content of any existing file of the sl@0: same name if it exists, or creating a new file if it does not exist. sl@0: sl@0: This is equivalent to calling RFile::Replace except that the file created or replaced sl@0: with this function can grow beyond 2GB - 1 also. sl@0: sl@0: sl@0: If the resulting path exists, then: sl@0: sl@0: - the length of an existing file with the same filename is re-set to zero sl@0: sl@0: - a new file is created, if no existing file with the same filename can be found. sl@0: sl@0: If the resulting path does not exist, then the operation cannot proceed and sl@0: the function returns an error code. sl@0: sl@0: Notes: sl@0: sl@0: - To close the file, use Close(), defined in the base class RFsBase. sl@0: sl@0: - It automatically sets the file's archive attribute. sl@0: sl@0: - It enables big file support to handle files whose size are greater then 2GB-1 sl@0: sl@0: sl@0: @param aFs The file server session. sl@0: @param aName The name of the file. Any path components (i.e. drive letter sl@0: or directory), which are not specified, are taken from sl@0: the session path. sl@0: @param aMode The mode in which the file is opened. The access mode is sl@0: automatically set to EFileWrite. See TFileMode. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide sl@0: error codes. sl@0: sl@0: @see TFileMode sl@0: @see RFile::Replace() sl@0: sl@0: @capability Dependent If the path in aName starts with /Sys then capability Tcb is required sl@0: @capability Dependent If the path in aName starts with /Resource then capability Tcb is required sl@0: @capability Dependent If the path in aName starts with /Private and does not match this process' sl@0: SID then AllFiles capability is required. sl@0: sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile64::Replace(RFs& aFs,const TDesC& aName,TUint aFileMode) sl@0: { sl@0: TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileReplace, MODULEUID, aFs.Handle(), aFileMode, aName); sl@0: sl@0: TInt r = CreateSubSession(aFs,EFsFileReplace,TIpcArgs(&aName,aFileMode|EFileBigFile)); sl@0: sl@0: TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileReplaceReturn, MODULEUID, r, SubSessionHandle()); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Creates and opens a temporary file with a unique name for writing and reading. sl@0: This is equivalent to calling RFile::Temp except that the file created sl@0: with this function can grow beyond 2GB - 1 also. sl@0: sl@0: sl@0: Notes: sl@0: sl@0: 1. To close the file, use Close() sl@0: 2. It enables big file support to handle files whose size are greater then 2GB-1 sl@0: sl@0: @param aFs The file server session. sl@0: @param aPath The directory in which the file is created. sl@0: @param aName On return, contains the full path and file name of the file. sl@0: The filename is guaranteed to be unique within the directory sl@0: specified by aPath. sl@0: @param aMode The mode in which the file is opened. The access mode is sl@0: automatically set to EFileWrite. See TFileMode. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide sl@0: error codes. sl@0: sl@0: @see TFileMode sl@0: @see RFile::Temp() sl@0: sl@0: @capability Dependent If aPath starts with /Sys then capability Tcb is required sl@0: @capability Dependent If aPath starts with /Resource then capability Tcb is required sl@0: @capability Dependent If aPath starts with /Private and does not match this process' sl@0: SID then AllFiles capability is required. sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile64::Temp(RFs& aFs,const TDesC& aPath,TFileName& aName,TUint aFileMode) sl@0: { sl@0: TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileTemp, MODULEUID, aFs.Handle(), aPath, aFileMode); sl@0: TInt r = CreateSubSession(aFs,EFsFileTemp,TIpcArgs(&aPath,aFileMode|EFileBigFile,&aName)); sl@0: TRACERETMULT3(UTF::EBorder, UTraceModuleEfsrv::EFileTempReturn, MODULEUID, r, SubSessionHandle(), aName); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Allows a server to adopt an already open file from a client. sl@0: The client's RFs and RFile or RFile64 handles are contained in message slots within aMsg. sl@0: sl@0: Assumes that the client's RFs and RFile or RFile64 handles have been sent to the server sl@0: using TransferToServer(). sl@0: sl@0: This is equivalent to calling RFile::AdoptFromClient sl@0: except that the file adopted can be enlarged to sizes beyond 2GB-1. sl@0: sl@0: Note: sl@0: If a RFile handle is received from the client then enlarging the file beyond sl@0: 2GB-1 might result in inconsistent behaviour by the client, since it(client) would sl@0: not be able to handle files of size greater than 2GB-1. sl@0: sl@0: If a RFile64 handle is received from the client then enlarging the file beyond sl@0: 2GB-1 should not cause any issues since the client would be sl@0: capable of handling files of size greater than 2GB-1. sl@0: sl@0: This RFile or RFile64 will own it's RFs session so that when the sub-session (RFile or RFile64) sl@0: is closed so will the RFs session. sl@0: sl@0: @param aMsg The message received from the client sl@0: @param aFsHandleIndex The index that identifies the message slot sl@0: of a file server session (RFs) handle sl@0: @param aFileHandleIndex The index that identifies the message slot sl@0: of the sub-session (RFile or RFile64) handle of the already opened file sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide sl@0: error codes. sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile64::AdoptFromClient(const RMessage2& aMsg, TInt aFsHandleIndex, TInt aFileHandleIndex) sl@0: { sl@0: TInt fileHandle = NULL; sl@0: sl@0: TInt r = KErrNone; sl@0: if (aFileHandleIndex == 0) sl@0: fileHandle = aMsg.Int0(); sl@0: else if (aFileHandleIndex == 1) sl@0: fileHandle = aMsg.Int1(); sl@0: else if (aFileHandleIndex == 2) sl@0: fileHandle = aMsg.Int2(); sl@0: else if (aFileHandleIndex == 3) sl@0: fileHandle = aMsg.Int3(); sl@0: else sl@0: r = KErrArgument; sl@0: sl@0: #ifdef SYMBIAN_FTRACE_ENABLE sl@0: TInt handle = NULL; sl@0: if (aFsHandleIndex == 0) sl@0: handle = aMsg.Int0(); sl@0: else if (aFsHandleIndex == 1) sl@0: handle = aMsg.Int1(); sl@0: else if (aFsHandleIndex == 2) sl@0: handle = aMsg.Int2(); sl@0: else if (aFsHandleIndex == 3) sl@0: handle = aMsg.Int3(); sl@0: TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClient, MODULEUID, handle, fileHandle, aFsHandleIndex, aFileHandleIndex); sl@0: #endif sl@0: sl@0: if (r != KErrNone) sl@0: { sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClientReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: // Duplicates the file server (RFs) session handle identified by an sl@0: // existing handle contained in the message slot at index aFsHandleIndex sl@0: RFs fs; sl@0: r = fs.Open(aMsg, aFsHandleIndex, KFileServerPolicy); sl@0: if (r != KErrNone) sl@0: { sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClientReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: //return CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(fileHandle)); sl@0: // Slot 1: Indicate Large File Supportis required. sl@0: r = CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(fileHandle, KFileAdopt64)); sl@0: sl@0: TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromClientReturn, MODULEUID, r, Session().Handle(), SubSessionHandle()); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Allows a client to adopt an already open file from a server. sl@0: sl@0: Assumes that the server's RFs and RFile or RFile64 handles have been sent to the sl@0: client using TransferToClient(). sl@0: sl@0: This is equivalent to calling RFile::AdoptFromServer sl@0: except that the file adopted can be enlarged to sizes beyond 2GB-1. sl@0: sl@0: Note: sl@0: If a RFile handle is received from the server then enlarging the file beyond sl@0: 2GB-1 might result in inconsistent behaviour by the server, since it(server) would sl@0: not be able to handle files of size greater than 2GB-1. sl@0: sl@0: If a RFile64 handle is received from the server then enlarging the file beyond sl@0: 2GB-1 should not cause any issues since the server would be capable of sl@0: handling files of size greater than 2GB-1. sl@0: sl@0: This RFile or RFile64 will own it's RFs session so that when the sub-session (RFile or RFile64) sl@0: is closed so will the RFs session. sl@0: sl@0: @param aFsHandle The file server session (RFs) handle sl@0: @param aFileHandle The file (RFile or RFile64) handle of the already opened file sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide sl@0: error codes. sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile64::AdoptFromServer(TInt aFsHandle, TInt aFileHandle) sl@0: { sl@0: TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromServer, MODULEUID, aFsHandle, aFileHandle); sl@0: sl@0: RFs fs; sl@0: TInt r = fs.SetReturnedHandle(aFsHandle, KFileServerPolicy); sl@0: if (r != KErrNone) sl@0: { sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromServerReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: //return(CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(aFileHandle))); sl@0: // Slot 1: Indicate Large File Supportis required. sl@0: r = CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(aFileHandle, KFileAdopt64)); sl@0: sl@0: TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromServerReturn, MODULEUID, r, Session().Handle(), SubSessionHandle()); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Allows a server to adopt an already open file from a client process. sl@0: The client's file-server (RFs) and file (RFile or RFile64) handles are contained in sl@0: this process's environment data slots. sl@0: sl@0: Assumes that the client's RFs and RFile or RFile64 handles have been sent to the server process sl@0: using TransferToProcess(). sl@0: sl@0: This is equivalent to calling RFile::AdoptFromCreator sl@0: except that the file adopted can be enlarged to sizes beyond 2GB-1. sl@0: sl@0: Note: sl@0: If a RFile handle is received from the client then enlarging the file beyond sl@0: 2GB-1 might result in inconsistent behaviour by the client, since it(client) would sl@0: not be able to handle files of size greater than 2GB-1. sl@0: sl@0: If a RFile64 handle is received from the client then enlarging the file beyond sl@0: 2GB-1 should not cause any issues since the client would be capable of sl@0: handling files of size greater than 2GB-1. sl@0: sl@0: This RFile or RFile64 will own it's RFs session so that when the sub-session (RFile or RFile64) sl@0: is closed so will the RFs session. sl@0: sl@0: @param aFsHandleIndex An index that identifies the slot in the process sl@0: environment data that contains the file server session (RFs) handle sl@0: @param aFileHandleIndex An index that identifies the slot in the process sl@0: environment data that contains the sub-session (RFile or RFile64) handle sl@0: of the already opened file sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide sl@0: error codes. sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile64::AdoptFromCreator(TInt aFsHandleIndex, TInt aFileHandleIndex) sl@0: { sl@0: TInt fileHandle; sl@0: TInt r = User::GetTIntParameter(aFileHandleIndex, fileHandle); sl@0: sl@0: TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreator, MODULEUID, fileHandle, aFsHandleIndex, aFileHandleIndex); sl@0: sl@0: if (r != KErrNone) sl@0: { sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreatorReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: // Duplicates the file server (RFs) session handle identified by an sl@0: // existing handle contained in the environment slot at index aFsHandleIndex sl@0: RFs fs; sl@0: r = fs.Open(aFsHandleIndex, KFileServerPolicy); sl@0: if (r != KErrNone) sl@0: { sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreatorReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: //return(CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(fileHandle))); sl@0: // Slot 1: Indicate Large File Supportis required. sl@0: r = CreateAutoCloseSubSession(fs, EFsFileAdopt, TIpcArgs(fileHandle, KFileAdopt64)); sl@0: sl@0: TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileAdoptFromCreatorReturn, MODULEUID, r, Session().Handle(), SubSessionHandle()); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Reads from the file at the specified offset within the file sl@0: sl@0: This is a synchronous function. sl@0: sl@0: This is equivalent to calling RFile::Read(TInt, TDes8&) except that this function sl@0: accepts TInt64, instead of TInt, as its first parameter. This allows to specify sl@0: the read position beyond 2GB-1. sl@0: sl@0: @see RFile::Read(TInt aPos, TDes8& aDes) sl@0: sl@0: Note that when an attempt is made to read beyond the end of the file, sl@0: no error is returned. sl@0: The descriptor's length is set to the number of bytes read into it. sl@0: Therefore, when reading through a file, the end of file has been reached sl@0: when the descriptor length, as returned by TDesC8::Length(), is zero. sl@0: sl@0: @param aPos Position of first byte to be read. This is an offset from sl@0: the start of the file. If no position is specified, reading sl@0: begins at the current file position. sl@0: If aPos is beyond the end of the file, the function returns sl@0: a zero length descriptor. sl@0: sl@0: @param aDes The descriptor into which binary data is read. Any existing content sl@0: is overwritten. On return, its length is set to the number of sl@0: bytes read. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: sl@0: @panic FSCLIENT 19 if aPos is negative. sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile64::Read(TInt64 aPos, TDes8& aDes) const sl@0: { sl@0: TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileRead3, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aDes.MaxLength()); sl@0: sl@0: __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); sl@0: sl@0: TInt r; sl@0: if (!(I64HIGH(aPos+1))) sl@0: { sl@0: r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),I64LOW(aPos))); sl@0: } sl@0: else sl@0: { sl@0: TPckgC pkPos(aPos); sl@0: r = SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.MaxLength(),&pkPos)); sl@0: } sl@0: sl@0: TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead3Return, MODULEUID, r, aDes.Length()); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Reads from the file at the specified offset within the file. sl@0: sl@0: This is an asynchronous function. sl@0: sl@0: This is equivalent to calling RFile::Read(TInt, TDes8&, TRequestStatus&) except sl@0: that this function accepts TInt64, instead of TInt, as its first parameter. sl@0: This allows to specify the read position beyond 2GB-1. sl@0: sl@0: @see RFile::Read(TInt aPos, TDes8& aDes, TRequestStatus& aStatus) sl@0: sl@0: Note that when an attempt is made to read beyond the end of the file, sl@0: no error is returned. sl@0: The descriptor's length is set to the number of bytes read into it. sl@0: Therefore, when reading through a file, the end of file has been reached sl@0: when the descriptor length, as returned by TDesC8::Length(), is zero. sl@0: sl@0: @param aPos Position of first byte to be read. This is an offset from sl@0: the start of the file. If no position is specified, sl@0: reading begins at the current file position. sl@0: If aPos is beyond the end of the file, the function returns sl@0: a zero length descriptor. sl@0: sl@0: @param aDes The descriptor into which binary data is read. Any existing sl@0: content is overwritten. On return, its length is set to sl@0: the number of bytes read. sl@0: NB: this function is asynchronous and the request that it sl@0: represents may not complete until some time after the call sl@0: to the function has returned. It is important, therefore, that sl@0: this descriptor remain valid, or remain in scope, until you have sl@0: been notified that the request is complete. sl@0: sl@0: @param aStatus The request status. On completion, contains an error code of KErrNone sl@0: if successful, otherwise one of the other system-wide error codes. sl@0: sl@0: @panic FSCLIENT 19 if aPos is negative. sl@0: */ sl@0: EFSRV_EXPORT_C void RFile64::Read(TInt64 aPos, TDes8& aDes, TRequestStatus& aStatus) const sl@0: { sl@0: TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileRead4, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aDes.MaxLength(), &aStatus); sl@0: sl@0: __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); sl@0: if (!(I64HIGH(aPos+1))) sl@0: { sl@0: RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),I64LOW(aPos)),aStatus); sl@0: } sl@0: else sl@0: { sl@0: TPckgC pkPos(aPos); sl@0: RSubSessionBase::SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.MaxLength(),&pkPos),aStatus); sl@0: } sl@0: sl@0: TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead4Return, MODULEUID); sl@0: } sl@0: sl@0: sl@0: /** sl@0: Reads the specified number of bytes of binary data from the file at a specified sl@0: offset within the file. sl@0: sl@0: This is a synchronous function. sl@0: sl@0: This is equivalent to calling RFile::Read(TInt, TDes8&, TInt) except sl@0: that this function accepts TInt64, instead of TInt, as its first parameter. sl@0: This allows to specify the read position beyond 2GB-1. sl@0: sl@0: @see RFile::Read(TInt aPos, TDes8& aDes, TInt aLength) sl@0: sl@0: Note that when an attempt is made to read beyond the end of the file, sl@0: no error is returned. sl@0: The descriptor's length is set to the number of bytes read into it. sl@0: Therefore, when reading through a file, the end of file has been reached sl@0: when the descriptor length, as returned by TDesC8::Length(), is zero. sl@0: Assuming aLength is less than the maximum length of the descriptor, the only sl@0: circumstances in which Read() can return fewer bytes than requested is when sl@0: the end of file is reached or if an error has occurred. sl@0: sl@0: @param aPos Position of first byte to be read. This is an offset from sl@0: the start of the file. If no position is specified, sl@0: reading begins at the current file position. sl@0: If aPos is beyond the end of the file, the function returns sl@0: a zero length descriptor. sl@0: sl@0: @param aDes The descriptor into which binary data is read. Any existing sl@0: contents are overwritten. On return, its length is set to sl@0: the number of bytes read. sl@0: @param aLength The number of bytes to read from the file into the descriptor. sl@0: If an attempt is made to read more bytes than the descriptor's sl@0: maximum length, then the function updates aStatus parameter with KErrOverflow. sl@0: It must not be negative otherwise the function updates aStatus with KErrArgument. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide sl@0: error codes. sl@0: sl@0: @panic FSCLIENT 19 if aPos is negative. sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile64::Read(TInt64 aPos, TDes8& aDes, TInt aLength) const sl@0: { sl@0: TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileRead3, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aLength); sl@0: sl@0: __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); sl@0: if (aLength==0) sl@0: { sl@0: aDes.Zero(); sl@0: return(KErrNone); sl@0: } sl@0: else if(aLength>aDes.MaxLength()) sl@0: { sl@0: return(KErrOverflow); sl@0: } sl@0: sl@0: TInt r; sl@0: if (!(I64HIGH(aPos+1))) sl@0: { sl@0: r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,I64LOW(aPos))); sl@0: } sl@0: else sl@0: { sl@0: TPckgC pkPos(aPos); sl@0: r = SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos)); sl@0: } sl@0: sl@0: TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead3Return, MODULEUID, r, aDes.Length()); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Reads the specified number of bytes of binary data from the file at a specified sl@0: offset within the file. sl@0: sl@0: This is an asynchronous function. sl@0: sl@0: This is equivalent to calling RFile::Read(TInt, TDes8&, TInt, TRequestStatus&) except sl@0: that this function accepts TInt64, instead of TInt, as its first parameter. sl@0: This allows to specify the read position beyond 2GB-1. sl@0: sl@0: @see RFile::Read(TInt aPos, TDes8& aDes,TInt aLength,TRequestStatus& aStatus) sl@0: sl@0: Note that when an attempt is made to read beyond the end of the file, sl@0: no error is returned. sl@0: The descriptor's length is set to the number of bytes read into it. sl@0: Therefore, when reading through a file, the end of file has been reached sl@0: when the descriptor length, as returned by TDesC8::Length(), is zero. sl@0: Assuming aLength is less than the maximum length of the descriptor, the only sl@0: circumstances in which Read() can return fewer bytes than requested is when sl@0: the end of file is reached or if an error has occurred. sl@0: sl@0: @param aPos Position of first byte to be read. This is an offset from sl@0: the start of the file. If no position is specified, sl@0: reading begins at the current file position. sl@0: If aPos is beyond the end of the file, the function returns sl@0: a zero length descriptor. sl@0: sl@0: @param aDes The descriptor into which binary data is read. Any existing sl@0: contents are overwritten. On return, its length is set to sl@0: the number of bytes read. sl@0: NB: this function is asynchronous and the request that it sl@0: represents may not complete until some time after the call sl@0: to the function has returned. It is important, therefore, that sl@0: this descriptor remain valid, or remain in scope, until you have sl@0: been notified that the request is complete. sl@0: sl@0: @param aLength The number of bytes to read from the file into the descriptor. sl@0: If an attempt is made to read more bytes than the descriptor's sl@0: maximum length, then the function returns KErrOverflow. sl@0: It must not be negative otherwise the function returns KErrArgument. sl@0: sl@0: @param aStatus Request status. On completion contains KErrNone if successful, sl@0: otherwise one of the other system-wide error codes. sl@0: sl@0: @panic FSCLIENT 19 if aPos is negative. sl@0: */ sl@0: EFSRV_EXPORT_C void RFile64::Read(TInt64 aPos, TDes8& aDes, TInt aLength,TRequestStatus& aStatus) const sl@0: { sl@0: TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileRead4, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aLength, &aStatus); sl@0: sl@0: __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); sl@0: if (aLength==0) sl@0: { sl@0: aDes.Zero(); sl@0: TRequestStatus* req=(&aStatus); sl@0: User::RequestComplete(req,KErrNone); sl@0: return; sl@0: } sl@0: else if(aLength>aDes.MaxLength()) sl@0: { sl@0: TRequestStatus* req=(&aStatus); sl@0: User::RequestComplete(req,KErrOverflow); sl@0: return; sl@0: } sl@0: sl@0: if (!(I64HIGH(aPos+1))) sl@0: { sl@0: RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,I64LOW(aPos)),aStatus); sl@0: } sl@0: else sl@0: { sl@0: TPckgC pkPos(aPos); sl@0: RSubSessionBase::SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos),aStatus); sl@0: } sl@0: sl@0: TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead4Return, MODULEUID); sl@0: } sl@0: sl@0: sl@0: /** sl@0: Writes to the file at the specified offset within the file sl@0: sl@0: This is a synchronous function. sl@0: sl@0: This is equivalent to calling RFile::Write(TInt, TDes8&) except sl@0: that this function accepts TInt64, instead of TInt, as its first parameter. sl@0: This allows to specify the write position beyond 2GB-1. sl@0: sl@0: @see RFile::Write(TInt aPos, TDes8& aDes) sl@0: sl@0: sl@0: @param aPos The offset from the start of the file at which the first sl@0: byte is written. sl@0: If a position beyond the end of the file is specified, then sl@0: the write operation begins at the end of the file. sl@0: If the position has been locked, then the write fails. sl@0: sl@0: @param aDes The descriptor from which binary data is written. The function writes sl@0: the entire contents of aDes to the file. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: sl@0: @panic FSCLIENT 19 if aPos is negative. sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile64::Write(TInt64 aPos, const TDesC8& aDes) sl@0: { sl@0: TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileWrite3, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aDes.Length()); sl@0: sl@0: __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); sl@0: sl@0: TInt r; sl@0: if (!(I64HIGH(aPos+1))) sl@0: { sl@0: r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),I64LOW(aPos))); sl@0: } sl@0: else sl@0: { sl@0: TPckgC pkPos(aPos); sl@0: r = SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.Length(),&pkPos)); sl@0: } sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite3Return, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Writes to the file at the specified offset within the file sl@0: sl@0: This is an asynchronous function. sl@0: sl@0: This is equivalent to calling RFile::Write(TInt, TDes8&, TRequestStatus&) except sl@0: that this function accepts TInt64, instead of TInt, as its first parameter. sl@0: This allows to specify the write position beyond 2GB-1. sl@0: sl@0: @see RFile::Write(TInt aPos, TDes8& aDes, TRequestStatus& aStatus) sl@0: sl@0: sl@0: @param aPos The offset from the start of the file at which the first sl@0: byte is written. sl@0: If a position beyond the end of the file is specified, then sl@0: the write operation begins at the end of the file. sl@0: If the position has been locked, then the write fails. sl@0: sl@0: @param aDes The descriptor from which binary data is written. The function sl@0: writes the entire contents of aDes to the file. sl@0: NB: this function is asynchronous and the request that it sl@0: represents may not complete until some time after the call sl@0: to the function has returned. It is important, therefore, that sl@0: this descriptor remain valid, or remain in scope, until you have sl@0: been notified that the request is complete. sl@0: sl@0: @param aStatus Request status. On completion contains KErrNone if successful, sl@0: otherwise one of the other system-wide error codes. sl@0: sl@0: @panic FSCLIENT 19 if aPos is negative. sl@0: */ sl@0: EFSRV_EXPORT_C void RFile64::Write(TInt64 aPos, const TDesC8& aDes,TRequestStatus& aStatus) sl@0: { sl@0: TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileWrite4, MODULEUID, Session().Handle(), SubSessionHandle(), aDes.Length(), &aStatus); sl@0: sl@0: __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); sl@0: sl@0: if (!(I64HIGH(aPos+1))) sl@0: { sl@0: RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),I64LOW(aPos)),aStatus); sl@0: } sl@0: else sl@0: { sl@0: TPckgC pkPos(aPos); sl@0: RSubSessionBase::SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.Length(),&pkPos),aStatus); sl@0: } sl@0: sl@0: TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite4Return, MODULEUID); sl@0: } sl@0: sl@0: sl@0: /** sl@0: Writes the specified number of bytes to the file at the specified offset within the file. sl@0: sl@0: This is a synchronous function. sl@0: sl@0: This is equivalent to calling RFile::Write(TInt, TDes8&, TInt) except sl@0: that this function accepts TInt64, instead of TInt, as its first parameter. sl@0: This allows to specify the write position beyond 2GB-1. sl@0: sl@0: @see RFile::Write(TInt aPos, TDes8& aDes, TInt aLength) sl@0: sl@0: @param aPos The offset from the start of the file at which the first sl@0: byte is written. sl@0: If a position beyond the end of the file is specified, then sl@0: the write operation begins at the end of the file. sl@0: If the position has been locked, then the write fails. sl@0: sl@0: @param aDes The descriptor from which binary data is written. sl@0: @param aLength The number of bytes to be written from aDes . sl@0: It must not be negative. sl@0: sl@0: @return KErrNone if successful; KErrArgument if aLength is negative; sl@0: otherwise one of the other system-wide error codes. sl@0: sl@0: @panic FSCLIENT 19 if aPos is negative. sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile64::Write(TInt64 aPos, const TDesC8& aDes,TInt aLength) sl@0: { sl@0: TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1, MODULEUID, Session().Handle(), SubSessionHandle(), aLength); sl@0: sl@0: __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); sl@0: sl@0: TInt r; sl@0: if (!(I64HIGH(aPos+1))) sl@0: { sl@0: r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,I64LOW(aPos))); sl@0: } sl@0: else sl@0: { sl@0: TPckgC pkPos(aPos); sl@0: r = SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos)); sl@0: } sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1Return, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Writes the specified number of bytes to the file at the specified offset within the file. sl@0: sl@0: This is an asynchronous function. sl@0: sl@0: This is equivalent to calling RFile::Write(TInt, TDes8&, TInt, TRequestStatus&) except sl@0: that this function accepts TInt64, instead of TInt, as its first parameter. sl@0: This allows to specify the write position beyond 2GB-1. sl@0: sl@0: @see RFile::Write(TInt aPos, TDes8& aDes, TInt aLength, TRequestStatus &aStatus) sl@0: sl@0: @param aPos The offset from the start of the file at which the first sl@0: byte is written. sl@0: If a position beyond the end of the file is specified, then sl@0: the write operation begins at the end of the file. sl@0: If the position has been locked, then the write fails. sl@0: sl@0: @param aDes The descriptor from which binary data is written. sl@0: NB: this function is asynchronous and the request that it sl@0: represents may not complete until some time after the call sl@0: to the function has returned. It is important, therefore, that sl@0: this descriptor remain valid, or remain in scope, until you have sl@0: been notified that the request is complete. sl@0: sl@0: @param aLength The number of bytes to be written from aDes. sl@0: It must not be negative. sl@0: sl@0: @param aStatus Request status. On completion contains KErrNone if successful; sl@0: KErrArgument if aLength is negative; sl@0: otherwise one of the other system-wide error codes. sl@0: sl@0: @panic FSCLIENT 19 if aPos is negative. sl@0: */ sl@0: EFSRV_EXPORT_C void RFile64::Write(TInt64 aPos, const TDesC8& aDes,TInt aLength,TRequestStatus& aStatus) sl@0: { sl@0: TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aLength, &aStatus); sl@0: sl@0: __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); sl@0: sl@0: if (!(I64HIGH(aPos+1))) sl@0: { sl@0: RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,I64LOW(aPos)),aStatus); sl@0: } sl@0: else sl@0: { sl@0: TPckgC pkPos(aPos); sl@0: RSubSessionBase::SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos),aStatus); sl@0: } sl@0: sl@0: TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2Return, MODULEUID); sl@0: } sl@0: sl@0: sl@0: /** sl@0: Sets the the current file position. sl@0: sl@0: The function can also be used to get the current file sl@0: position without changing it. The file position is the position at which sl@0: reading and writing takes place. The start of the file is position zero. sl@0: sl@0: To retrieve the current file position without changing it, specify ESeekCurrent sl@0: for the seek mode, and zero for the offset. sl@0: sl@0: This is equivalent to calling RFile::Seek except that this function accepts sl@0: a reference to TInt64, instead of TInt, as its second parameter. sl@0: This allows to seek to positions beyond 2GB-1. sl@0: sl@0: @see RFile::Seek() sl@0: sl@0: If the seek mode is ESeekStart, then: sl@0: sl@0: 1. the function does not modify the aPos argument, sl@0: sl@0: 2. the function returns an error if the offset specified is negative. sl@0: sl@0: If the seek mode is ESeekAddress, an error is returned if: sl@0: sl@0: 1. the file is not in ROM, sl@0: sl@0: 2. the offset specified is greater than the size of the file. sl@0: sl@0: @param aMode Seek mode. Controls the destination of the seek operation. sl@0: @param aPos Offset from location specified in aMode. Can be negative. sl@0: On return contains the new file position. sl@0: If the seek mode is either ESeekCurrent or ESeekEnd and the offset sl@0: specifies a position before the start of the file sl@0: or beyond the end of the file, then on return, aPos is set to sl@0: the new file position (either the start or the end of the file). sl@0: If the seek mode is ESeekAddress, aPos returns the address of sl@0: the byte at the specified offset within the file. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile64::Seek(TSeek aMode, TInt64& aPos) const sl@0: { sl@0: TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileSeek, MODULEUID, Session().Handle(), SubSessionHandle(), aMode, aPos, 0); sl@0: sl@0: TPckgC pkOffset(aPos); sl@0: TPckg pkNewPos(aPos); sl@0: TInt r = SendReceive(EFsFileSeek|KIpcArgSlot0Desc|KIpcArgSlot2Desc,TIpcArgs(&pkOffset,aMode,&pkNewPos)); sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileSeekReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Gets the current file size. sl@0: sl@0: This is equivalent to calling RFile::Size except that this function accepts sl@0: a reference to TInt64, instead of TInt, as its first parameter. sl@0: This allows to query file sizes, which are greater than 2GB-1 sl@0: sl@0: @see RFile::Size() sl@0: sl@0: sl@0: @param aSize On return, the size of the file in bytes. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile64::Size(TInt64& aSize) const sl@0: { sl@0: TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFileSize2, MODULEUID, Session().Handle(), SubSessionHandle()); sl@0: sl@0: TPckg pkSize(aSize); sl@0: TInt r = SendReceive(EFsFileSize|KIpcArgSlot0Desc,TIpcArgs(&pkSize)); sl@0: sl@0: TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFileSize2Return, MODULEUID, r, I64LOW(aSize), I64HIGH(aSize)); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Sets the file size. sl@0: sl@0: If the size of the file is reduced, data may be lost from sl@0: the end of the file. sl@0: sl@0: This is equivalent to calling RFile::SetSize except that this function accepts sl@0: a reference to TInt64, instead of TInt, as its first parameter. sl@0: This allows to set file sizes to greater than 2GB-1 sl@0: sl@0: @see RFile::SetSize() sl@0: sl@0: sl@0: Note: sl@0: sl@0: 1. The current file position remains unchanged unless SetSize() reduces the size sl@0: of the file in such a way that the current file position is now beyond sl@0: the end of the file. In this case, the current file position is set to sl@0: the end of file. sl@0: sl@0: 2. If the file was not opened for writing, an error is returned. sl@0: sl@0: @param aSize The new size of the file, in bytes. This value must not be negative, otherwise the function raises a panic. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: sl@0: @panic FSCLIENT 20 If aSize is negative. sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile64::SetSize(TInt64 aSize) sl@0: { sl@0: TRACE4(UTF::EBorder, UTraceModuleEfsrv::EFileSetSize, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aSize), I64HIGH(aSize)); sl@0: sl@0: TPckgC pkSize(aSize); sl@0: TInt r = SendReceive(EFsFileSetSize|KIpcArgSlot0Desc, TIpcArgs(&pkSize)); sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileSetSizeReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Locks a region within the file as defined by a range of bytes. sl@0: sl@0: This ensures that those bytes are accessible sl@0: only through the RFile object which claims the lock. To re-allow access by sl@0: other programs to the locked region, it must either be unlocked or the file sl@0: closed. Locking can be used to synchronize operations on a file when more sl@0: than one program has access to the file in EFileShareAny mode. sl@0: sl@0: More than one distinct region of a file can be locked, but an error is returned sl@0: if more than one lock is placed on the same region. Different RFile objects sl@0: can lock different parts of the same file as long as the file is opened in sl@0: EFileShareAny mode. The locked region may extend beyond the end of a file; sl@0: this prevents the file from being extended by other programs. sl@0: sl@0: This is equivalent to calling RFile::Lock except that this function accepts sl@0: TInt64 parameters instead of TInt parameters. sl@0: This allows to to lock positions in file beyond 2GB-1. sl@0: sl@0: @see RFile::Lock() sl@0: sl@0: @param aPos Position in file from which to lock; this is the offset from sl@0: the beginning of the file. sl@0: @param aLength Number of bytes to lock. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: sl@0: @panic FSCLIENT 17 if aLength is not greater than zero, sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile64::Lock(TInt64 aPos, TInt64 aLength) const sl@0: { sl@0: TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileLock, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aLength); sl@0: sl@0: __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); sl@0: TPckgC pkPos(aPos); sl@0: TPckgC pkLength(aLength); sl@0: sl@0: TInt r; sl@0: sl@0: if(aPos <= KMaxTInt && aLength <= KMaxTInt) sl@0: r = SendReceive(EFsFileLock,TIpcArgs(I64LOW(aPos), I64LOW(aLength))); sl@0: else if(aPos <= KMaxTInt) sl@0: r = SendReceive(EFsFileLock|KIpcArgSlot1Desc,TIpcArgs(I64LOW(aPos), &pkLength)); sl@0: else if(aLength <= KMaxTInt) sl@0: r = SendReceive(EFsFileLock|KIpcArgSlot0Desc,TIpcArgs(&pkPos, I64LOW(aLength))); sl@0: else sl@0: r = SendReceive(EFsFileLock|KIpcArgSlot0Desc|KIpcArgSlot1Desc,TIpcArgs(&pkPos, &pkLength)); sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileLockReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Unlocks a region within the file as defined by a range of bytes. sl@0: sl@0: A lock can only be removed by the RFile object which claimed the lock. sl@0: sl@0: A portion of a locked region cannot be unlocked. The entire locked region sl@0: must be unlocked otherwise an error is returned. If any byte within sl@0: the specified range of bytes to unlock is not locked, an error is returned. sl@0: sl@0: This is equivalent to calling RFile::UnLock except that this function accepts sl@0: TInt64 parameters instead of TInt parameters. sl@0: This allows to to unlock positions in file beyond 2GB-1. sl@0: sl@0: @see RFile::UnLock() sl@0: sl@0: @param aPos Position in file from which to unlock; this is the offset from sl@0: the beginning of the file. sl@0: @param aLength Number of bytes to unlock. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: sl@0: @panic FSCLIENT 18 if aLength is not greater than zero, sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile64::UnLock(TInt64 aPos, TInt64 aLength) const sl@0: { sl@0: TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileUnLock, MODULEUID, Session().Handle(), SubSessionHandle(), I64LOW(aPos), I64HIGH(aPos), aLength); sl@0: sl@0: __ASSERT_ALWAYS(aPos>=0,Panic(EPosNegative)); sl@0: sl@0: TPckgC pkPos(aPos); sl@0: TPckgC pkLength(aLength); sl@0: sl@0: TInt r; sl@0: sl@0: if(aPos <= KMaxTInt && aLength <= KMaxTInt) sl@0: r = SendReceive(EFsFileUnLock,TIpcArgs(I64LOW(aPos), I64LOW(aLength))); sl@0: else if(aPos <= KMaxTInt) sl@0: r = SendReceive(EFsFileUnLock|KIpcArgSlot1Desc,TIpcArgs(I64LOW(aPos), &pkLength)); sl@0: else if(aLength <= KMaxTInt) sl@0: r = SendReceive(EFsFileUnLock|KIpcArgSlot0Desc,TIpcArgs(&pkPos, I64LOW(aLength))); sl@0: else sl@0: r = SendReceive(EFsFileUnLock|KIpcArgSlot0Desc|KIpcArgSlot1Desc,TIpcArgs(&pkPos, &pkLength)); sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileUnLockReturn, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Reads from the file at the specified offset within the file sl@0: sl@0: This is a synchronous function. sl@0: sl@0: This is equivalent to calling RFile::Read(TInt, TDes8&) or RFile64::Read(TInt64, TDes8&) sl@0: except that this function accepts TUint, instead of TInt or TInt64, as its first parameter. sl@0: sl@0: This function is provided for gradual migration of a client from 32-bit RFile APIs sl@0: to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION sl@0: macro. If the macro is defined, then it hides this overload, which would then throw sl@0: compile-time errors for any user code that uses TUint parameter for RFile64::Read. sl@0: sl@0: sl@0: @see RFile::Read(TInt aPos, TDes8& aDes) sl@0: @see RFile64::Read(TInt aPos, TDes8& aDes) sl@0: sl@0: Note that when an attempt is made to read beyond the end of the file, sl@0: no error is returned. sl@0: The descriptor's length is set to the number of bytes read into it. sl@0: Therefore, when reading through a file, the end of file has been reached sl@0: when the descriptor length, as returned by TDesC8::Length(), is zero. sl@0: sl@0: @param aPos Position of first byte to be read. This is an offset from sl@0: the start of the file. If no position is specified, reading sl@0: begins at the current file position. sl@0: If aPos is beyond the end of the file, the function returns sl@0: a zero length descriptor. sl@0: sl@0: @param aDes The descriptor into which binary data is read. Any existing content sl@0: is overwritten. On return, its length is set to the number of sl@0: bytes read. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile64::Read(TUint aPos,TDes8& aDes) const sl@0: { sl@0: TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileRead3, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.MaxLength()); sl@0: sl@0: TInt r; sl@0: if(!(aPos + 1)) sl@0: { sl@0: r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),aPos)); sl@0: } sl@0: else sl@0: { sl@0: TInt64 pos = aPos; sl@0: TPckgC pkPos(pos); sl@0: r = SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.MaxLength(),&pkPos)); sl@0: } sl@0: sl@0: TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead3Return, MODULEUID, r, aDes.Length()); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Reads from the file at the specified offset within the file. sl@0: sl@0: This is an asynchronous function. sl@0: sl@0: This is equivalent to calling RFile::Read(TInt, TDes8&, TRequestStatus&) or sl@0: RFile64::Read(TInt64, TDes8&, TRequestStatus&) except that this function sl@0: accepts TUint, instead of TInt or TInt64, as its first parameter. sl@0: sl@0: This function is provided for gradual migration of a client from 32-bit RFile APIs sl@0: to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION sl@0: macro. If the macro is defined, then it hides this overload, which would then throw sl@0: compile-time errors for any user code that uses TUint parameter for RFile64::Read. sl@0: sl@0: @see RFile::Read(TInt aPos, TDes8& aDes, TRequestStatus& aStatus) sl@0: @see RFile64::Read(TInt aPos, TDes8& aDes, TRequestStatus& aStatus) sl@0: sl@0: Note that when an attempt is made to read beyond the end of the file, sl@0: no error is returned. sl@0: The descriptor's length is set to the number of bytes read into it. sl@0: Therefore, when reading through a file, the end of file has been reached sl@0: when the descriptor length, as returned by TDesC8::Length(), is zero. sl@0: sl@0: @param aPos Position of first byte to be read. This is an offset from sl@0: the start of the file. If no position is specified, sl@0: reading begins at the current file position. sl@0: If aPos is beyond the end of the file, the function returns sl@0: a zero length descriptor. sl@0: sl@0: @param aDes The descriptor into which binary data is read. Any existing sl@0: content is overwritten. On return, its length is set to sl@0: the number of bytes read. sl@0: NB: this function is asynchronous and the request that it sl@0: represents may not complete until some time after the call sl@0: to the function has returned. It is important, therefore, that sl@0: this descriptor remain valid, or remain in scope, until you have sl@0: been notified that the request is complete. sl@0: sl@0: @param aStatus The request status. On completion, contains an error code of KErrNone sl@0: if successful, otherwise one of the other system-wide error codes. sl@0: sl@0: */ sl@0: EFSRV_EXPORT_C void RFile64::Read(TUint aPos,TDes8& aDes,TRequestStatus& aStatus) const sl@0: { sl@0: TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileRead4, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.MaxLength(), &aStatus); sl@0: sl@0: if(!(aPos + 1)) sl@0: { sl@0: RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aDes.MaxLength(),aPos),aStatus); sl@0: } sl@0: else sl@0: { sl@0: TInt64 pos = aPos; sl@0: TPckgC pkPos(pos); sl@0: RSubSessionBase::SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.MaxLength(),&pkPos),aStatus); sl@0: } sl@0: sl@0: TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead4Return, MODULEUID); sl@0: } sl@0: sl@0: sl@0: /** sl@0: Reads the specified number of bytes of binary data from the file at a specified sl@0: offset within the file. sl@0: sl@0: This is a synchronous function. sl@0: sl@0: This is equivalent to calling RFile::Read(TInt, TDes8&, TInt) or sl@0: RFile64::Read(TInt64, TDes8&, TInt) except that this function sl@0: accepts TUint, instead of TInt or TInt64, as its first parameter. sl@0: sl@0: This function is provided for gradual migration of a client from 32-bit RFile APIs sl@0: to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION sl@0: macro. If the macro is defined, then it hides this overload, which would then throw sl@0: compile-time errors for any user code that uses TUint parameter for RFile64::Read. sl@0: sl@0: sl@0: @see RFile::Read(TInt aPos, TDes8& aDes,TInt aLength) sl@0: @see RFile64::Read(TInt aPos, TDes8& aDes,TInt aLength) sl@0: sl@0: Note that when an attempt is made to read beyond the end of the file, sl@0: no error is returned. sl@0: The descriptor's length is set to the number of bytes read into it. sl@0: Therefore, when reading through a file, the end of file has been reached sl@0: when the descriptor length, as returned by TDesC8::Length(), is zero. sl@0: Assuming aLength is less than the maximum length of the descriptor, the only sl@0: circumstances in which Read() can return fewer bytes than requested is when sl@0: the end of file is reached or if an error has occurred. sl@0: sl@0: @param aPos Position of first byte to be read. This is an offset from sl@0: the start of the file. If no position is specified, sl@0: reading begins at the current file position. sl@0: If aPos is beyond the end of the file, the function returns sl@0: a zero length descriptor. sl@0: sl@0: @param aDes The descriptor into which binary data is read. Any existing sl@0: contents are overwritten. On return, its length is set to sl@0: the number of bytes read. sl@0: @param aLength The number of bytes to read from the file into the descriptor. sl@0: If an attempt is made to read more bytes than the descriptor's sl@0: maximum length, then the function updates aStatus parameter with KErrOverflow. sl@0: It must not be negative otherwise the function updates aStatus with KErrArgument. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide sl@0: error codes. sl@0: sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile64::Read(TUint aPos,TDes8& aDes,TInt aLength) const sl@0: { sl@0: TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileRead3, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength); sl@0: sl@0: if (aLength==0) sl@0: { sl@0: aDes.Zero(); sl@0: return(KErrNone); sl@0: } sl@0: else if(aLength>aDes.MaxLength()) sl@0: { sl@0: return(KErrOverflow); sl@0: } sl@0: sl@0: TInt r; sl@0: if(!(aPos + 1)) sl@0: { sl@0: r = SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,aPos)); sl@0: } sl@0: else sl@0: { sl@0: TInt64 pos = aPos; sl@0: TPckgC pkPos(pos); sl@0: r = SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos)); sl@0: } sl@0: sl@0: TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFileRead3Return, MODULEUID, r, aDes.Length()); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Reads the specified number of bytes of binary data from the file at a specified sl@0: offset within the file. sl@0: sl@0: This is an asynchronous function. sl@0: sl@0: This is equivalent to calling RFile::Read(TInt, TDes8&, TInt,TRequestStatus&) or sl@0: RFile64::Read(TInt64, TDes8&, TInt, TRequestStatus&) except that this function sl@0: accepts TUint, instead of TInt or TInt64, as its first parameter. sl@0: sl@0: This function is provided for gradual migration of a client from 32-bit RFile APIs sl@0: to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION sl@0: macro. If the macro is defined, then it hides this overload, which would then throw sl@0: compile-time errors for any user code that uses TUint parameter for RFile64::Read. sl@0: sl@0: sl@0: @see RFile::Read(TInt aPos, TDes8& aDes,TInt aLength,TRequestStatus& aStatus) sl@0: @see RFile64::Read(TInt aPos, TDes8& aDes,TInt aLength,TRequestStatus& aStatus) sl@0: sl@0: Note that when an attempt is made to read beyond the end of the file, sl@0: no error is returned. sl@0: The descriptor's length is set to the number of bytes read into it. sl@0: Therefore, when reading through a file, the end of file has been reached sl@0: when the descriptor length, as returned by TDesC8::Length(), is zero. sl@0: Assuming aLength is less than the maximum length of the descriptor, the only sl@0: circumstances in which Read() can return fewer bytes than requested is when sl@0: the end of file is reached or if an error has occurred. sl@0: sl@0: @param aPos Position of first byte to be read. This is an offset from sl@0: the start of the file. If no position is specified, sl@0: reading begins at the current file position. sl@0: If aPos is beyond the end of the file, the function returns sl@0: a zero length descriptor. sl@0: sl@0: @param aDes The descriptor into which binary data is read. Any existing sl@0: contents are overwritten. On return, its length is set to sl@0: the number of bytes read. sl@0: NB: this function is asynchronous and the request that it sl@0: represents may not complete until some time after the call sl@0: to the function has returned. It is important, therefore, that sl@0: this descriptor remain valid, or remain in scope, until you have sl@0: been notified that the request is complete. sl@0: sl@0: @param aLength The number of bytes to read from the file into the descriptor. sl@0: If an attempt is made to read more bytes than the descriptor's sl@0: maximum length, then the function returns KErrOverflow. sl@0: It must not be negative otherwise the function returns KErrArgument. sl@0: sl@0: @param aStatus Request status. On completion contains KErrNone if successful, sl@0: otherwise one of the other system-wide error codes. sl@0: sl@0: */ sl@0: EFSRV_EXPORT_C void RFile64::Read(TUint aPos,TDes8& aDes,TInt aLength,TRequestStatus& aStatus) const sl@0: { sl@0: TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileRead4, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength, &aStatus); sl@0: sl@0: if (aLength==0) sl@0: { sl@0: aDes.Zero(); sl@0: TRequestStatus* req=(&aStatus); sl@0: User::RequestComplete(req,KErrNone); sl@0: return; sl@0: } sl@0: else if(aLength>aDes.MaxLength()) sl@0: { sl@0: TRequestStatus* req=(&aStatus); sl@0: User::RequestComplete(req,KErrOverflow); sl@0: return; sl@0: } sl@0: sl@0: if(!(aPos + 1)) sl@0: { sl@0: RSubSessionBase::SendReceive(EFsFileRead,TIpcArgs(&aDes,aLength,aPos),aStatus); sl@0: } sl@0: else sl@0: { sl@0: TInt64 pos = aPos; sl@0: TPckgC pkPos(pos); sl@0: RSubSessionBase::SendReceive(EFsFileRead|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos),aStatus); sl@0: } sl@0: sl@0: TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileRead4Return, MODULEUID); sl@0: } sl@0: sl@0: sl@0: /** sl@0: Writes to the file at the specified offset within the file sl@0: sl@0: This is a synchronous function. sl@0: sl@0: This is equivalent to calling RFile::Write(TInt, TDes8&) or sl@0: RFile64::Write(TInt64, TDes8&) except that this function sl@0: accepts TUint, instead of TInt or TInt64, as its first parameter. sl@0: sl@0: This function is provided for gradual migration of a client from 32-bit RFile APIs sl@0: to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION sl@0: macro. If the macro is defined, then it hides this overload, which would then throw sl@0: compile-time errors for any user code that uses TUint parameter for RFile64::Read. sl@0: sl@0: sl@0: @see RFile::Write(TInt aPos, TDes8& aDes) sl@0: @see RFile64::Write(TInt aPos, TDes8& aDes) sl@0: sl@0: sl@0: @param aPos The offset from the start of the file at which the first sl@0: byte is written. sl@0: If a position beyond the end of the file is specified, then sl@0: the write operation begins at the end of the file. sl@0: If the position has been locked, then the write fails. sl@0: sl@0: @param aDes The descriptor from which binary data is written. The function writes sl@0: the entire contents of aDes to the file. sl@0: sl@0: @return KErrNone if successful, otherwise one of the other system-wide error sl@0: codes. sl@0: sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile64::Write(TUint aPos,const TDesC8& aDes) sl@0: { sl@0: TRACE5(UTF::EBorder, UTraceModuleEfsrv::EFileWrite3, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.Length()); sl@0: sl@0: TInt r; sl@0: if(!(aPos + 1)) sl@0: { sl@0: r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),aPos)); sl@0: } sl@0: else sl@0: { sl@0: TInt64 pos = aPos; sl@0: TPckgC pkPos(pos); sl@0: r = SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.Length(),&pkPos)); sl@0: } sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite3Return, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Writes to the file at the specified offset within the file sl@0: sl@0: This is an asynchronous function. sl@0: sl@0: This is equivalent to calling RFile::Write(TInt, TDes8&,TRequestStatus&) or sl@0: RFile64::Write(TInt64, TDes8&,TRequestStatus&) except that this function sl@0: accepts TUint, instead of TInt or TInt64, as its first parameter. sl@0: sl@0: This function is provided for gradual migration of a client from 32-bit RFile APIs sl@0: to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION sl@0: macro. If the macro is defined, then it hides this overload, which would then throw sl@0: compile-time errors for any user code that uses TUint parameter for RFile64::Read. sl@0: sl@0: sl@0: @see RFile::Write(TInt aPos, TDes8& aDes,TRequestStatus& aStatus) sl@0: @see RFile64::Write(TInt aPos, TDes8& aDes,TRequestStatus& aStatus) sl@0: sl@0: sl@0: @param aPos The offset from the start of the file at which the first sl@0: byte is written. sl@0: If a position beyond the end of the file is specified, then sl@0: the write operation begins at the end of the file. sl@0: If the position has been locked, then the write fails. sl@0: sl@0: @param aDes The descriptor from which binary data is written. The function sl@0: writes the entire contents of aDes to the file. sl@0: NB: this function is asynchronous and the request that it sl@0: represents may not complete until some time after the call sl@0: to the function has returned. It is important, therefore, that sl@0: this descriptor remain valid, or remain in scope, until you have sl@0: been notified that the request is complete. sl@0: sl@0: @param aStatus Request status. On completion contains KErrNone if successful, sl@0: otherwise one of the other system-wide error codes. sl@0: sl@0: */ sl@0: EFSRV_EXPORT_C void RFile64::Write(TUint aPos,const TDesC8& aDes,TRequestStatus& aStatus) sl@0: { sl@0: TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileWrite4, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aDes.Length(), &aStatus); sl@0: sl@0: if(!(aPos + 1)) sl@0: { sl@0: RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aDes.Length(),aPos),aStatus); sl@0: } sl@0: else sl@0: { sl@0: TInt64 pos = aPos; sl@0: TPckgC pkPos(pos); sl@0: RSubSessionBase::SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aDes.Length(),&pkPos),aStatus); sl@0: } sl@0: TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite4Return, MODULEUID); sl@0: } sl@0: sl@0: sl@0: /** sl@0: Writes the specified number of bytes to the file at the specified offset within the file. sl@0: sl@0: This is a synchronous function. sl@0: sl@0: This is equivalent to calling RFile::Write(TInt, TDes8&,TInt) or sl@0: RFile64::Write(TInt64, TDes8&,TInt) except that this function sl@0: accepts TUint, instead of TInt or TInt64, as its first parameter. sl@0: sl@0: This function is provided for gradual migration of a client from 32-bit RFile APIs sl@0: to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION sl@0: macro. If the macro is defined, then it hides this overload, which would then throw sl@0: compile-time errors for any user code that uses TUint parameter for RFile64::Read. sl@0: sl@0: sl@0: @see RFile::Write(TInt aPos, TDes8& aDes,TInt aLength) sl@0: @see RFile64::Write(TInt aPos, TDes8& aDes,TInt aLength) sl@0: sl@0: @param aPos The offset from the start of the file at which the first sl@0: byte is written. sl@0: If a position beyond the end of the file is specified, then sl@0: the write operation begins at the end of the file. sl@0: If the position has been locked, then the write fails. sl@0: sl@0: @param aDes The descriptor from which binary data is written. sl@0: @param aLength The number of bytes to be written from aDes . sl@0: It must not be negative. sl@0: sl@0: @return KErrNone if successful; KErrArgument if aLength is negative; sl@0: otherwise one of the other system-wide error codes. sl@0: sl@0: */ sl@0: EFSRV_EXPORT_C TInt RFile64::Write(TUint aPos,const TDesC8& aDes,TInt aLength) sl@0: { sl@0: TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1, MODULEUID, Session().Handle(), SubSessionHandle(), aLength); sl@0: sl@0: TInt r; sl@0: if(!(aPos + 1)) sl@0: { sl@0: r = SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,aPos)); sl@0: } sl@0: else sl@0: { sl@0: TInt64 pos = aPos; sl@0: TPckgC pkPos(pos); sl@0: r = SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos)); sl@0: } sl@0: sl@0: TRACERET1(UTF::EBorder, UTraceModuleEfsrv::EFileWrite1Return, MODULEUID, r); sl@0: return r; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Writes the specified number of bytes to the file at the specified offset within the file. sl@0: sl@0: This is an asynchronous function. sl@0: sl@0: This is equivalent to calling RFile::Write(TInt, TDes8&,TInt,TRequestStatus&) or sl@0: RFile64::Write(TInt64, TDes8&,TInt,TRequestStatus&) except that this function sl@0: accepts TUint, instead of TInt or TInt64, as its first parameter. sl@0: sl@0: This function is provided for gradual migration of a client from 32-bit RFile APIs sl@0: to 64-bit RFile64 APIs. It is protected under _F32_STRICT_64_BIT_MIGRATION sl@0: macro. If the macro is defined, then it hides this overload, which would then throw sl@0: compile-time errors for any user code that uses TUint parameter for RFile64::Read. sl@0: sl@0: sl@0: @see RFile::Write(TInt aPos, TDes8& aDes, TInt aLength, TRequestStatus& aStatus) sl@0: @see RFile64::Write(TInt aPos, TDes8& aDes,TInt aLength, TRequestStatus& aStatus) sl@0: sl@0: sl@0: @param aPos The offset from the start of the file at which the first sl@0: byte is written. sl@0: If a position beyond the end of the file is specified, then sl@0: the write operation begins at the end of the file. sl@0: If the position has been locked, then the write fails. sl@0: sl@0: @param aDes The descriptor from which binary data is written. sl@0: NB: this function is asynchronous and the request that it sl@0: represents may not complete until some time after the call sl@0: to the function has returned. It is important, therefore, that sl@0: this descriptor remain valid, or remain in scope, until you have sl@0: been notified that the request is complete. sl@0: sl@0: @param aLength The number of bytes to be written from aDes. sl@0: It must not be negative. sl@0: sl@0: @param aStatus Request status. On completion contains KErrNone if successful; sl@0: KErrArgument if aLength is negative; sl@0: otherwise one of the other system-wide error codes. sl@0: sl@0: */ sl@0: EFSRV_EXPORT_C void RFile64::Write(TUint aPos,const TDesC8& aDes,TInt aLength,TRequestStatus& aStatus) sl@0: { sl@0: TRACE6(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2, MODULEUID, Session().Handle(), SubSessionHandle(), aPos, 0, aLength, &aStatus); sl@0: sl@0: if(!(aPos + 1)) sl@0: { sl@0: RSubSessionBase::SendReceive(EFsFileWrite,TIpcArgs(&aDes,aLength,aPos),aStatus); sl@0: } sl@0: else sl@0: { sl@0: TInt64 pos = aPos; sl@0: TPckgC pkPos(pos); sl@0: RSubSessionBase::SendReceive(EFsFileWrite|KIpcArgSlot2Desc,TIpcArgs(&aDes,aLength,&pkPos),aStatus); sl@0: } sl@0: TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFileWrite2Return, MODULEUID); sl@0: } sl@0: #else sl@0: EFSRV_EXPORT_C TInt RFile64::Open(RFs& /*aFs*/,const TDesC& /*aName*/,TUint /*aFileMode*/) sl@0: {Panic(ENotImplemented);return (KErrNotSupported);} sl@0: EFSRV_EXPORT_C TInt RFile64::Create(RFs& /*aFs*/,const TDesC& /*aName*/,TUint /*aFileMode*/) sl@0: {Panic(ENotImplemented);return (KErrNotSupported);} sl@0: EFSRV_EXPORT_C TInt RFile64::Replace(RFs& /*aFs*/,const TDesC& /*aName*/,TUint /*aFileMode*/) sl@0: {Panic(ENotImplemented);return (KErrNotSupported);} sl@0: EFSRV_EXPORT_C TInt RFile64::Temp(RFs& /*aFs*/,const TDesC& /*aPath*/,TFileName& /*aName*/,TUint /*aFileMode*/) sl@0: {Panic(ENotImplemented);return (KErrNotSupported);} sl@0: EFSRV_EXPORT_C TInt RFile64::AdoptFromClient(const RMessage2& /*aMsg*/, TInt /*aFsHandleIndex*/, TInt /*aFileHandleIndex*/) sl@0: {Panic(ENotImplemented);return (KErrNotSupported);} sl@0: EFSRV_EXPORT_C TInt RFile64::AdoptFromServer(TInt /*aFsHandle*/, TInt /*aFileHandle*/) sl@0: {Panic(ENotImplemented);return (KErrNotSupported);} sl@0: EFSRV_EXPORT_C TInt RFile64::AdoptFromCreator(TInt /*aFsHandleIndex*/, TInt /*aFileHandleIndex*/) sl@0: {Panic(ENotImplemented);return (KErrNotSupported);} sl@0: EFSRV_EXPORT_C TInt RFile64::Read(TInt64 /*aPos*/, TDes8& /*aDes*/) const sl@0: {Panic(ENotImplemented);return (KErrNotSupported);} sl@0: EFSRV_EXPORT_C void RFile64::Read(TInt64 /*aPos*/, TDes8& /*aDes*/, TRequestStatus& /*aStatus*/) const sl@0: {Panic(ENotImplemented);} sl@0: EFSRV_EXPORT_C TInt RFile64::Read(TInt64 /*aPos*/, TDes8& /*aDes*/, TInt /*aLength*/) const sl@0: {Panic(ENotImplemented);return (KErrNotSupported);} sl@0: EFSRV_EXPORT_C void RFile64::Read(TInt64 /*aPos*/, TDes8& /*aDes*/, TInt /*aLength*/,TRequestStatus& /*aStatus*/) const sl@0: {Panic(ENotImplemented);} sl@0: EFSRV_EXPORT_C TInt RFile64::Write(TInt64 /*aPos*/, const TDesC8& /*aDes*/) sl@0: {Panic(ENotImplemented);return (KErrNotSupported);} sl@0: EFSRV_EXPORT_C void RFile64::Write(TInt64 /*aPos*/, const TDesC8& /*aDes*/,TRequestStatus& /*aStatus*/) sl@0: {Panic(ENotImplemented);} sl@0: EFSRV_EXPORT_C TInt RFile64::Write(TInt64 /*aPos*/, const TDesC8& /*aDes*/, TInt /*aLength*/) sl@0: {Panic(ENotImplemented);return (KErrNotSupported);} sl@0: EFSRV_EXPORT_C void RFile64::Write(TInt64 /*aPos*/, const TDesC8& /*aDes*/,TInt /*aLength*/,TRequestStatus& /*aStatus*/) sl@0: {Panic(ENotImplemented);} sl@0: EFSRV_EXPORT_C TInt RFile64::Seek(TSeek /*aMode*/, TInt64& /*aPos*/) const sl@0: {Panic(ENotImplemented);return (KErrNotSupported);} sl@0: EFSRV_EXPORT_C TInt RFile64::Size(TInt64& /*aSize*/) const sl@0: {Panic(ENotImplemented);return (KErrNotSupported);} sl@0: EFSRV_EXPORT_C TInt RFile64::SetSize(TInt64 /*aSize*/) sl@0: {Panic(ENotImplemented);return (KErrNotSupported);} sl@0: EFSRV_EXPORT_C TInt RFile64::Lock(TInt64 /*aPos*/, TInt64 /*aLength*/) const sl@0: {Panic(ENotImplemented);return (KErrNotSupported);} sl@0: EFSRV_EXPORT_C TInt RFile64::UnLock(TInt64 /*aPos*/, TInt64 /*aLength*/) const sl@0: {Panic(ENotImplemented);return (KErrNotSupported);} sl@0: EFSRV_EXPORT_C TInt RFile64::Read(TUint /*aPos*/,TDes8& /*aDes*/) const sl@0: {Panic(ENotImplemented);return (KErrNotSupported);} sl@0: EFSRV_EXPORT_C void RFile64::Read(TUint /*aPos*/,TDes8& /*aDes*/,TRequestStatus& /*aStatus*/) const sl@0: {Panic(ENotImplemented);} sl@0: EFSRV_EXPORT_C TInt RFile64::Read(TUint /*aPos*/,TDes8& /*aDes*/,TInt /*aLength*/) const sl@0: {Panic(ENotImplemented);return (KErrNotSupported);} sl@0: EFSRV_EXPORT_C void RFile64::Read(TUint /*aPos*/,TDes8& /*aDes*/,TInt /*aLength*/,TRequestStatus& /*aStatus*/) const sl@0: {Panic(ENotImplemented);} sl@0: EFSRV_EXPORT_C TInt RFile64::Write(TUint /*aPos*/,const TDesC8& /*aDes*/) sl@0: {Panic(ENotImplemented);return (KErrNotSupported);} sl@0: EFSRV_EXPORT_C void RFile64::Write(TUint /*aPos*/,const TDesC8& /*aDes*/,TRequestStatus& /*aStatus*/) sl@0: {Panic(ENotImplemented);} sl@0: EFSRV_EXPORT_C TInt RFile64::Write(TUint /*aPos*/,const TDesC8& /*aDes*/,TInt /*aLength*/) sl@0: {Panic(ENotImplemented);return (KErrNotSupported);} sl@0: EFSRV_EXPORT_C void RFile64::Write(TUint /*aPos*/, const TDesC8& /*aDes*/,TInt /*aLength*/,TRequestStatus& /*aStatus*/) sl@0: {Panic(ENotImplemented);} sl@0: #endif