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 "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-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 "tmsdrive.h" |
|
24 |
|
25 extern RTest test; |
|
26 extern RFs fsSession; |
|
27 |
|
28 |
|
29 void TMsDrive::GetUsbDeviceL() |
|
30 { |
|
31 TDriveList drivelist1; |
|
32 TDriveList drivelist2; |
|
33 TChar driveLetter; |
|
34 TInt driveNumber; |
|
35 |
|
36 User::LeaveIfError(fsSession.DriveList(drivelist1)); |
|
37 for (driveNumber = EDriveA; driveNumber <= EDriveZ; driveNumber++) |
|
38 { |
|
39 if (drivelist1[driveNumber]) |
|
40 { |
|
41 User::LeaveIfError(fsSession.DriveToChar(driveNumber, driveLetter)); |
|
42 } |
|
43 } |
|
44 |
|
45 TRequestStatus status; |
|
46 fsSession.NotifyChange(ENotifyAll, status); |
|
47 |
|
48 test.Printf(_L("Waiting for File System change notifcation...\r\n")); |
|
49 User::WaitForRequest(status); |
|
50 test.Printf(_L("NotifyChange status=%d\r\n"), status.Int()); |
|
51 |
|
52 User::LeaveIfError(fsSession.DriveList(drivelist2)); |
|
53 for (driveNumber = EDriveA; driveNumber <= EDriveZ; driveNumber++) |
|
54 { |
|
55 if (drivelist2[driveNumber]) |
|
56 { |
|
57 User::LeaveIfError(fsSession.DriveToChar(driveNumber,driveLetter)); |
|
58 } |
|
59 } |
|
60 |
|
61 for (driveNumber = 0; driveNumber < drivelist1.Length(); driveNumber++) |
|
62 { |
|
63 if (drivelist1[driveNumber] != drivelist2[driveNumber]) |
|
64 { |
|
65 break; |
|
66 } |
|
67 } |
|
68 |
|
69 |
|
70 User::LeaveIfError(fsSession.DriveToChar(driveNumber,driveLetter)); |
|
71 test.Printf(_L("Drive mounted on %c (0x%02x)"), TUint(driveLetter), drivelist2[driveNumber]); |
|
72 |
|
73 TRAPD(err, TMsPrintDrive::VolInfoL(driveNumber)); |
|
74 // ignore error |
|
75 err = err; |
|
76 iDriveNumber = driveNumber; |
|
77 } |
|
78 |
|
79 |
|
80 void TMsDrive::SetSessionPathL() |
|
81 { |
|
82 TChar driveLetter; |
|
83 User::LeaveIfError(fsSession.DriveToChar(iDriveNumber, driveLetter)); |
|
84 TFileName path; |
|
85 |
|
86 _LIT(KPath, "%c:\\"); |
|
87 path.Format(KPath, TUint(driveLetter)); |
|
88 |
|
89 TInt err = fsSession.SetSessionPath(path); |
|
90 test(err == KErrNone); |
|
91 err = fsSession.SessionPath(iSessionPath); |
|
92 test(err == KErrNone); |
|
93 _LIT(KSession,"Session path for fsSession is %S\n"); |
|
94 test.Printf(KSession, &iSessionPath); |
|
95 } |
|
96 |
|
97 |
|
98 |
|
99 const TFileName& TMsDrive::GetSessionPath() const |
|
100 { |
|
101 return iSessionPath; |
|
102 } |
|
103 |
|
104 TBool TMsDrive::DrivePresent() const |
|
105 { |
|
106 TDriveInfo driveInfo; |
|
107 fsSession.Drive(driveInfo, iDriveNumber); |
|
108 return driveInfo.iType == EMediaNotPresent ? EFalse : ETrue; |
|
109 } |
|
110 |
|
111 |
|