kerneltest/f32test/testfsys/t_tfsys3.cpp
changeset 0 a41df078684a
child 33 0173bcd7697c
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2006-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 "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // f32test\testfsys\t_tfsys3.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "t_tfsys3.h"
       
    19 
       
    20 
       
    21 const TInt KMajorVersionNumber=1;
       
    22 const TInt KMinorVersionNumber=0;
       
    23 
       
    24 CTestFileSystem::CTestFileSystem()
       
    25 //
       
    26 // Constructor
       
    27 //
       
    28 	{
       
    29 	__DECLARE_NAME(_S("CTestFileSystem3"));
       
    30 	}
       
    31 
       
    32 CTestFileSystem::~CTestFileSystem()
       
    33 //
       
    34 // Destructor
       
    35 //
       
    36 	{}
       
    37 
       
    38 TInt CTestFileSystem::Install()
       
    39 //
       
    40 // Install the file system
       
    41 //
       
    42 	{
       
    43 	iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KF32BuildVersionNumber);
       
    44 	TPtrC name=_L("Test3");
       
    45 	return(SetName(&name));
       
    46 	}
       
    47 
       
    48 CMountCB* CTestFileSystem::NewMountL() const
       
    49 //
       
    50 // Create a new mount control block
       
    51 //
       
    52 	{
       
    53 	return (new(ELeave) CTestMountCB);
       
    54 	}
       
    55 
       
    56 CFileCB* CTestFileSystem::NewFileL() const
       
    57 //
       
    58 // Create a new file
       
    59 //
       
    60 	{
       
    61 	return (new(ELeave) CTestFileCB);
       
    62 	}
       
    63 
       
    64 CDirCB* CTestFileSystem::NewDirL() const
       
    65 //
       
    66 // create a new directory lister
       
    67 //
       
    68 	{
       
    69 	return (new(ELeave) CTestDirCB);
       
    70 	}
       
    71 
       
    72 CFormatCB* CTestFileSystem::NewFormatL() const
       
    73 //
       
    74 // Create a new media formatter
       
    75 //
       
    76 	{
       
    77 	return (new(ELeave) CTestFormatCB);
       
    78 	}
       
    79 
       
    80 TInt CTestFileSystem::DefaultPath(TDes& aPath) const
       
    81 //
       
    82 // Return the intial default path
       
    83 //
       
    84 	{
       
    85 	aPath=_L("C:\\");
       
    86 	return (KErrNone);
       
    87 	}
       
    88 
       
    89 void CTestFileSystem::DriveInfo(TDriveInfo& anInfo,TInt aDriveNumber) const
       
    90 //
       
    91 // Return drive info - iDriveAtt and iBatteryState are already set
       
    92 //
       
    93 	{
       
    94 	if(!IsValidLocalDriveMapping(aDriveNumber))
       
    95 		return;
       
    96 
       
    97     TLocalDriveCapsV2Buf localDriveCaps;
       
    98 	
       
    99 	// is the drive local?
       
   100 	if (!IsProxyDrive(aDriveNumber))
       
   101 		{
       
   102 		// if not valid local drive, use default values in localDriveCaps
       
   103 		// if valid local drive and not locked, use TBusLocalDrive::Caps() values
       
   104 		// if valid drive and locked, hard-code attributes
       
   105 		(void)GetLocalDrive(aDriveNumber).Caps(localDriveCaps);
       
   106 		}
       
   107 	else  // this need to be made a bit nicer
       
   108 		{   
       
   109 		CExtProxyDrive* pD = GetProxyDrive(aDriveNumber);
       
   110 		if(pD)
       
   111 			{
       
   112 			(void)pD->Caps(localDriveCaps);
       
   113 			}
       
   114 		}
       
   115 
       
   116 	anInfo.iMediaAtt=localDriveCaps().iMediaAtt;
       
   117 	anInfo.iType=localDriveCaps().iType;
       
   118 	anInfo.iDriveAtt=localDriveCaps().iDriveAtt;
       
   119 	}
       
   120 
       
   121 /**
       
   122 Reports whether the specified interface is supported - if it is,
       
   123 the supplied interface object is modified to it
       
   124 
       
   125 @param aInterfaceId     The interface of interest
       
   126 @param aInterface       The interface object
       
   127 @return                 KErrNone if the interface is supported, otherwise KErrNotFound 
       
   128 
       
   129 @see CFileSystem::GetInterface()
       
   130 */
       
   131 TInt CTestFileSystem::GetInterface(TInt aInterfaceId, TAny*& aInterface,TAny* aInput)
       
   132     {
       
   133     switch(aInterfaceId)
       
   134         {
       
   135         case CFileSystem::EProxyDriveSupport: // The FAT Filesystem supports proxy drives
       
   136 			return KErrNone;
       
   137 
       
   138         default:
       
   139             return(CFileSystem::GetInterface(aInterfaceId, aInterface, aInput));
       
   140         }
       
   141     }
       
   142 
       
   143 CFileSystem* CTestFileSystem::NewL()
       
   144 //
       
   145 //
       
   146 //
       
   147 	{
       
   148 	CFileSystem* testFSys = new(ELeave) CTestFileSystem;
       
   149 	return testFSys;
       
   150 	}
       
   151 
       
   152 
       
   153 CTestMountCB::CTestMountCB(){};
       
   154 CTestMountCB::~CTestMountCB(){};
       
   155 CTestDirCB::CTestDirCB(){};
       
   156 CTestDirCB::~CTestDirCB(){};
       
   157 CTestFileCB::CTestFileCB(){};
       
   158 CTestFileCB::~CTestFileCB(){};
       
   159 CTestFormatCB::CTestFormatCB(){};
       
   160 CTestFormatCB::~CTestFormatCB(){};
       
   161 
       
   162 
       
   163 extern "C" {
       
   164 
       
   165 EXPORT_C CFileSystem* CreateFileSystem()
       
   166 //
       
   167 // Create a new file system
       
   168 //
       
   169 	{
       
   170 	return(CTestFileSystem::NewL());
       
   171 	}
       
   172 }
       
   173 
       
   174 TInt CTestMountCB::ClusterSize() const
       
   175 	{
       
   176 	return KTestClusterSize;
       
   177 	}
       
   178 
       
   179 TInt CTestMountCB::SubType(TDes& aName) const
       
   180 	{
       
   181 	if(aName.MaxLength() < 12)
       
   182 		return KErrArgument;
       
   183 
       
   184 	aName = _L("Test3SubType");
       
   185 	return KErrNone;
       
   186 	}
       
   187 
       
   188 TInt CTestMountCB::GetInterface(TInt aInterfaceId, TAny*& aInterface,TAny* aInput)
       
   189 	{
       
   190 	switch(aInterfaceId)
       
   191 		{
       
   192 		case (CMountCB::EGetFileSystemSubType):
       
   193 			{
       
   194 			aInterface = (MFileSystemSubType*) (this);
       
   195 			return KErrNone;
       
   196 			}
       
   197 		case (CMountCB::EGetClusterSize):
       
   198 			{
       
   199 			aInterface = (MFileSystemClusterSize*) (this);
       
   200 			return KErrNone;
       
   201 			}
       
   202 		default:
       
   203 			{
       
   204 			return(CMountCB::GetInterface(aInterfaceId, aInterface, aInput));
       
   205 			}
       
   206 		}
       
   207 	}