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_drive.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 |
EXPORT_C TDriveUnit::TDriveUnit(TInt aDrive)
|
sl@0
|
24 |
/**
|
sl@0
|
25 |
Constructor taking a drive number.
|
sl@0
|
26 |
|
sl@0
|
27 |
@param aDrive The drive number.
|
sl@0
|
28 |
|
sl@0
|
29 |
@panic FSCLIENT 0 if aDrive is greater than or equal to KMaxDrives or less than 0.
|
sl@0
|
30 |
|
sl@0
|
31 |
@see KMaxDrives
|
sl@0
|
32 |
*/
|
sl@0
|
33 |
{
|
sl@0
|
34 |
__ASSERT_ALWAYS((aDrive>=0 && aDrive<KMaxDrives),Panic(EDriveUnitBadDrive));
|
sl@0
|
35 |
iDrive=aDrive;
|
sl@0
|
36 |
}
|
sl@0
|
37 |
|
sl@0
|
38 |
|
sl@0
|
39 |
|
sl@0
|
40 |
|
sl@0
|
41 |
EXPORT_C TDriveUnit::TDriveUnit(const TDesC& aDriveText)
|
sl@0
|
42 |
/**
|
sl@0
|
43 |
Constructor taking a drive letter.
|
sl@0
|
44 |
|
sl@0
|
45 |
@param aDriveText A descriptor containing text whose first character is
|
sl@0
|
46 |
the drive letter. Can be upper or lower case. Trailing text
|
sl@0
|
47 |
is ignored.
|
sl@0
|
48 |
|
sl@0
|
49 |
@panic FSCLIENT 1 if the drive letter is invalid, i.e. does not correspond
|
sl@0
|
50 |
to a drive number.
|
sl@0
|
51 |
|
sl@0
|
52 |
@see RFs::CharToDrive
|
sl@0
|
53 |
*/
|
sl@0
|
54 |
{
|
sl@0
|
55 |
__ASSERT_ALWAYS(RFs::CharToDrive(aDriveText[0],iDrive)==0,Panic(EDriveUnitBadDriveText));
|
sl@0
|
56 |
}
|
sl@0
|
57 |
|
sl@0
|
58 |
|
sl@0
|
59 |
|
sl@0
|
60 |
|
sl@0
|
61 |
EXPORT_C TDriveUnit& TDriveUnit::operator=(TInt aDrive)
|
sl@0
|
62 |
/**
|
sl@0
|
63 |
Assigns the drive number to the drive unit
|
sl@0
|
64 |
|
sl@0
|
65 |
@param aDrive The new drive number.
|
sl@0
|
66 |
|
sl@0
|
67 |
@return A reference to this drive unit.
|
sl@0
|
68 |
|
sl@0
|
69 |
@panic FSCLIENT 0 if aDrive is greater than or equal to KMaxDrives.
|
sl@0
|
70 |
|
sl@0
|
71 |
@see KMaxDrives
|
sl@0
|
72 |
*/
|
sl@0
|
73 |
{
|
sl@0
|
74 |
__ASSERT_ALWAYS(aDrive<KMaxDrives,Panic(EDriveUnitBadDrive));
|
sl@0
|
75 |
iDrive=aDrive;
|
sl@0
|
76 |
return *this;
|
sl@0
|
77 |
}
|
sl@0
|
78 |
|
sl@0
|
79 |
|
sl@0
|
80 |
|
sl@0
|
81 |
|
sl@0
|
82 |
EXPORT_C TDriveUnit& TDriveUnit::operator=(const TDesC& aDriveText)
|
sl@0
|
83 |
/**
|
sl@0
|
84 |
Assigns a drive letter to the drive unit.
|
sl@0
|
85 |
|
sl@0
|
86 |
The letter must be between A and Z or a panic is raised. Any trailing
|
sl@0
|
87 |
text within the descriptor is ignored.
|
sl@0
|
88 |
|
sl@0
|
89 |
@param aDriveText Descriptor containing text whose first character is
|
sl@0
|
90 |
the drive letter. It can be upper or lower case.
|
sl@0
|
91 |
|
sl@0
|
92 |
@return A reference to this drive unit.
|
sl@0
|
93 |
|
sl@0
|
94 |
@panic FSCLIENT 1 if the drive letter is invalid, i.e. does not correspond
|
sl@0
|
95 |
to a drive number.
|
sl@0
|
96 |
|
sl@0
|
97 |
@see RFs::CharToDrive
|
sl@0
|
98 |
*/
|
sl@0
|
99 |
{
|
sl@0
|
100 |
__ASSERT_ALWAYS(RFs::CharToDrive(aDriveText[0],iDrive)==0,Panic(EDriveUnitBadDriveText));
|
sl@0
|
101 |
return *this;
|
sl@0
|
102 |
}
|
sl@0
|
103 |
|
sl@0
|
104 |
|
sl@0
|
105 |
|
sl@0
|
106 |
|
sl@0
|
107 |
EXPORT_C TDriveName TDriveUnit::Name() const
|
sl@0
|
108 |
/**
|
sl@0
|
109 |
Gets the drive unit as text.
|
sl@0
|
110 |
|
sl@0
|
111 |
The drive letter is returned with a trailing colon.
|
sl@0
|
112 |
|
sl@0
|
113 |
@return The drive letter and a trailing colon.
|
sl@0
|
114 |
|
sl@0
|
115 |
@panic FSCLIENT 0 if RFs::DriveToChar() returned an error.
|
sl@0
|
116 |
*/
|
sl@0
|
117 |
{
|
sl@0
|
118 |
TChar driveLetter;
|
sl@0
|
119 |
TInt r = RFs::DriveToChar(iDrive,driveLetter);
|
sl@0
|
120 |
__ASSERT_ALWAYS(r == KErrNone, Panic(EDriveUnitBadDrive));
|
sl@0
|
121 |
TDriveName driveName;
|
sl@0
|
122 |
driveName.SetLength(2);
|
sl@0
|
123 |
driveName[0]=(TText)driveLetter;
|
sl@0
|
124 |
driveName[1]=KDriveDelimiter;
|
sl@0
|
125 |
return driveName;
|
sl@0
|
126 |
}
|
sl@0
|
127 |
|