userlibandfileserver/fileserver/sfsrv/cl_drive.cpp
author hgs
Wed, 20 Oct 2010 13:58:28 +0100
changeset 293 0659d0e1a03c
parent 279 957c583b417b
permissions -rw-r--r--
201041_07
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
     1
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
     2
// All rights reserved.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
     3
// This component and the accompanying materials are made available
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
     4
// under the terms of the License "Eclipse Public License v1.0"
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
     5
// which accompanies this distribution, and is available
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
     7
//
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
     8
// Initial Contributors:
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    10
//
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    11
// Contributors:
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    12
//
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    13
// Description:
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    14
// f32\sfsrv\cl_drive.cpp
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    15
// 
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    16
//
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    17
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    18
#include "cl_std.h"
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    19
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    20
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    21
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    22
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    23
EXPORT_C TDriveUnit::TDriveUnit(TInt aDrive)
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    24
/**
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    25
Constructor taking a drive number.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    26
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    27
@param aDrive The drive number.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    28
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    29
@panic FSCLIENT 0 if aDrive is greater than or equal to KMaxDrives or less than 0.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    30
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    31
@see KMaxDrives
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    32
*/
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    33
	{
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    34
	__ASSERT_ALWAYS((aDrive>=0 && aDrive<KMaxDrives),Panic(EDriveUnitBadDrive));
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    35
	iDrive=aDrive;
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    36
	}
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    37
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    38
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    39
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    40
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    41
EXPORT_C TDriveUnit::TDriveUnit(const TDesC& aDriveText)
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    42
/**
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    43
Constructor taking a drive letter.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    44
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    45
@param aDriveText A descriptor containing text whose first character is
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    46
                  the drive letter. Can be upper or lower case. Trailing text
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    47
                  is ignored.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    48
                  
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    49
@panic FSCLIENT 1 if the drive letter is invalid, i.e. does not correspond
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    50
       to a drive number.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    51
       
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    52
@see RFs::CharToDrive
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    53
*/
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    54
	{
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    55
	__ASSERT_ALWAYS(RFs::CharToDrive(aDriveText[0],iDrive)==0,Panic(EDriveUnitBadDriveText));
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    56
	}
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    57
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    58
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    59
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    60
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    61
EXPORT_C TDriveUnit& TDriveUnit::operator=(TInt aDrive)
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    62
/**
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    63
Assigns the drive number to the drive unit
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    64
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    65
@param aDrive The new drive number.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    66
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    67
@return A reference to this drive unit. 
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    68
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    69
@panic FSCLIENT 0 if aDrive is greater than or equal to KMaxDrives.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    70
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    71
@see KMaxDrives
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    72
*/
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    73
	{
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    74
	__ASSERT_ALWAYS(aDrive<KMaxDrives,Panic(EDriveUnitBadDrive));
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    75
	iDrive=aDrive;
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    76
	return *this;
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    77
	}
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    78
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    79
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    80
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    81
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    82
EXPORT_C TDriveUnit& TDriveUnit::operator=(const TDesC& aDriveText)
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    83
/**
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    84
Assigns a drive letter to the drive unit.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    85
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    86
The letter must be between A and Z or a panic is raised. Any trailing
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    87
text within the descriptor is ignored.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    88
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    89
@param aDriveText Descriptor containing text whose first character is
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    90
                  the drive letter. It can be upper or lower case.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    91
                  
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    92
@return A reference to this drive unit. 
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    93
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    94
@panic FSCLIENT 1 if the drive letter is invalid, i.e. does not correspond
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    95
       to a drive number.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    96
       
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    97
@see RFs::CharToDrive                  
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    98
*/
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
    99
	{
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   100
	__ASSERT_ALWAYS(RFs::CharToDrive(aDriveText[0],iDrive)==0,Panic(EDriveUnitBadDriveText));
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   101
	return *this;
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   102
	}
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   103
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   104
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   105
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   106
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   107
EXPORT_C TDriveName TDriveUnit::Name() const
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   108
/**
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   109
Gets the drive unit as text.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   110
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   111
The drive letter is returned with a trailing colon.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   112
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   113
@return The drive letter and a trailing colon.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   114
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   115
@panic FSCLIENT 0 if RFs::DriveToChar() returned an error.
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   116
*/
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   117
	{
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   118
	TChar driveLetter;
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   119
	TInt r = RFs::DriveToChar(iDrive,driveLetter);
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   120
	__ASSERT_ALWAYS(r == KErrNone, Panic(EDriveUnitBadDrive));
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   121
	TDriveName driveName;
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   122
	driveName.SetLength(2);
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   123
	driveName[0]=(TText)driveLetter;
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   124
	driveName[1]=KDriveDelimiter;
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   125
	return driveName;
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   126
	}
a41df078684a Convert Kernelhwsrv package from SFL to EPL
John Imhofe
parents:
diff changeset
   127
271
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   128
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   129
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   130
//-------------------------------------------------------------------------------------------------------------------
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   131
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   132
/** 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   133
    internal class of the CFsMountHelper, provides the real implementation, It is not supposed to 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   134
    be instantiated by anyone except CFsMountHelper.
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   135
*/
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   136
class TFsMntHelperImpl
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   137
    {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   138
    friend class CFsMountHelper;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   139
   
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   140
 private:
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   141
    
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   142
    TFsMntHelperImpl(RFs& aFs, TInt aDrvNum);
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   143
        
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   144
    //------ 1:1 interface to the host CFsMountHelper class
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   145
    void Init(); 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   146
    TInt GetMountProperties();
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   147
    TInt MountFileSystem() const;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   148
    void DismountFileSystem(TRequestStatus& aStat, CFsMountHelper::TFsDismountMode aDismountMode) const;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   149
    //------
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   150
    
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   151
 private:
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   152
    TBool DataValid() const {return iFsName.Length() >0;}
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   153
    TBool operator==(const TFsMntHelperImpl& aRhs) const;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   154
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   155
    enum {KPrimExtIdx =0}; //-- index of the primary extension name in the iExtNames array
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   156
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   157
    const TDesC& FSysName() const       {return iFsName;}
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   158
    const TDesC& PrimaryExtName() const {return iExtNames[KPrimExtIdx];}
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   159
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   160
    /** bits in a error bitmap that indicate some, potentially multiple, API failure reasons */
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   161
    enum TErrorBits
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   162
        {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   163
        Err_GetFsName       = 0x0001, ///< Error when trying to obtain FS name (possible reason: there is no FS at all on this drive)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   164
        Err_MountFs         = 0x0002, ///< Error when mounting the FS. (possible reason: the FS layout on the media is corrupt or not recognised)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   165
        Err_MountFsPrimExt  = 0x0004, ///< Error when mounting the FS with the primary extension
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   166
        Err_MountSecExt     = 0x0008, ///< Error when mounting the secondary extension 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   167
        };
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   168
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   169
        
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   170
    void  AddErrorBit(TUint32 aFlag) const {ASSERT(aFlag); iErrorBitmap |= aFlag;}
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   171
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   172
    /** panic codes */
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   173
    enum TPanicCode
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   174
        {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   175
        ENotInitialised,  ///< the instance of the implementation is not created
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   176
        EDrvNumberInvalid,///< invalid drive number provided
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   177
        ENotImplemented   ///< the functionality is not implemented
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   178
        };
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   179
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   180
    void Panic(TPanicCode aPanicCode) const;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   181
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   182
 private:
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   183
        RFs&    iFs;                            ///< reference to the file server session
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   184
        TInt    iDrvNum;                        ///< drive number
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   185
        TFSName iFsName;                        ///< file system name.
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   186
        TFSName iExtNames[KMaxExtensionCount];  ///< [0] is a primary ext. name + up to several secondary ones
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   187
        TBool   iDrvSynch;                      ///< true if the drive is synchronous
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   188
        mutable TUint32 iErrorBitmap;           ///< 32 bits indicating API call failures. '1' bit corresponds to some particular reason. See TErrorBits.  
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   189
    };
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   190
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   191
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   192
//-------------------------------------------------------------------------------------------------------------------
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   193
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   194
void TFsMntHelperImpl::DismountFileSystem(TRequestStatus& aStat, CFsMountHelper::TFsDismountMode aDismountMode) const
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   195
    {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   196
    if(!this)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   197
        Panic(ENotInitialised); 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   198
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   199
    TInt nRes;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   200
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   201
#ifdef _DEBUG
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   202
    //-- consistency check (debug mode only). Check that we are dismounting file system with the same parameters
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   203
    //-- since last GetMountProperties() call
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   204
    TFsMntHelperImpl  currSnapshot(iFs, iDrvNum);
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   205
    currSnapshot.GetMountProperties();
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   206
    ASSERT(currSnapshot == *this);
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   207
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   208
#endif //_DEBUG
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   209
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   210
    
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   211
    nRes = KErrArgument;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   212
    TRequestStatus* pStat = &aStat;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   213
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   214
    switch(aDismountMode)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   215
        {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   216
        case CFsMountHelper::ENormal:
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   217
            //-- normal graceful dismounting. Will fail with KErrInUse if there are any opened objects, like files, directories etc.
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   218
            //-- aStat is completed with the API return code. 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   219
            nRes = iFs.DismountFileSystem(iFsName, iDrvNum);
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   220
            User::RequestComplete(pStat, nRes);
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   221
        break;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   222
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   223
        case CFsMountHelper::EForceImmediate:
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   224
            //-- immediate forced dismount. Don't pay attention to any opened objects. All handles will become invalid.
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   225
            //-- The user should wait for aStat completion. Though it is very likely that it is completed immediately.
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   226
            iFs.NotifyDismount(iDrvNum, aStat, EFsDismountForceDismount); 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   227
        break;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   228
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   229
     
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   230
        case CFsMountHelper::ENotifyClients:
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   231
            //-- attempt to dismount FS with notifying any interested clients.
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   232
            iFs.NotifyDismount(iDrvNum, aStat, EFsDismountNotifyClients); 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   233
        break;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   234
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   235
        default:
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   236
            ASSERT(0);
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   237
            User::RequestComplete(pStat, KErrArgument);
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   238
        break;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   239
        };
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   240
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   241
    }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   242
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   243
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   244
//-------------------------------------------------------------------
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   245
TInt TFsMntHelperImpl::GetMountProperties()
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   246
    {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   247
    if(!this)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   248
        Panic(ENotInitialised); 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   249
    Init();
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   250
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   251
    TInt nRes;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   252
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   253
    //-- 1. get file system name
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   254
    nRes = iFs.FileSystemName(iFsName, iDrvNum);
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   255
    if(nRes != KErrNone)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   256
        {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   257
        AddErrorBit(Err_GetFsName); //-- indicate an error 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   258
        return nRes;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   259
        }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   260
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   261
    //-- 2. find out if the drive sync/async
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   262
    TPckgBuf<TBool> drvSyncBuf;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   263
    nRes = iFs.QueryVolumeInfoExt(iDrvNum, EIsDriveSync, drvSyncBuf);
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   264
    if(nRes != KErrNone)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   265
        {//-- pretend that the drive is asynch. in the case of file system being corrupted. this is 99.9% true
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   266
        iDrvSynch = EFalse;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   267
        }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   268
    else
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   269
        {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   270
        iDrvSynch = drvSyncBuf();
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   271
        }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   272
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   273
    //-- 3. find out extension names if there are any. Extension #0 is a primary one and up to several secondary ones
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   274
    for(TInt i=0; i<KMaxExtensionCount; ++i)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   275
        {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   276
        nRes = iFs.ExtensionName(iExtNames[i], iDrvNum, i);
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   277
        if(nRes != KErrNone)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   278
            {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   279
            iExtNames[i].Zero();
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   280
            }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   281
        } 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   282
    
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   283
   
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   284
    return KErrNone;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   285
 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   286
    }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   287
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   288
//-------------------------------------------------------------------
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   289
TInt TFsMntHelperImpl::MountFileSystem() const
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   290
    {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   291
    if(!this)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   292
        Panic(ENotInitialised); 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   293
    
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   294
    ASSERT(DataValid());
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   295
    
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   296
    TInt nRes;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   297
    const TBool bPrimaryExtExists = (PrimaryExtName().Length() >0);
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   298
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   299
    //-- all possible extensions that have existed before dismounting should be present in the file server context.
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   300
    //-- anyway, it's impossible to load them here, because their file names are unknown 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   301
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   302
    if(bPrimaryExtExists)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   303
        {//-- there was a primary extension, use special mounting API
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   304
        nRes = iFs.MountFileSystem(FSysName(), PrimaryExtName(), iDrvNum, iDrvSynch);
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   305
        }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   306
    else
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   307
        {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   308
        nRes = iFs.MountFileSystem(FSysName(), iDrvNum, iDrvSynch);
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   309
        }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   310
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   311
    //-- actually, if nRes != KErrNone, it doesn't _necessarily_ mean that _mounting_ of the file system failed.
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   312
    //-- for example, the FS can be bound to the drive OK, but the media can be corrupted. This can happen when the FS
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   313
    //-- had been dismounted from such a corrupted media.
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   314
    //-- opposite, KErrNotReady is very likely to mean that the removable media is not present.
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   315
    
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   316
    const TInt nFsMountRes = nRes;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   317
    if(nFsMountRes != KErrNone)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   318
        {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   319
        AddErrorBit(bPrimaryExtExists ?  Err_MountFsPrimExt : Err_MountFs);
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   320
        }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   321
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   322
    //-- mount secondary extensions if there were any
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   323
    TInt nExtMountRes = KErrNone;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   324
    for(TInt i=1; i<KMaxExtensionCount; ++i)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   325
        {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   326
        if(iExtNames[i].Length() >0)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   327
            {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   328
            nRes = iFs.MountExtension(iExtNames[i], iDrvNum);
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   329
            if(nRes != KErrNone)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   330
                {//-- indicate that an error happened while installing some secondary extension 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   331
                AddErrorBit(Err_MountSecExt);    
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   332
                nExtMountRes = nRes;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   333
                }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   334
            }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   335
        }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   336
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   337
    //-- return FS mounting error code if it wasn't OK, otherwise - extension mounting code.
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   338
    //-- for more info see error bitmap
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   339
    return (nFsMountRes != KErrNone) ? nFsMountRes : nExtMountRes;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   340
    }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   341
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   342
//-------------------------------------------------------------------
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   343
void TFsMntHelperImpl::Init() 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   344
    {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   345
    if(!this)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   346
        Panic(ENotInitialised); 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   347
    
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   348
    iDrvSynch = EFalse;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   349
    iFsName.Zero();
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   350
    iErrorBitmap = 0;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   351
             
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   352
    for(TInt i=0; i<KMaxExtensionCount; ++i) 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   353
        {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   354
        iExtNames[i].Zero();
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   355
        }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   356
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   357
    }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   358
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   359
//-------------------------------------------------------------------
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   360
/**
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   361
    Panics.
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   362
    @param aPanicCode   a panic code
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   363
*/
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   364
void TFsMntHelperImpl::Panic(TPanicCode aPanicCode) const
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   365
    {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   366
    _LIT(KPanicCat,"CFsMountHelper");
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   367
    User::Panic(KPanicCat, aPanicCode);
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   368
    }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   369
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   370
TFsMntHelperImpl::TFsMntHelperImpl(RFs& aFs, TInt aDrvNum) 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   371
                 :iFs(aFs), iDrvNum(aDrvNum) 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   372
    {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   373
    if(aDrvNum < EDriveA || aDrvNum >EDriveZ)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   374
        Panic(EDrvNumberInvalid);
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   375
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   376
    Init();
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   377
    }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   378
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   379
/**
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   380
    Debug only method. Compares 2 instances of the implementation
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   381
*/
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   382
TBool TFsMntHelperImpl::operator==(const TFsMntHelperImpl& aRhs) const
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   383
    {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   384
    ASSERT(this != &aRhs);
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   385
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   386
#ifdef _DEBUG
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   387
    
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   388
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   389
    if(iFsName.CompareF(aRhs.iFsName) !=0)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   390
        return EFalse;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   391
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   392
    for(TInt i=0; i<KMaxExtensionCount; ++i)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   393
        {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   394
        if(iExtNames[i].CompareF(aRhs.iExtNames[i]) !=0)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   395
        return EFalse;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   396
        }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   397
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   398
    if(!iDrvSynch != !aRhs.iDrvSynch)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   399
        return EFalse;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   400
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   401
    return ETrue;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   402
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   403
#else //_DEBUG
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   404
    (void)aRhs;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   405
    Panic(ENotImplemented);
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   406
    return EFalse;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   407
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   408
#endif// _DEBUG
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   409
}
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   410
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   411
279
957c583b417b 201039_07
hgs
parents: 271
diff changeset
   412
//-------------------------------------------------------------------
957c583b417b 201039_07
hgs
parents: 271
diff changeset
   413
/** 
957c583b417b 201039_07
hgs
parents: 271
diff changeset
   414
    Closes the object, deletes the implementation
957c583b417b 201039_07
hgs
parents: 271
diff changeset
   415
*/
957c583b417b 201039_07
hgs
parents: 271
diff changeset
   416
void CFsMountHelper::Close()
957c583b417b 201039_07
hgs
parents: 271
diff changeset
   417
{
957c583b417b 201039_07
hgs
parents: 271
diff changeset
   418
    delete ipImpl;
957c583b417b 201039_07
hgs
parents: 271
diff changeset
   419
    ipImpl = NULL;
957c583b417b 201039_07
hgs
parents: 271
diff changeset
   420
}
271
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   421
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   422
//-------------------------------------------------------------------
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   423
/**
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   424
    Factory function. Produces an object of this class
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   425
    
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   426
    @param  aFs     file server session
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   427
    @param  aDrvNum drive number
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   428
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   429
    @return pointer to the constructed object or NULL on error.
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   430
*/
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   431
EXPORT_C CFsMountHelper* CFsMountHelper::New(RFs& aFs, TInt aDrvNum)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   432
{
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   433
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   434
    CFsMountHelper* pSelf = new CFsMountHelper;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   435
    
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   436
    if(pSelf)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   437
        {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   438
        pSelf->ipImpl = new TFsMntHelperImpl(aFs, aDrvNum);
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   439
    
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   440
        if(!pSelf->ipImpl)
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   441
            {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   442
            delete pSelf;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   443
            pSelf = NULL;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   444
            }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   445
        }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   446
    
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   447
    return pSelf;
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   448
}
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   449
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   450
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   451
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   452
//-------------------------------------------------------------------
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   453
/** 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   454
    Acqires drive/mount/file system properties that will be used for mounting the file system back.
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   455
    @return Standard Error code.
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   456
*/
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   457
EXPORT_C TInt CFsMountHelper::GetMountProperties()
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   458
    {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   459
    return ipImpl->GetMountProperties();
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   460
    }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   461
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   462
//-------------------------------------------------------------------
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   463
/** 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   464
    Mount the file system onto the drive using properties previously acquired by GetMountProperties() call.
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   465
    Note that the drive shouldn't have the file system mounted, this API call will fail in this case.
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   466
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   467
    @return KErrNone if mounting file system + possible extensions was ok
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   468
            the result of file system mounting if the file system mounting failed (e.g. because of the damaged media) 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   469
            the result of mounting secondary extension if file system mounted OK, but secondary extension mounting resulted in some error.
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   470
*/
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   471
EXPORT_C TInt CFsMountHelper::MountFileSystem() const
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   472
    {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   473
    return ipImpl->MountFileSystem();
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   474
    }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   475
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   476
//-------------------------------------------------------------------
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   477
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   478
/**
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   479
    An asynchronous API to dismount the file system on the specified drive.
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   480
    Precondition: The drive / file system parameters at the time of this API call must be the same as acquired by the last call of GetMountProperties().
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   481
                  This is checked in debug mode to prevent possible inconsistencied when mounting the file system back later.   
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   482
                  This means that the GetMountProperties() should be called at least once before any attempt to dismount the file system.
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   483
    
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   484
    @param  aStat           request status. On completion will contain the dismounting result code.
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   485
    @param  aDismountMode   describes the dismounting method. See TFsDismountMode.
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   486
        
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   487
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   488
*/
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   489
EXPORT_C void CFsMountHelper::DismountFileSystem(TRequestStatus& aStat, TFsDismountMode aDismountMode/*=ENormal*/) const
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   490
    {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   491
    ipImpl->DismountFileSystem(aStat, aDismountMode);
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   492
    }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   493
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   494
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   495
//-------------------------------------------------------------------
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   496
/**
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   497
    A simplified synchronous version of the DismountFileSystem() API. 
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   498
    Works absolutely the same as RFs::DismountFileSystem()
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   499
    
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   500
    @return RFs::DismountFileSystem() result code
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   501
*/
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   502
EXPORT_C TInt CFsMountHelper::DismountFileSystem() const
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   503
    {
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   504
    TRequestStatus stat;    
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   505
    DismountFileSystem(stat, ENormal);
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   506
    User::WaitForRequest(stat);
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   507
    
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   508
    return stat.Int();
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   509
    }
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   510
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   511
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   512
279
957c583b417b 201039_07
hgs
parents: 271
diff changeset
   513
EXPORT_C CFsMountHelper::~CFsMountHelper() 
957c583b417b 201039_07
hgs
parents: 271
diff changeset
   514
    {
957c583b417b 201039_07
hgs
parents: 271
diff changeset
   515
    Close();
957c583b417b 201039_07
hgs
parents: 271
diff changeset
   516
    } 
271
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   517
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   518
dc268b18d709 201037_07
hgs
parents: 0
diff changeset
   519