|
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: JNI Layer corresponding to FileSystemUtils.java |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32cmn.h> |
|
20 #include <f32file.h> |
|
21 |
|
22 #include "javajniutils.h" |
|
23 #include "javasymbianoslayer.h" |
|
24 #include "s60commonutils.h" |
|
25 #include "logger.h" |
|
26 |
|
27 #include "systempropertyprovider.h" |
|
28 #include "com_nokia_mj_impl_file_FileSystemUtils.h" |
|
29 |
|
30 using namespace std; |
|
31 using namespace java::file; |
|
32 using namespace java::util; |
|
33 |
|
34 /* |
|
35 * Class: com_nokia_mj_impl_file_FileSystemUtils |
|
36 * Method: _getMemoryCardDrivePath |
|
37 * Signature: ()Ljava/lang/String; |
|
38 */ |
|
39 JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_file_FileSystemUtils__1getMemoryCardDrivePath |
|
40 (JNIEnv *aJni, jclass) |
|
41 { |
|
42 JELOG2(EJavaFile); |
|
43 TFileName fileName; |
|
44 SystemPropertyProvider::GetMemoryCardPath(fileName); |
|
45 wstring name((wchar_t*)fileName.PtrZ()); |
|
46 return JniUtils::wstringToJstring(aJni, name); |
|
47 } |
|
48 |
|
49 /* |
|
50 * Class: com_nokia_mj_impl_file_FileSystemUtils |
|
51 * Method: _getTemporaryDrivePath |
|
52 * Signature: ()Ljava/lang/String; |
|
53 */ |
|
54 JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_file_FileSystemUtils__1getTemporaryDrivePath |
|
55 (JNIEnv *aJni, jclass) |
|
56 { |
|
57 JELOG2(EJavaFile); |
|
58 TFileName fileName; |
|
59 SystemPropertyProvider::GetTemporaryDrive(fileName); |
|
60 wstring name((wchar_t*)fileName.PtrZ()); |
|
61 return JniUtils::wstringToJstring(aJni, name); |
|
62 } |
|
63 |
|
64 /* |
|
65 * Class: com_nokia_mj_impl_file_FileSystemUtils |
|
66 * Method: _getRomDrivePath |
|
67 * Signature: ()Ljava/lang/String; |
|
68 */ |
|
69 JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_file_FileSystemUtils__1getRomDrivePath |
|
70 (JNIEnv *aJni, jclass) |
|
71 { |
|
72 JELOG2(EJavaFile); |
|
73 TFileName fileName; |
|
74 SystemPropertyProvider::GetRomDrive(fileName); |
|
75 wstring name((wchar_t*)fileName.PtrZ()); |
|
76 return JniUtils::wstringToJstring(aJni, name); |
|
77 } |
|
78 |
|
79 /* |
|
80 * Class: com_nokia_mj_impl_file_FileSystemUtils |
|
81 * Method: _getDefaultRootPath |
|
82 * Signature: ()Ljava/lang/String; |
|
83 */ |
|
84 JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_file_FileSystemUtils__1getDefaultRootPath |
|
85 (JNIEnv *aJni, jclass) |
|
86 { |
|
87 JELOG2(EJavaFile); |
|
88 TFileName fileName; |
|
89 SystemPropertyProvider::GetDefaultRoot(fileName); |
|
90 wstring name((wchar_t*)fileName.PtrZ()); |
|
91 return JniUtils::wstringToJstring(aJni, name); |
|
92 } |
|
93 |
|
94 /* |
|
95 * Class: com_nokia_mj_impl_file_FileSystemUtils |
|
96 * Method: _getPathOfProperty |
|
97 * Signature: (I)Ljava/lang/String; |
|
98 */ |
|
99 JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_file_FileSystemUtils__1getPathOfProperty |
|
100 (JNIEnv *aJni, jclass, jint aKey, jboolean addRoot) |
|
101 { |
|
102 JELOG2(EJavaFile); |
|
103 TFileName fileName; |
|
104 SystemPropertyProvider::GetPathOfProperty(aKey, fileName, addRoot); |
|
105 wstring name((wchar_t*)fileName.PtrZ()); |
|
106 return JniUtils::wstringToJstring(aJni, name); |
|
107 } |
|
108 |
|
109 /* |
|
110 * Class: com_nokia_mj_impl_file_FileSystemUtils |
|
111 * Method: _getForbiddenPaths |
|
112 * Signature: ()Ljava/lang/String; |
|
113 */ |
|
114 JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_file_FileSystemUtils__1getForbiddenPaths |
|
115 (JNIEnv *aJni, jclass) |
|
116 { |
|
117 JELOG2(EJavaFile); |
|
118 jstring str = 0; |
|
119 HBufC* names = 0; |
|
120 |
|
121 SystemPropertyProvider::GetForbiddenPaths(names); |
|
122 TPtrC namePtr(names->Des()); |
|
123 if (0 != names) |
|
124 { |
|
125 str = S60CommonUtils::NativeToJavaString(*aJni, namePtr); |
|
126 delete names; |
|
127 } |
|
128 return str; |
|
129 } |
|
130 |
|
131 /* |
|
132 * Class: com_nokia_mj_impl_file_FileSystemUtils |
|
133 * Method: _getRestrictedPaths |
|
134 * Signature: ()Ljava/lang/String; |
|
135 */ |
|
136 JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_file_FileSystemUtils__1getRestrictedPaths |
|
137 (JNIEnv *aJni, jclass) |
|
138 { |
|
139 JELOG2(EJavaFile); |
|
140 jstring str = 0; |
|
141 HBufC* names = 0; |
|
142 |
|
143 TRAPD(err, SystemPropertyProvider::GetRestrictedPathsL(names)); |
|
144 |
|
145 if (KErrNone == err) |
|
146 { |
|
147 TPtrC namePtr(names->Des()); |
|
148 if (0 != names) |
|
149 { |
|
150 str = S60CommonUtils::NativeToJavaString(*aJni, namePtr); |
|
151 delete names; |
|
152 } |
|
153 } |
|
154 return str; |
|
155 } |