Update contrib.
1 // Copyright (c) 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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
18 #include "rusbhostmsdevice.h"
19 #include "rusbhostmslogicalunit.h"
20 #include "rextfilesystem.h"
24 _LIT(KFsNm, "elocal");
26 RExtFileSystem::RExtFileSystem()
31 RExtFileSystem::~RExtFileSystem()
37 void RExtFileSystem::OpenL()
41 User::LeaveIfError(fs.Connect());
42 CleanupClosePushL(fs);
45 err = fs.AddFileSystem(KFsNm);
46 if (err != KErrAlreadyExists)
47 User::LeaveIfError(err);
49 err = fs.AddFileSystem(_L("ELOCAL"));
50 if (!(KErrAlreadyExists == err || KErrCorrupt == err))
51 User::LeaveIfError(err);
53 err = fs.AddProxyDrive(_L("usbhostms.pxy"));
54 if (!(KErrAlreadyExists == err || KErrCorrupt == err))
55 User::LeaveIfError(err);
57 CleanupStack::PopAndDestroy(&fs);
61 void RExtFileSystem::CloseL()
65 User::LeaveIfError(fs.Connect());
66 CleanupClosePushL(fs);
67 TInt err = fs.RemoveProxyDrive(_L("usbhostms"));
68 CleanupStack::PopAndDestroy(&fs);
72 void RExtFileSystem::MountL(RUsbHostMsDevice& aDevice,
73 TDriveNumber aDriveNumber,
85 User::LeaveIfError(fs.Connect());
86 CleanupClosePushL(fs);
89 err = aDevice.MountLun(aLun, aDriveNumber);
90 if (!(KErrAlreadyExists == err || KErrNotReady == err))
92 __PRINT1(_L("** Error: MountLun returned %d **"), err);
93 RDebug::Print(_L("** Error: MountLun returned %d **"), err);
94 User::LeaveIfError(err);
97 CleanupStack::PopAndDestroy(&fs);
101 TTimeIntervalSeconds timeTaken;
102 end.SecondsFrom(start, timeTaken);
103 TUint totalTime = timeTaken.Int();
104 RDebug::Print(_L("Mount has taken %dHrs:%dmins:%dsecs\n"),
111 void RExtFileSystem::DismountL(RUsbHostMsDevice& aDevice, TDriveNumber aDriveNumber)
115 User::LeaveIfError(fs.Connect());
116 __PRINT(_L("DismountFileSystem"));
117 //TInt err = aDevice.DismountLun(aDriveNumber);
118 aDevice.DismountLun(aDriveNumber);
123 TDriveNumber RExtFileSystem::GetDriveL()
126 User::LeaveIfError(fs.Connect());
127 TDriveList driveList;
128 fs.DriveList(driveList);
132 for (drive = EDriveG; drive <= EDriveZ; drive++)
134 // Skip K drive which is reserved for LFFS but shows as being free
135 if (drive == EDriveK)
139 if (driveList[drive] == 0)
147 RDebug::Print(_L("####### NOT Found free drive"));
148 User::Leave(KErrInUse);
151 __PRINT1(_L("Found free drive @ %d"), drive);
152 RDebug::Print(_L("####### Found free drive @ %d"), drive);
153 return static_cast<TDriveNumber>(drive);