os/kernelhwsrv/kerneltest/f32test/testfsys/t_tfsys2.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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_tfsys2.cpp
    15 // 
    16 //
    17 
    18 #include "t_tfsys2.h"
    19 
    20 
    21 const TInt KMajorVersionNumber=1;
    22 const TInt KMinorVersionNumber=0;
    23 
    24 //TInt gMountAttempts = 0;
    25 
    26 CTestFileSystem::CTestFileSystem()
    27 //
    28 // Constructor
    29 //
    30 	{
    31 	__DECLARE_NAME(_S("CTestFileSystem2"));
    32 	}
    33 
    34 CTestFileSystem::~CTestFileSystem()
    35 //
    36 // Destructor
    37 //
    38 	{}
    39 
    40 TInt CTestFileSystem::Install()
    41 //
    42 // Install the file system
    43 //
    44 	{
    45 	iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KF32BuildVersionNumber);
    46 	TPtrC name=_L("Test2");
    47 	return(SetName(&name));
    48 	}
    49 
    50 CMountCB* CTestFileSystem::NewMountL() const
    51 //
    52 // Create a new mount control block
    53 //
    54 	{
    55 	CTestMountCB* mount = new(ELeave) CTestMountCB;
    56 	mount->SetFsy(this);
    57 	return  mount;
    58 	}
    59 
    60 CFileCB* CTestFileSystem::NewFileL() const
    61 //
    62 // Create a new file
    63 //
    64 	{
    65 	return (new(ELeave) CTestFileCB);
    66 	}
    67 
    68 CDirCB* CTestFileSystem::NewDirL() const
    69 //
    70 // create a new directory lister
    71 //
    72 	{
    73 	return (new(ELeave) CTestDirCB);
    74 	}
    75 
    76 CFormatCB* CTestFileSystem::NewFormatL() const
    77 //
    78 // Create a new media formatter
    79 //
    80 	{
    81 	return (new(ELeave) CTestFormatCB);
    82 	}
    83 
    84 TInt CTestFileSystem::DefaultPath(TDes& aPath) const
    85 //
    86 // Return the intial default path
    87 //
    88 	{
    89 	aPath=_L("C:\\");
    90 	return (KErrNone);
    91 	}
    92 
    93 void CTestFileSystem::DriveInfo(TDriveInfo& anInfo,TInt aDriveNumber) const
    94 //
    95 // Return drive info
    96 //
    97 	{
    98     CFileSystem::DriveInfo(anInfo, aDriveNumber);
    99 
   100 	// hijack the iBattery member to report back the number of times MountL() has been called
   101 	anInfo.iBattery = (TBatteryState) iMountAttempts;
   102 	}
   103 
   104 /**
   105 Reports whether the specified interface is supported - if it is,
   106 the supplied interface object is modified to it
   107 
   108 @param aInterfaceId     The interface of interest
   109 @param aInterface       The interface object
   110 @return                 KErrNone if the interface is supported, otherwise KErrNotFound 
   111 
   112 @see CFileSystem::GetInterface()
   113 */
   114 TInt CTestFileSystem::GetInterface(TInt aInterfaceId, TAny*& aInterface,TAny* aInput)
   115     {
   116     switch(aInterfaceId)
   117         {
   118         case CFileSystem::EProxyDriveSupport: // The FAT Filesystem supports proxy drives
   119 			return KErrNone;
   120 
   121         default:
   122             return(CFileSystem::GetInterface(aInterfaceId, aInterface, aInput));
   123         }
   124     }
   125 
   126 CFileSystem* CTestFileSystem::NewL()
   127 //
   128 //
   129 //
   130 	{
   131 	CFileSystem* testFSys = new(ELeave) CTestFileSystem;
   132 	return testFSys;
   133 	}
   134 
   135 
   136 CTestMountCB::CTestMountCB() : iFileSystem(NULL)
   137 	{
   138 	};
   139 
   140 CTestMountCB::~CTestMountCB(){};
   141 CTestDirCB::CTestDirCB(){};
   142 CTestDirCB::~CTestDirCB(){};
   143 CTestFileCB::CTestFileCB(){};
   144 CTestFileCB::~CTestFileCB(){};
   145 CTestFormatCB::CTestFormatCB(){};
   146 CTestFormatCB::~CTestFormatCB(){};
   147 void CTestMountCB::MountL(TBool /*aForceMount*/)
   148 	{
   149 	if (iFileSystem)
   150 		iFileSystem->iMountAttempts++;
   151 
   152 	User::Leave(KErrCorrupt);
   153 	}
   154 
   155 void CTestMountCB::EntryL(const TDesC& /*aName*/,TEntry& /*anEntry*/) const
   156 	{
   157 	User::Leave(KErrNotFound);
   158 	}
   159 
   160 TInt CTestMountCB::ForceRemountDrive(const TDesC8* /*aMountInfo*/,TInt /*aMountInfoMessageHandle*/,TUint /*aFlags*/)
   161 	{
   162 	Drive().SetChanged(ETrue);
   163 	return(KErrNone);
   164 	}
   165 
   166 void CTestMountCB::SetFsy(const CTestFileSystem* aFileSystem)
   167 	{
   168 	iFileSystem = const_cast<CTestFileSystem*> (aFileSystem);
   169 	}
   170 
   171 extern "C" {
   172 
   173 EXPORT_C CFileSystem* CreateFileSystem()
   174 //
   175 // Create a new file system
   176 //
   177 	{
   178 	return(CTestFileSystem::NewL());
   179 	}
   180 }
   181