Update contrib.
1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32\sfsrv\cl_fraw.cpp
24 Opens a direct access channel to the disk.
26 Other resources are disabled from accessing the disk until Close() is called.
28 Note that if any resources are currently open on the disk, an error
31 @param aFs The file server session.
32 @param aDrive The drive containing the disk to be accessed. Specify a drive
33 in the range EDriveA to EDriveZ for drives A to Z.
35 @return KErrNone, if successful;
36 KErrInUse is returned if any resources are currently open on the disk;
37 otherwise one of the other system-wide error codes.
42 EXPORT_C TInt RRawDisk::Open(RFs& aFs,TInt aDrive)
44 if (!RFs::IsValidDrive(aDrive))
47 return(CreateSubSession(aFs,EFsRawDiskOpen,TIpcArgs(aDrive)));
54 Closes the direct access channel to the disk, and allows other resources
57 EXPORT_C void RRawDisk::Close()
59 CloseSubSession(EFsRawSubClose);
66 Reads directly from the disk.
68 The function reads a number of bytes into the specified descriptor from
69 the disk, beginning at the specified position.
71 @param aPos The position on the disk at which to begin reading.
72 @param aDes The descriptor into which data is to be read.
73 On return aDes contains the data read.
75 @panic User In debug builds, the media driver panics if aPos is larger than
76 the size of the physical media or if the end address, given by
77 aPos + the maximum length of the descriptor, is greater than
78 the size of the physical media.
80 @return KErrNone, if successful, otherwise one of the other system-wide error
86 EXPORT_C TInt RRawDisk::Read(TInt64 aPos,TDes8& aDes)
88 TInt maxLength = aDes.MaxLength();
91 TPtrC8 tBuf((TUint8*)&aPos,sizeof(TInt64));
92 return(SendReceive(EFsRawDiskRead,TIpcArgs(&aDes,maxLength,&tBuf)));
99 Writes directly to the disk.
101 The function writes the contents of the specified descriptor to the
102 disk at position aPos.
104 @param aPos The position at which to begin writing.
105 @param aDes The descriptor containing the data to be written to the disk.
107 @panic User In debug builds, the media driver panics if aPos is larger than
108 the size of the physical media or if the end address, given by
109 aPos + the maximum length of the descriptor, is greater than
110 the size of the physical media.
112 @return KErrNone, if successful, otherwise one of the other system-wide error
118 EXPORT_C TInt RRawDisk::Write(TInt64 aPos,TDesC8& aDes)
120 TInt length = aDes.Length();
123 TPtrC8 tBuf((TUint8*)&aPos,sizeof(TInt64));
124 return(SendReceive(EFsRawDiskWrite,TIpcArgs(&aDes,length,&tBuf)));
131 // Old read / write methods left in to be BC
133 class _RRawDisk : public RRawDisk
136 IMPORT_C TInt Read(TInt aPos,TDes8& aDes);
137 IMPORT_C TInt Write(TInt aPos,TDesC8& aDes);
144 Reads directly from the disk.
146 The function reads a number of bytes into the specified descriptor from
147 the disk beginning at the specified position.
149 @param aPos The position on the disk at which to begin reading.
150 @param aDes The descriptor into which data is to be read. On return, contains the
151 data read. The number of bytes read is the smaller of:
152 a) the total number of bytes on the disk minus aPos;
153 b) the maximum length of the descriptor.
155 @return KErrNone, if successful, otherwise one of the other system-wide error
161 EXPORT_C TInt _RRawDisk::Read(TInt aPos,TDes8& aDes)
163 TInt maxLength = aDes.MaxLength();
166 TInt64 pos = MAKE_TINT64(0,aPos);
167 TPtrC8 tBuf((TUint8*)&pos,sizeof(TInt64));
168 return(SendReceive(EFsRawDiskRead,TIpcArgs(&aDes,maxLength,&tBuf)));
175 Writes directly to the disk.
177 The function writes the contents of the specified descriptor to the
178 disk at position aPos.
180 @param aPos The position at which to begin writing.
181 @param aDes The descriptor containing the data to be written to the disk.
183 @return KErrNone, if successful, otherwise one of the other system-wide error
189 EXPORT_C TInt _RRawDisk::Write(TInt aPos,TDesC8& aDes)
191 TInt length = aDes.Length();
194 TInt64 pos = MAKE_TINT64(0,aPos);
195 TPtrC8 tBuf((TUint8*)&pos,sizeof(TInt64));
196 return(SendReceive(EFsRawDiskWrite,TIpcArgs(&aDes,length,&tBuf)));