1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/sfsrv/cl_drive.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,127 @@
1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// f32\sfsrv\cl_drive.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +#include "cl_std.h"
1.22 +
1.23 +
1.24 +
1.25 +
1.26 +EXPORT_C TDriveUnit::TDriveUnit(TInt aDrive)
1.27 +/**
1.28 +Constructor taking a drive number.
1.29 +
1.30 +@param aDrive The drive number.
1.31 +
1.32 +@panic FSCLIENT 0 if aDrive is greater than or equal to KMaxDrives or less than 0.
1.33 +
1.34 +@see KMaxDrives
1.35 +*/
1.36 + {
1.37 + __ASSERT_ALWAYS((aDrive>=0 && aDrive<KMaxDrives),Panic(EDriveUnitBadDrive));
1.38 + iDrive=aDrive;
1.39 + }
1.40 +
1.41 +
1.42 +
1.43 +
1.44 +EXPORT_C TDriveUnit::TDriveUnit(const TDesC& aDriveText)
1.45 +/**
1.46 +Constructor taking a drive letter.
1.47 +
1.48 +@param aDriveText A descriptor containing text whose first character is
1.49 + the drive letter. Can be upper or lower case. Trailing text
1.50 + is ignored.
1.51 +
1.52 +@panic FSCLIENT 1 if the drive letter is invalid, i.e. does not correspond
1.53 + to a drive number.
1.54 +
1.55 +@see RFs::CharToDrive
1.56 +*/
1.57 + {
1.58 + __ASSERT_ALWAYS(RFs::CharToDrive(aDriveText[0],iDrive)==0,Panic(EDriveUnitBadDriveText));
1.59 + }
1.60 +
1.61 +
1.62 +
1.63 +
1.64 +EXPORT_C TDriveUnit& TDriveUnit::operator=(TInt aDrive)
1.65 +/**
1.66 +Assigns the drive number to the drive unit
1.67 +
1.68 +@param aDrive The new drive number.
1.69 +
1.70 +@return A reference to this drive unit.
1.71 +
1.72 +@panic FSCLIENT 0 if aDrive is greater than or equal to KMaxDrives.
1.73 +
1.74 +@see KMaxDrives
1.75 +*/
1.76 + {
1.77 + __ASSERT_ALWAYS(aDrive<KMaxDrives,Panic(EDriveUnitBadDrive));
1.78 + iDrive=aDrive;
1.79 + return *this;
1.80 + }
1.81 +
1.82 +
1.83 +
1.84 +
1.85 +EXPORT_C TDriveUnit& TDriveUnit::operator=(const TDesC& aDriveText)
1.86 +/**
1.87 +Assigns a drive letter to the drive unit.
1.88 +
1.89 +The letter must be between A and Z or a panic is raised. Any trailing
1.90 +text within the descriptor is ignored.
1.91 +
1.92 +@param aDriveText Descriptor containing text whose first character is
1.93 + the drive letter. It can be upper or lower case.
1.94 +
1.95 +@return A reference to this drive unit.
1.96 +
1.97 +@panic FSCLIENT 1 if the drive letter is invalid, i.e. does not correspond
1.98 + to a drive number.
1.99 +
1.100 +@see RFs::CharToDrive
1.101 +*/
1.102 + {
1.103 + __ASSERT_ALWAYS(RFs::CharToDrive(aDriveText[0],iDrive)==0,Panic(EDriveUnitBadDriveText));
1.104 + return *this;
1.105 + }
1.106 +
1.107 +
1.108 +
1.109 +
1.110 +EXPORT_C TDriveName TDriveUnit::Name() const
1.111 +/**
1.112 +Gets the drive unit as text.
1.113 +
1.114 +The drive letter is returned with a trailing colon.
1.115 +
1.116 +@return The drive letter and a trailing colon.
1.117 +
1.118 +@panic FSCLIENT 0 if RFs::DriveToChar() returned an error.
1.119 +*/
1.120 + {
1.121 + TChar driveLetter;
1.122 + TInt r = RFs::DriveToChar(iDrive,driveLetter);
1.123 + __ASSERT_ALWAYS(r == KErrNone, Panic(EDriveUnitBadDrive));
1.124 + TDriveName driveName;
1.125 + driveName.SetLength(2);
1.126 + driveName[0]=(TText)driveLetter;
1.127 + driveName[1]=KDriveDelimiter;
1.128 + return driveName;
1.129 + }
1.130 +