sl@0
|
1 |
// Copyright (c) 1996-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_fraw.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include "cl_std.h"
|
sl@0
|
19 |
|
sl@0
|
20 |
|
sl@0
|
21 |
|
sl@0
|
22 |
|
sl@0
|
23 |
/**
|
sl@0
|
24 |
Opens a direct access channel to the disk.
|
sl@0
|
25 |
|
sl@0
|
26 |
Other resources are disabled from accessing the disk until Close() is called.
|
sl@0
|
27 |
|
sl@0
|
28 |
Note that if any resources are currently open on the disk, an error
|
sl@0
|
29 |
is returned.
|
sl@0
|
30 |
|
sl@0
|
31 |
@param aFs The file server session.
|
sl@0
|
32 |
@param aDrive The drive containing the disk to be accessed. Specify a drive
|
sl@0
|
33 |
in the range EDriveA to EDriveZ for drives A to Z.
|
sl@0
|
34 |
|
sl@0
|
35 |
@return KErrNone, if successful;
|
sl@0
|
36 |
KErrInUse is returned if any resources are currently open on the disk;
|
sl@0
|
37 |
otherwise one of the other system-wide error codes.
|
sl@0
|
38 |
|
sl@0
|
39 |
@capability TCB
|
sl@0
|
40 |
|
sl@0
|
41 |
*/
|
sl@0
|
42 |
EXPORT_C TInt RRawDisk::Open(RFs& aFs,TInt aDrive)
|
sl@0
|
43 |
{
|
sl@0
|
44 |
if (!RFs::IsValidDrive(aDrive))
|
sl@0
|
45 |
return(KErrArgument);
|
sl@0
|
46 |
iDrive=aDrive;
|
sl@0
|
47 |
return(CreateSubSession(aFs,EFsRawDiskOpen,TIpcArgs(aDrive)));
|
sl@0
|
48 |
}
|
sl@0
|
49 |
|
sl@0
|
50 |
|
sl@0
|
51 |
|
sl@0
|
52 |
|
sl@0
|
53 |
/**
|
sl@0
|
54 |
Closes the direct access channel to the disk, and allows other resources
|
sl@0
|
55 |
to access the disk.
|
sl@0
|
56 |
*/
|
sl@0
|
57 |
EXPORT_C void RRawDisk::Close()
|
sl@0
|
58 |
{
|
sl@0
|
59 |
CloseSubSession(EFsRawSubClose);
|
sl@0
|
60 |
}
|
sl@0
|
61 |
|
sl@0
|
62 |
|
sl@0
|
63 |
|
sl@0
|
64 |
|
sl@0
|
65 |
/**
|
sl@0
|
66 |
Reads directly from the disk.
|
sl@0
|
67 |
|
sl@0
|
68 |
The function reads a number of bytes into the specified descriptor from
|
sl@0
|
69 |
the disk, beginning at the specified position.
|
sl@0
|
70 |
|
sl@0
|
71 |
@param aPos The position on the disk at which to begin reading.
|
sl@0
|
72 |
@param aDes The descriptor into which data is to be read.
|
sl@0
|
73 |
On return aDes contains the data read.
|
sl@0
|
74 |
|
sl@0
|
75 |
@panic User In debug builds, the media driver panics if aPos is larger than
|
sl@0
|
76 |
the size of the physical media or if the end address, given by
|
sl@0
|
77 |
aPos + the maximum length of the descriptor, is greater than
|
sl@0
|
78 |
the size of the physical media.
|
sl@0
|
79 |
|
sl@0
|
80 |
@return KErrNone, if successful, otherwise one of the other system-wide error
|
sl@0
|
81 |
codes.
|
sl@0
|
82 |
|
sl@0
|
83 |
@capability TCB
|
sl@0
|
84 |
|
sl@0
|
85 |
*/
|
sl@0
|
86 |
EXPORT_C TInt RRawDisk::Read(TInt64 aPos,TDes8& aDes)
|
sl@0
|
87 |
{
|
sl@0
|
88 |
TInt maxLength = aDes.MaxLength();
|
sl@0
|
89 |
if (maxLength==0)
|
sl@0
|
90 |
return(KErrNone);
|
sl@0
|
91 |
TPtrC8 tBuf((TUint8*)&aPos,sizeof(TInt64));
|
sl@0
|
92 |
return(SendReceive(EFsRawDiskRead,TIpcArgs(&aDes,maxLength,&tBuf)));
|
sl@0
|
93 |
}
|
sl@0
|
94 |
|
sl@0
|
95 |
|
sl@0
|
96 |
|
sl@0
|
97 |
|
sl@0
|
98 |
/**
|
sl@0
|
99 |
Writes directly to the disk.
|
sl@0
|
100 |
|
sl@0
|
101 |
The function writes the contents of the specified descriptor to the
|
sl@0
|
102 |
disk at position aPos.
|
sl@0
|
103 |
|
sl@0
|
104 |
@param aPos The position at which to begin writing.
|
sl@0
|
105 |
@param aDes The descriptor containing the data to be written to the disk.
|
sl@0
|
106 |
|
sl@0
|
107 |
@panic User In debug builds, the media driver panics if aPos is larger than
|
sl@0
|
108 |
the size of the physical media or if the end address, given by
|
sl@0
|
109 |
aPos + the maximum length of the descriptor, is greater than
|
sl@0
|
110 |
the size of the physical media.
|
sl@0
|
111 |
|
sl@0
|
112 |
@return KErrNone, if successful, otherwise one of the other system-wide error
|
sl@0
|
113 |
codes.
|
sl@0
|
114 |
|
sl@0
|
115 |
@capability TCB
|
sl@0
|
116 |
|
sl@0
|
117 |
*/
|
sl@0
|
118 |
EXPORT_C TInt RRawDisk::Write(TInt64 aPos,TDesC8& aDes)
|
sl@0
|
119 |
{
|
sl@0
|
120 |
TInt length = aDes.Length();
|
sl@0
|
121 |
if (length==0)
|
sl@0
|
122 |
return(KErrNone);
|
sl@0
|
123 |
TPtrC8 tBuf((TUint8*)&aPos,sizeof(TInt64));
|
sl@0
|
124 |
return(SendReceive(EFsRawDiskWrite,TIpcArgs(&aDes,length,&tBuf)));
|
sl@0
|
125 |
}
|
sl@0
|
126 |
|
sl@0
|
127 |
|
sl@0
|
128 |
|
sl@0
|
129 |
|
sl@0
|
130 |
//
|
sl@0
|
131 |
// Old read / write methods left in to be BC
|
sl@0
|
132 |
//
|
sl@0
|
133 |
class _RRawDisk : public RRawDisk
|
sl@0
|
134 |
{
|
sl@0
|
135 |
public:
|
sl@0
|
136 |
IMPORT_C TInt Read(TInt aPos,TDes8& aDes);
|
sl@0
|
137 |
IMPORT_C TInt Write(TInt aPos,TDesC8& aDes);
|
sl@0
|
138 |
};
|
sl@0
|
139 |
|
sl@0
|
140 |
|
sl@0
|
141 |
|
sl@0
|
142 |
|
sl@0
|
143 |
/**
|
sl@0
|
144 |
Reads directly from the disk.
|
sl@0
|
145 |
|
sl@0
|
146 |
The function reads a number of bytes into the specified descriptor from
|
sl@0
|
147 |
the disk beginning at the specified position.
|
sl@0
|
148 |
|
sl@0
|
149 |
@param aPos The position on the disk at which to begin reading.
|
sl@0
|
150 |
@param aDes The descriptor into which data is to be read. On return, contains the
|
sl@0
|
151 |
data read. The number of bytes read is the smaller of:
|
sl@0
|
152 |
a) the total number of bytes on the disk minus aPos;
|
sl@0
|
153 |
b) the maximum length of the descriptor.
|
sl@0
|
154 |
|
sl@0
|
155 |
@return KErrNone, if successful, otherwise one of the other system-wide error
|
sl@0
|
156 |
codes.
|
sl@0
|
157 |
|
sl@0
|
158 |
@capability TCB
|
sl@0
|
159 |
@deprecated
|
sl@0
|
160 |
*/
|
sl@0
|
161 |
EXPORT_C TInt _RRawDisk::Read(TInt aPos,TDes8& aDes)
|
sl@0
|
162 |
{
|
sl@0
|
163 |
TInt maxLength = aDes.MaxLength();
|
sl@0
|
164 |
if (maxLength==0)
|
sl@0
|
165 |
return(KErrNone);
|
sl@0
|
166 |
TInt64 pos = MAKE_TINT64(0,aPos);
|
sl@0
|
167 |
TPtrC8 tBuf((TUint8*)&pos,sizeof(TInt64));
|
sl@0
|
168 |
return(SendReceive(EFsRawDiskRead,TIpcArgs(&aDes,maxLength,&tBuf)));
|
sl@0
|
169 |
}
|
sl@0
|
170 |
|
sl@0
|
171 |
|
sl@0
|
172 |
|
sl@0
|
173 |
|
sl@0
|
174 |
/**
|
sl@0
|
175 |
Writes directly to the disk.
|
sl@0
|
176 |
|
sl@0
|
177 |
The function writes the contents of the specified descriptor to the
|
sl@0
|
178 |
disk at position aPos.
|
sl@0
|
179 |
|
sl@0
|
180 |
@param aPos The position at which to begin writing.
|
sl@0
|
181 |
@param aDes The descriptor containing the data to be written to the disk.
|
sl@0
|
182 |
|
sl@0
|
183 |
@return KErrNone, if successful, otherwise one of the other system-wide error
|
sl@0
|
184 |
codes.
|
sl@0
|
185 |
|
sl@0
|
186 |
@capability TCB
|
sl@0
|
187 |
@deprecated
|
sl@0
|
188 |
*/
|
sl@0
|
189 |
EXPORT_C TInt _RRawDisk::Write(TInt aPos,TDesC8& aDes)
|
sl@0
|
190 |
{
|
sl@0
|
191 |
TInt length = aDes.Length();
|
sl@0
|
192 |
if (length==0)
|
sl@0
|
193 |
return(KErrNone);
|
sl@0
|
194 |
TInt64 pos = MAKE_TINT64(0,aPos);
|
sl@0
|
195 |
TPtrC8 tBuf((TUint8*)&pos,sizeof(TInt64));
|
sl@0
|
196 |
return(SendReceive(EFsRawDiskWrite,TIpcArgs(&aDes,length,&tBuf)));
|
sl@0
|
197 |
}
|