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