Changes to File Server Behaviour

Describes the behaviour changes of APIs that have been made 64-bit aware. The signature of these APIs has not changed but the change in their behaviour may impact existing applications.

If you wish to use large files with your application and you are using any of the following functions, check that the changes in behaviour described here do not cause your application to fail.

Note: If your legacy application opens a file in shared write mode, another application can make it large using the 64-bit APIs. If your application is affected, you should:
  • enable 64-bit file support to allow access to files beyond the 2GB boundary

  • migrate to TInt64 offsets

  • migrate to the RFile::Seek64() and RFile::Size64() APIs.

Clients that do not migrate need to ensure t hey handle the error KErrTooBig:

  • RFile::Read() returns KErrTooBig if the read position goes beyond 2GB-1.

  • RFile::Seek() returns KErrTooBig if the 64-bit Seek() function seeks to a location greater than 2GB-1.

  • RFile::Size() returns the lower 32-bits of the file size and KErrTooBig.

RFile::Read()

There are four RFile::Read() overloaded functions that can perform a read from the current file position. These functions can read from a position beyond 2GB–1:

Verify that your application can handle reads greater than 2GB. The following example shows a counter variable accumulating the number of bytes. As this can be more than 2GB, the counter should be of type TInt64.

    TInt r;
    RFile file;
    // Replace TInt variable with TInt64 variable
    // TInt bytesRead = 0;
    TInt64 bytesRead = 0;
    TBuf8<4096> readBuf;
    ...
    // Read loop
    FOREVER
        {
        // Read a block
        r = file.Read(readBuf);
        if(KErrNone != r)
            {
            // Error handling
            break;
            }
        bytesRead += readBuf.Length();

RFile::Seek()

RFile::Seek() has not been altered to handle large files. The table below describes the behaviour for the different seek modes as defined in TMode.

Seek mode

New behaviour

ESeekAddress

No change in behaviour.

ESeekStart

Can seek up to 2GB–1.

ESeekCurrent

If the current position is less than 2GB–1 and the expected position is less than 2GB–1, then the current file pointer is moved, the output parameter is updated with the new file position and KErrNone is returned.

If either the current position or the expected position is more than 2GB–1, seek fails with the error code KErrTooBig and the output parameter is not modified.

ESeekEnd

If the current position is less than 2GB–1 and the expected position is less than 2GB–1, then the current file pointer is moved and the output parameter is updated with the new file position and KErrNone is returned.

If either the current position or the expected position is more than 2GB–1, seek fails with the error code KErrTooBig and the output parameter is not modified.

To handle large files use RFile::Seek64() instead of RFile::Seek(). See Seeking a Position in a Large File.

RFile::Size()

If the file is less than 2GB-1 RFile::Size() behaves as usual and returns KErrNone with the size of the file. If the file is larger than 2GB–1 the function returns KErrTooBig and the lower 32 bits of the file size is returned.

To handle files larger than 2GB-1 use the function RFile::Size64(). See Getting the Size of a Large File using RFile and Getting the Size of a Large File using TEntry.

CRir::Sort()

CRir::Sort() has been enhanced so that it can handle the sorting by size of large directory entries. No change is required to applications currently using this function.

Note: Sort by size is limited to 4GB-1.

RDir::GetDir()

The implementation of the three overloaded functions for RDir::GetDir() has been updated so that these functions can correctly sort directory entries by size. No change is required to applications currently using this function.

Note: Sort by size is limited to 4GB-1.

CFileMan::Copy()

CFileMan::Copy() copies a large file to any location on either the same drive or a different drive. If the target drive does not support large files, the function returns the error KErrTooBig.

No change is required to applications currently using this function.

CFileMan::Move()

CFileMan::Move() moves a file to any location on either the same drive or a different drive. If the target drive does not support large files, the function returns the error KErrTooBig.

No change is required to applications currently using this function.