|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: DriveUtilities - S60 specific |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <f32file.h> |
|
19 #include <driveinfo.h> |
|
20 |
|
21 #include "logger.h" |
|
22 |
|
23 #include "driveutilities.h" |
|
24 |
|
25 namespace java |
|
26 { |
|
27 namespace fileutils |
|
28 { |
|
29 OS_EXPORT void DriveUtilities::getAllDrives(driveInfos& aDriveInfos) |
|
30 { |
|
31 JELOG2(EJavaFile); |
|
32 |
|
33 int rc = KErrNone; |
|
34 |
|
35 RFs fs; |
|
36 if (KErrNone == (rc = fs.Connect())) |
|
37 { |
|
38 TDriveList driveList; |
|
39 if (KErrNone == (rc = fs.DriveList(driveList))) |
|
40 { |
|
41 TInt driveCount = KMaxDrives; // driveArray.Count(); |
|
42 for (TInt index = 0 ; index < driveCount ; index++) |
|
43 { |
|
44 if (0 != driveList[index]) |
|
45 { |
|
46 driveInfo di; |
|
47 TChar ret(0); |
|
48 RFs::DriveToChar(index, ret); |
|
49 di.iRootPath = (wchar_t) ret; |
|
50 di.iRootPath += L":\\"; |
|
51 |
|
52 TUint status = 0; |
|
53 if (KErrNone == (rc = DriveInfo::GetDriveStatus(fs, index, status))) |
|
54 { |
|
55 di.iIsPresent = status & DriveInfo::EDrivePresent; |
|
56 di.iIsRemovable = status & DriveInfo::EDriveRemovable; |
|
57 di.iIsLocal =!(status & DriveInfo::EDriveRemote); |
|
58 di.iIsReadOnly = status & DriveInfo::EDriveReadOnly; |
|
59 di.iIsExternallyMountable = status & DriveInfo::EDriveExternallyMountable; |
|
60 TVolumeInfo volumeInfo; |
|
61 if (KErrNone == (rc = fs.Volume(volumeInfo, index))) |
|
62 { |
|
63 di.iId = volumeInfo.iUniqueID; |
|
64 } |
|
65 else |
|
66 { |
|
67 di.iId = 0; |
|
68 } |
|
69 } |
|
70 |
|
71 aDriveInfos.push_back(di); |
|
72 } |
|
73 } |
|
74 } |
|
75 fs.Close(); |
|
76 } |
|
77 |
|
78 if (KErrNone != rc) |
|
79 { |
|
80 ELOG1(EJavaFile, "getAllDrives failed due to SymbianOS error %d", rc); |
|
81 } |
|
82 } |
|
83 } // end of namespace fileutils |
|
84 } // end of namespace java |