0
|
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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
|
|
17 |
#include <e32def.h>
|
|
18 |
#include <e32cmn.h>
|
|
19 |
#include <f32file.h>
|
|
20 |
#include <e32test.h>
|
|
21 |
|
|
22 |
#include "tmsprintdrive.h"
|
|
23 |
#include "cmsdrive.h"
|
|
24 |
|
|
25 |
extern RTest test;
|
|
26 |
extern RFs fsSession;
|
|
27 |
|
|
28 |
#define __CMSDRIVE_DEBUG
|
|
29 |
|
|
30 |
CMsDrive* CMsDrive::NewL()
|
|
31 |
{
|
|
32 |
CMsDrive* r = new (ELeave) CMsDrive();
|
|
33 |
CleanupStack::PushL(r);
|
|
34 |
|
|
35 |
r->ConstructL();
|
|
36 |
CleanupStack::Pop();
|
|
37 |
return r;
|
|
38 |
}
|
|
39 |
|
|
40 |
|
|
41 |
void CMsDrive::ConstructL()
|
|
42 |
{
|
|
43 |
}
|
|
44 |
|
|
45 |
|
|
46 |
CMsDrive::CMsDrive()
|
|
47 |
{
|
|
48 |
GetInitialDriveMapL();
|
|
49 |
}
|
|
50 |
|
|
51 |
|
|
52 |
CMsDrive::~CMsDrive()
|
|
53 |
{
|
|
54 |
}
|
|
55 |
|
|
56 |
|
|
57 |
void CMsDrive::GetInitialDriveMapL()
|
|
58 |
{
|
|
59 |
TChar driveLetter;
|
|
60 |
|
|
61 |
User::LeaveIfError(fsSession.DriveList(iOriginalDrivelist));
|
|
62 |
|
|
63 |
#ifdef __CMSDRIVE_DEBUG
|
|
64 |
for (TInt driveNumber = EDriveA; driveNumber <= EDriveZ; driveNumber++)
|
|
65 |
{
|
|
66 |
if (iOriginalDrivelist[driveNumber])
|
|
67 |
{
|
|
68 |
User::LeaveIfError(fsSession.DriveToChar(driveNumber, driveLetter));
|
|
69 |
RDebug::Printf("> %d %c", driveNumber, (char)driveLetter);
|
|
70 |
}
|
|
71 |
}
|
|
72 |
#endif
|
|
73 |
}
|
|
74 |
|
|
75 |
|
|
76 |
TBool CMsDrive::GetUsbDeviceL()
|
|
77 |
{
|
|
78 |
TChar driveLetter;
|
|
79 |
TInt driveNumber;
|
|
80 |
|
|
81 |
User::LeaveIfError(fsSession.DriveList(iMsDrivelist));
|
|
82 |
#ifdef __CMSDRIVE_DEBUG
|
|
83 |
for (driveNumber = EDriveA; driveNumber <= EDriveZ; driveNumber++)
|
|
84 |
{
|
|
85 |
if (iMsDrivelist[driveNumber])
|
|
86 |
{
|
|
87 |
User::LeaveIfError(fsSession.DriveToChar(driveNumber,driveLetter));
|
|
88 |
RDebug::Printf("< %d %c", driveNumber, (char)driveLetter);
|
|
89 |
}
|
|
90 |
}
|
|
91 |
#endif
|
|
92 |
|
|
93 |
const TInt maxDrives = iOriginalDrivelist.Length();
|
|
94 |
for (driveNumber = 0; driveNumber < maxDrives; driveNumber++)
|
|
95 |
{
|
|
96 |
if (iOriginalDrivelist[driveNumber] != iMsDrivelist[driveNumber])
|
|
97 |
{
|
|
98 |
break;
|
|
99 |
}
|
|
100 |
}
|
|
101 |
|
|
102 |
if (driveNumber == maxDrives)
|
|
103 |
{
|
|
104 |
return EFalse;
|
|
105 |
}
|
|
106 |
|
|
107 |
User::LeaveIfError(fsSession.DriveToChar(driveNumber,driveLetter));
|
|
108 |
test.Printf(_L("Drive mounted on %c (0x%02x)"), TUint(driveLetter), iMsDrivelist[driveNumber]);
|
|
109 |
|
|
110 |
TRAPD(err, TMsPrintDrive::VolInfoL(driveNumber));
|
|
111 |
// ignore error
|
|
112 |
err = err;
|
|
113 |
iDriveNumber = driveNumber;
|
|
114 |
return ETrue;
|
|
115 |
}
|
|
116 |
|
|
117 |
|
|
118 |
void CMsDrive::SetSessionPathL()
|
|
119 |
{
|
|
120 |
TChar driveLetter;
|
|
121 |
User::LeaveIfError(fsSession.DriveToChar(iDriveNumber, driveLetter));
|
|
122 |
TFileName path;
|
|
123 |
|
|
124 |
_LIT(KPath, "%c:\\");
|
|
125 |
path.Format(KPath, TUint(driveLetter));
|
|
126 |
|
|
127 |
TInt err = fsSession.SetSessionPath(path);
|
|
128 |
test(err == KErrNone);
|
|
129 |
err = fsSession.SessionPath(iSessionPath);
|
|
130 |
test(err == KErrNone);
|
|
131 |
_LIT(KSession,"Session path for fsSession is %S\n");
|
|
132 |
test.Printf(KSession, &iSessionPath);
|
|
133 |
}
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
const TFileName& CMsDrive::GetSessionPath() const
|
|
138 |
{
|
|
139 |
return iSessionPath;
|
|
140 |
}
|
|
141 |
|
|
142 |
TBool CMsDrive::DrivePresent() const
|
|
143 |
{
|
|
144 |
TDriveInfo driveInfo;
|
|
145 |
fsSession.Drive(driveInfo, iDriveNumber);
|
|
146 |
return driveInfo.iType == EMediaNotPresent ? EFalse : ETrue;
|
|
147 |
}
|
|
148 |
|
|
149 |
|