symport/f32/sfsrv/cl_drive.cpp
changeset 1 0a7b44b10206
child 2 806186ab5e14
equal deleted inserted replaced
0:c55016431358 1:0a7b44b10206
       
     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 "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // f32\sfsrv\cl_drive.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "cl_std.h"
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 EXPORT_C TDriveUnit::TDriveUnit(TInt aDrive)
       
    24 /**
       
    25 Constructor taking a drive number.
       
    26 
       
    27 @param aDrive The drive number.
       
    28 
       
    29 @panic FSCLIENT 0 if aDrive is greater than or equal to KMaxDrives or less than 0.
       
    30 
       
    31 @see KMaxDrives
       
    32 */
       
    33 	{
       
    34 	__ASSERT_ALWAYS((aDrive>=0 && aDrive<KMaxDrives),Panic(EDriveUnitBadDrive));
       
    35 	iDrive=aDrive;
       
    36 	}
       
    37 
       
    38 
       
    39 
       
    40 
       
    41 EXPORT_C TDriveUnit::TDriveUnit(const TDesC& aDriveText)
       
    42 /**
       
    43 Constructor taking a drive letter.
       
    44 
       
    45 @param aDriveText A descriptor containing text whose first character is
       
    46                   the drive letter. Can be upper or lower case. Trailing text
       
    47                   is ignored.
       
    48                   
       
    49 @panic FSCLIENT 1 if the drive letter is invalid, i.e. does not correspond
       
    50        to a drive number.
       
    51        
       
    52 @see RFs::CharToDrive
       
    53 */
       
    54 	{
       
    55 	__ASSERT_ALWAYS(RFs::CharToDrive(aDriveText[0],iDrive)==0,Panic(EDriveUnitBadDriveText));
       
    56 	}
       
    57 
       
    58 
       
    59 
       
    60 
       
    61 EXPORT_C TDriveUnit& TDriveUnit::operator=(TInt aDrive)
       
    62 /**
       
    63 Assigns the drive number to the drive unit
       
    64 
       
    65 @param aDrive The new drive number.
       
    66 
       
    67 @return A reference to this drive unit. 
       
    68 
       
    69 @panic FSCLIENT 0 if aDrive is greater than or equal to KMaxDrives.
       
    70 
       
    71 @see KMaxDrives
       
    72 */
       
    73 	{
       
    74 	__ASSERT_ALWAYS(aDrive<KMaxDrives,Panic(EDriveUnitBadDrive));
       
    75 	iDrive=aDrive;
       
    76 	return *this;
       
    77 	}
       
    78 
       
    79 
       
    80 
       
    81 
       
    82 EXPORT_C TDriveUnit& TDriveUnit::operator=(const TDesC& aDriveText)
       
    83 /**
       
    84 Assigns a drive letter to the drive unit.
       
    85 
       
    86 The letter must be between A and Z or a panic is raised. Any trailing
       
    87 text within the descriptor is ignored.
       
    88 
       
    89 @param aDriveText Descriptor containing text whose first character is
       
    90                   the drive letter. It can be upper or lower case.
       
    91                   
       
    92 @return A reference to this drive unit. 
       
    93 
       
    94 @panic FSCLIENT 1 if the drive letter is invalid, i.e. does not correspond
       
    95        to a drive number.
       
    96        
       
    97 @see RFs::CharToDrive                  
       
    98 */
       
    99 	{
       
   100 	__ASSERT_ALWAYS(RFs::CharToDrive(aDriveText[0],iDrive)==0,Panic(EDriveUnitBadDriveText));
       
   101 	return *this;
       
   102 	}
       
   103 
       
   104 
       
   105 
       
   106 
       
   107 EXPORT_C TDriveName TDriveUnit::Name() const
       
   108 /**
       
   109 Gets the drive unit as text.
       
   110 
       
   111 The drive letter is returned with a trailing colon.
       
   112 
       
   113 @return The drive letter and a trailing colon.
       
   114 
       
   115 @panic FSCLIENT 0 if RFs::DriveToChar() returned an error.
       
   116 */
       
   117 	{
       
   118 	TChar driveLetter;
       
   119 	TInt r = RFs::DriveToChar(iDrive,driveLetter);
       
   120 	__ASSERT_ALWAYS(r == KErrNone, Panic(EDriveUnitBadDrive));
       
   121 	TDriveName driveName;
       
   122 	driveName.SetLength(2);
       
   123 	driveName[0]=(TText)driveLetter;
       
   124 	driveName[1]=KDriveDelimiter;
       
   125 	return driveName;
       
   126 	}
       
   127