blob: 1e8d1e8308828c74dffb1592a019da5313c2691d [file] [log] [blame]
peter@chromium.orgf63cdf12012-03-14 20:24:04 +09001// Copyright (c) 2012 The Chromium Authors. All rights reserved.
michaelbai@google.com686190b2011-08-03 01:11:16 +09002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "base/android/path_utils.h"
6
michaelbai@google.com686190b2011-08-03 01:11:16 +09007#include "base/android/jni_android.h"
8#include "base/android/jni_string.h"
joth@chromium.orged27f3a2011-09-09 19:17:35 +09009#include "base/android/scoped_java_ref.h"
michaelbai@google.com686190b2011-08-03 01:11:16 +090010
bulach@chromium.org4c248ed2012-07-20 05:02:55 +090011#include "jni/PathUtils_jni.h"
michaelbai@google.com686190b2011-08-03 01:11:16 +090012
13namespace base {
14namespace android {
15
16std::string GetDataDirectory() {
17 JNIEnv* env = AttachCurrentThread();
peter@chromium.orgf63cdf12012-03-14 20:24:04 +090018 ScopedJavaLocalRef<jstring> path =
19 Java_PathUtils_getDataDirectory(env, GetApplicationContext());
20 return ConvertJavaStringToUTF8(path);
michaelbai@google.com686190b2011-08-03 01:11:16 +090021}
22
23std::string GetCacheDirectory() {
24 JNIEnv* env = AttachCurrentThread();
peter@chromium.orgf63cdf12012-03-14 20:24:04 +090025 ScopedJavaLocalRef<jstring> path =
26 Java_PathUtils_getCacheDirectory(env, GetApplicationContext());
27 return ConvertJavaStringToUTF8(path);
28}
29
30std::string GetDownloadsDirectory() {
31 JNIEnv* env = AttachCurrentThread();
32 ScopedJavaLocalRef<jstring> path =
33 Java_PathUtils_getDownloadsDirectory(env, GetApplicationContext());
34 return ConvertJavaStringToUTF8(path);
michaelbai@google.com686190b2011-08-03 01:11:16 +090035}
36
aurimas@chromium.org59cc7cf2012-07-03 05:04:04 +090037std::string GetNativeLibraryDirectory() {
38 JNIEnv* env = AttachCurrentThread();
39 ScopedJavaLocalRef<jstring> path =
40 Java_PathUtils_getNativeLibraryDirectory(env, GetApplicationContext());
41 return ConvertJavaStringToUTF8(path);
42}
43
nileshagrawal@chromium.orga4be12c2012-08-24 19:08:27 +090044std::string GetExternalStorageDirectory() {
45 JNIEnv* env = AttachCurrentThread();
46 ScopedJavaLocalRef<jstring> path =
47 Java_PathUtils_getExternalStorageDirectory(env);
48 return ConvertJavaStringToUTF8(path);
49}
50
michaelbai@google.com686190b2011-08-03 01:11:16 +090051bool RegisterPathUtils(JNIEnv* env) {
52 return RegisterNativesImpl(env);
53}
54
55} // namespace android
56} // namespace base