blob: 3e2dbb769913ad37e6e7d70e866d553ef5b747e4 [file] [log] [blame]
[email protected]6fa1e7ef2012-03-14 11:24:041// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]61c86c62011-08-02 16:11:162// 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
[email protected]61c86c62011-08-02 16:11:167#include "base/android/jni_android.h"
8#include "base/android/jni_string.h"
[email protected]f98d7b92011-09-09 10:17:359#include "base/android/scoped_java_ref.h"
[email protected]57999812013-02-24 05:40:5210#include "base/files/file_path.h"
[email protected]61c86c62011-08-02 16:11:1611
[email protected]e46f66152012-07-19 20:02:5512#include "jni/PathUtils_jni.h"
[email protected]61c86c62011-08-02 16:11:1613
14namespace base {
15namespace android {
16
[email protected]18011cb72012-10-02 22:03:3317bool GetDataDirectory(FilePath* result) {
[email protected]61c86c62011-08-02 16:11:1618 JNIEnv* env = AttachCurrentThread();
wnwen9c8dc6d2016-09-08 13:32:1219 ScopedJavaLocalRef<jstring> path = Java_PathUtils_getDataDirectory(env);
[email protected]18011cb72012-10-02 22:03:3320 FilePath data_path(ConvertJavaStringToUTF8(path));
21 *result = data_path;
22 return true;
[email protected]61c86c62011-08-02 16:11:1623}
24
[email protected]18011cb72012-10-02 22:03:3325bool GetCacheDirectory(FilePath* result) {
[email protected]61c86c62011-08-02 16:11:1626 JNIEnv* env = AttachCurrentThread();
wnwen9c8dc6d2016-09-08 13:32:1227 ScopedJavaLocalRef<jstring> path = Java_PathUtils_getCacheDirectory(env);
[email protected]18011cb72012-10-02 22:03:3328 FilePath cache_path(ConvertJavaStringToUTF8(path));
29 *result = cache_path;
30 return true;
[email protected]6fa1e7ef2012-03-14 11:24:0431}
32
wnwena56aa7b2015-07-09 14:30:3233bool GetThumbnailCacheDirectory(FilePath* result) {
34 JNIEnv* env = AttachCurrentThread();
35 ScopedJavaLocalRef<jstring> path =
wnwen9c8dc6d2016-09-08 13:32:1236 Java_PathUtils_getThumbnailCacheDirectory(env);
wnwena56aa7b2015-07-09 14:30:3237 FilePath thumbnail_cache_path(ConvertJavaStringToUTF8(path));
38 *result = thumbnail_cache_path;
39 return true;
40}
41
[email protected]18011cb72012-10-02 22:03:3342bool GetDownloadsDirectory(FilePath* result) {
[email protected]6fa1e7ef2012-03-14 11:24:0443 JNIEnv* env = AttachCurrentThread();
wnwen9c8dc6d2016-09-08 13:32:1244 ScopedJavaLocalRef<jstring> path = Java_PathUtils_getDownloadsDirectory(env);
[email protected]18011cb72012-10-02 22:03:3345 FilePath downloads_path(ConvertJavaStringToUTF8(path));
46 *result = downloads_path;
47 return true;
[email protected]61c86c62011-08-02 16:11:1648}
49
[email protected]18011cb72012-10-02 22:03:3350bool GetNativeLibraryDirectory(FilePath* result) {
[email protected]672898b2012-07-02 20:04:0451 JNIEnv* env = AttachCurrentThread();
52 ScopedJavaLocalRef<jstring> path =
wnwen9c8dc6d2016-09-08 13:32:1253 Java_PathUtils_getNativeLibraryDirectory(env);
[email protected]18011cb72012-10-02 22:03:3354 FilePath library_path(ConvertJavaStringToUTF8(path));
55 *result = library_path;
56 return true;
[email protected]672898b2012-07-02 20:04:0457}
58
[email protected]18011cb72012-10-02 22:03:3359bool GetExternalStorageDirectory(FilePath* result) {
[email protected]fa67f76c2012-08-24 10:08:2760 JNIEnv* env = AttachCurrentThread();
61 ScopedJavaLocalRef<jstring> path =
62 Java_PathUtils_getExternalStorageDirectory(env);
[email protected]18011cb72012-10-02 22:03:3363 FilePath storage_path(ConvertJavaStringToUTF8(path));
64 *result = storage_path;
65 return true;
[email protected]fa67f76c2012-08-24 10:08:2766}
67
[email protected]61c86c62011-08-02 16:11:1668} // namespace android
69} // namespace base